arc.c (321553) | arc.c (321562) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 6301 unchanged lines hidden (view full) --- 6310 return (arc_c_max); 6311} 6312 6313void 6314arc_init(void) 6315{ 6316 int i, prefetch_tunable_set = 0; 6317 | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 6301 unchanged lines hidden (view full) --- 6310 return (arc_c_max); 6311} 6312 6313void 6314arc_init(void) 6315{ 6316 int i, prefetch_tunable_set = 0; 6317 |
6318 /* 6319 * allmem is "all memory that we could possibly use". 6320 */ 6321#ifdef illumos 6322#ifdef _KERNEL 6323 uint64_t allmem = ptob(physmem - swapfs_minfree); 6324#else 6325 uint64_t allmem = (physmem * PAGESIZE) / 2; 6326#endif 6327#else 6328 uint64_t allmem = kmem_size(); 6329#endif 6330 6331 |
|
6318 mutex_init(&arc_reclaim_lock, NULL, MUTEX_DEFAULT, NULL); 6319 cv_init(&arc_reclaim_thread_cv, NULL, CV_DEFAULT, NULL); 6320 cv_init(&arc_reclaim_waiters_cv, NULL, CV_DEFAULT, NULL); 6321 6322 mutex_init(&arc_dnlc_evicts_lock, NULL, MUTEX_DEFAULT, NULL); 6323 cv_init(&arc_dnlc_evicts_cv, NULL, CV_DEFAULT, NULL); 6324 6325 /* Convert seconds to clock ticks */ 6326 arc_min_prefetch_lifespan = 1 * hz; 6327 6328 /* Start out with 1/8 of all memory */ | 6332 mutex_init(&arc_reclaim_lock, NULL, MUTEX_DEFAULT, NULL); 6333 cv_init(&arc_reclaim_thread_cv, NULL, CV_DEFAULT, NULL); 6334 cv_init(&arc_reclaim_waiters_cv, NULL, CV_DEFAULT, NULL); 6335 6336 mutex_init(&arc_dnlc_evicts_lock, NULL, MUTEX_DEFAULT, NULL); 6337 cv_init(&arc_dnlc_evicts_cv, NULL, CV_DEFAULT, NULL); 6338 6339 /* Convert seconds to clock ticks */ 6340 arc_min_prefetch_lifespan = 1 * hz; 6341 6342 /* Start out with 1/8 of all memory */ |
6329 arc_c = kmem_size() / 8; | 6343 arc_c = allmem / 8; |
6330 6331#ifdef illumos 6332#ifdef _KERNEL 6333 /* 6334 * On architectures where the physical memory can be larger 6335 * than the addressable space (intel in 32-bit mode), we may 6336 * need to limit the cache to 1/8 of VM size. 6337 */ 6338 arc_c = MIN(arc_c, vmem_size(heap_arena, VMEM_ALLOC | VMEM_FREE) / 8); 6339#endif 6340#endif /* illumos */ 6341 /* set min cache to 1/32 of all memory, or arc_abs_min, whichever is more */ | 6344 6345#ifdef illumos 6346#ifdef _KERNEL 6347 /* 6348 * On architectures where the physical memory can be larger 6349 * than the addressable space (intel in 32-bit mode), we may 6350 * need to limit the cache to 1/8 of VM size. 6351 */ 6352 arc_c = MIN(arc_c, vmem_size(heap_arena, VMEM_ALLOC | VMEM_FREE) / 8); 6353#endif 6354#endif /* illumos */ 6355 /* set min cache to 1/32 of all memory, or arc_abs_min, whichever is more */ |
6342 arc_c_min = MAX(arc_c / 4, arc_abs_min); 6343 /* set max to 1/2 of all memory, or all but 1GB, whichever is more */ 6344 if (arc_c * 8 >= 1 << 30) 6345 arc_c_max = (arc_c * 8) - (1 << 30); | 6356 arc_c_min = MAX(allmem / 32, arc_abs_min); 6357 /* set max to 5/8 of all memory, or all but 1GB, whichever is more */ 6358 if (allmem >= 1 << 30) 6359 arc_c_max = allmem - (1 << 30); |
6346 else 6347 arc_c_max = arc_c_min; | 6360 else 6361 arc_c_max = arc_c_min; |
6348 arc_c_max = MAX(arc_c * 5, arc_c_max); | 6362 arc_c_max = MAX(allmem * 5 / 8, arc_c_max); |
6349 6350 /* 6351 * In userland, there's only the memory pressure that we artificially 6352 * create (see arc_available_memory()). Don't let arc_c get too 6353 * small, because it can cause transactions to be larger than 6354 * arc_c, causing arc_tempreserve_space() to fail. 6355 */ 6356#ifndef _KERNEL 6357 arc_c_min = arc_c_max / 2; 6358#endif 6359 6360#ifdef _KERNEL 6361 /* 6362 * Allow the tunables to override our calculations if they are 6363 * reasonable. 6364 */ | 6363 6364 /* 6365 * In userland, there's only the memory pressure that we artificially 6366 * create (see arc_available_memory()). Don't let arc_c get too 6367 * small, because it can cause transactions to be larger than 6368 * arc_c, causing arc_tempreserve_space() to fail. 6369 */ 6370#ifndef _KERNEL 6371 arc_c_min = arc_c_max / 2; 6372#endif 6373 6374#ifdef _KERNEL 6375 /* 6376 * Allow the tunables to override our calculations if they are 6377 * reasonable. 6378 */ |
6365 if (zfs_arc_max > arc_abs_min && zfs_arc_max < kmem_size()) { | 6379 if (zfs_arc_max > arc_abs_min && zfs_arc_max < allmem) { |
6366 arc_c_max = zfs_arc_max; 6367 arc_c_min = MIN(arc_c_min, arc_c_max); 6368 } 6369 if (zfs_arc_min > arc_abs_min && zfs_arc_min <= arc_c_max) 6370 arc_c_min = zfs_arc_min; 6371#endif 6372 6373 arc_c = arc_c_max; --- 106 unchanged lines hidden (view full) --- 6480 zfs_prefetch_disable = 1; 6481 } 6482#endif 6483 /* Warn about ZFS memory and address space requirements. */ 6484 if (((uint64_t)physmem * PAGESIZE) < (256 + 128 + 64) * (1 << 20)) { 6485 printf("ZFS WARNING: Recommended minimum RAM size is 512MB; " 6486 "expect unstable behavior.\n"); 6487 } | 6380 arc_c_max = zfs_arc_max; 6381 arc_c_min = MIN(arc_c_min, arc_c_max); 6382 } 6383 if (zfs_arc_min > arc_abs_min && zfs_arc_min <= arc_c_max) 6384 arc_c_min = zfs_arc_min; 6385#endif 6386 6387 arc_c = arc_c_max; --- 106 unchanged lines hidden (view full) --- 6494 zfs_prefetch_disable = 1; 6495 } 6496#endif 6497 /* Warn about ZFS memory and address space requirements. */ 6498 if (((uint64_t)physmem * PAGESIZE) < (256 + 128 + 64) * (1 << 20)) { 6499 printf("ZFS WARNING: Recommended minimum RAM size is 512MB; " 6500 "expect unstable behavior.\n"); 6501 } |
6488 if (kmem_size() < 512 * (1 << 20)) { | 6502 if (allmem < 512 * (1 << 20)) { |
6489 printf("ZFS WARNING: Recommended minimum kmem_size is 512MB; " 6490 "expect unstable behavior.\n"); 6491 printf(" Consider tuning vm.kmem_size and " 6492 "vm.kmem_size_max\n"); 6493 printf(" in /boot/loader.conf.\n"); 6494 } 6495#endif 6496} --- 1226 unchanged lines hidden --- | 6503 printf("ZFS WARNING: Recommended minimum kmem_size is 512MB; " 6504 "expect unstable behavior.\n"); 6505 printf(" Consider tuning vm.kmem_size and " 6506 "vm.kmem_size_max\n"); 6507 printf(" in /boot/loader.conf.\n"); 6508 } 6509#endif 6510} --- 1226 unchanged lines hidden --- |