arc.c (329490) | arc.c (330061) |
---|---|
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 --- 4223 unchanged lines hidden (view full) --- 4232static int64_t 4233arc_available_memory(void) 4234{ 4235 int64_t lowest = INT64_MAX; 4236 int64_t n; 4237 free_memory_reason_t r = FMR_UNKNOWN; 4238 4239#ifdef _KERNEL | 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 --- 4223 unchanged lines hidden (view full) --- 4232static int64_t 4233arc_available_memory(void) 4234{ 4235 int64_t lowest = INT64_MAX; 4236 int64_t n; 4237 free_memory_reason_t r = FMR_UNKNOWN; 4238 4239#ifdef _KERNEL |
4240#ifdef __FreeBSD__ |
|
4240 /* 4241 * Cooperate with pagedaemon when it's time for it to scan 4242 * and reclaim some pages. 4243 */ 4244 n = PAGESIZE * ((int64_t)freemem - zfs_arc_free_target); 4245 if (n < lowest) { 4246 lowest = n; 4247 r = FMR_LOTSFREE; 4248 } 4249 | 4241 /* 4242 * Cooperate with pagedaemon when it's time for it to scan 4243 * and reclaim some pages. 4244 */ 4245 n = PAGESIZE * ((int64_t)freemem - zfs_arc_free_target); 4246 if (n < lowest) { 4247 lowest = n; 4248 r = FMR_LOTSFREE; 4249 } 4250 |
4250#ifdef illumos | 4251#else 4252 if (needfree > 0) { 4253 n = PAGESIZE * (-needfree); 4254 if (n < lowest) { 4255 lowest = n; 4256 r = FMR_NEEDFREE; 4257 } 4258 } 4259 |
4251 /* 4252 * check that we're out of range of the pageout scanner. It starts to 4253 * schedule paging if freemem is less than lotsfree and needfree. 4254 * lotsfree is the high-water mark for pageout, and needfree is the 4255 * number of needed free pages. We add extra pages here to make sure 4256 * the scanner doesn't start up while we're freeing memory. 4257 */ 4258 n = PAGESIZE * (freemem - lotsfree - needfree - desfree); --- 26 unchanged lines hidden (view full) --- 4285 */ 4286 n = PAGESIZE * (availrmem - pages_pp_maximum - 4287 arc_pages_pp_reserve); 4288 if (n < lowest) { 4289 lowest = n; 4290 r = FMR_PAGES_PP_MAXIMUM; 4291 } 4292 | 4260 /* 4261 * check that we're out of range of the pageout scanner. It starts to 4262 * schedule paging if freemem is less than lotsfree and needfree. 4263 * lotsfree is the high-water mark for pageout, and needfree is the 4264 * number of needed free pages. We add extra pages here to make sure 4265 * the scanner doesn't start up while we're freeing memory. 4266 */ 4267 n = PAGESIZE * (freemem - lotsfree - needfree - desfree); --- 26 unchanged lines hidden (view full) --- 4294 */ 4295 n = PAGESIZE * (availrmem - pages_pp_maximum - 4296 arc_pages_pp_reserve); 4297 if (n < lowest) { 4298 lowest = n; 4299 r = FMR_PAGES_PP_MAXIMUM; 4300 } 4301 |
4293#endif /* illumos */ | 4302#endif /* __FreeBSD__ */ |
4294#if defined(__i386) || !defined(UMA_MD_SMALL_ALLOC) 4295 /* 4296 * If we're on an i386 platform, it's possible that we'll exhaust the 4297 * kernel heap space before we ever run out of available physical 4298 * memory. Most checks of the size of the heap_area compare against 4299 * tune.t_minarmem, which is the minimum available real memory that we 4300 * can have in the system. However, this is generally fixed at 25 pages 4301 * which is so low that it's useless. In this comparison, we seek to --- 194 unchanged lines hidden (view full) --- 4496 * If we are still low on memory, shrink the ARC 4497 * so that we have arc_shrink_min free space. 4498 */ 4499 free_memory = arc_available_memory(); 4500 4501 int64_t to_free = 4502 (arc_c >> arc_shrink_shift) - free_memory; 4503 if (to_free > 0) { | 4303#if defined(__i386) || !defined(UMA_MD_SMALL_ALLOC) 4304 /* 4305 * If we're on an i386 platform, it's possible that we'll exhaust the 4306 * kernel heap space before we ever run out of available physical 4307 * memory. Most checks of the size of the heap_area compare against 4308 * tune.t_minarmem, which is the minimum available real memory that we 4309 * can have in the system. However, this is generally fixed at 25 pages 4310 * which is so low that it's useless. In this comparison, we seek to --- 194 unchanged lines hidden (view full) --- 4505 * If we are still low on memory, shrink the ARC 4506 * so that we have arc_shrink_min free space. 4507 */ 4508 free_memory = arc_available_memory(); 4509 4510 int64_t to_free = 4511 (arc_c >> arc_shrink_shift) - free_memory; 4512 if (to_free > 0) { |
4513#ifdef _KERNEL 4514#ifdef illumos 4515 to_free = MAX(to_free, ptob(needfree)); 4516#endif 4517#endif |
|
4504 arc_shrink(to_free); 4505 } 4506 } else if (free_memory < arc_c >> arc_no_grow_shift) { 4507 arc_no_grow = B_TRUE; 4508 } else if (gethrtime() >= growtime) { 4509 arc_no_grow = B_FALSE; 4510 } 4511 --- 3324 unchanged lines hidden --- | 4518 arc_shrink(to_free); 4519 } 4520 } else if (free_memory < arc_c >> arc_no_grow_shift) { 4521 arc_no_grow = B_TRUE; 4522 } else if (gethrtime() >= growtime) { 4523 arc_no_grow = B_FALSE; 4524 } 4525 --- 3324 unchanged lines hidden --- |