diff options
author | Jeff Roberson <jeff@FreeBSD.org> | 2018-01-02 04:35:56 +0000 |
---|---|---|
committer | Jeff Roberson <jeff@FreeBSD.org> | 2018-01-02 04:35:56 +0000 |
commit | ad5b0f5b51eb2c0da2d2f835a54e6909320a03f4 (patch) | |
tree | 24dd492792c92e7b73ed9f0703b3afdd2899b849 /sys/vm | |
parent | 67530f82dd5e50b0666ded863e33d0aeda8cacee (diff) | |
download | src-ad5b0f5b51eb2c0da2d2f835a54e6909320a03f4.tar.gz src-ad5b0f5b51eb2c0da2d2f835a54e6909320a03f4.zip |
Fix arc after r326347 broke various memory limit queries. Use UMA features
rather than kmem arena size to determine available memory.
Initialize the UMA limit to LONG_MAX to avoid spurious wakeups on boot before
the real limit is set.
PR: 224330 (partial), 224080
Reviewed by: markj, avg
Sponsored by: Netflix / Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D13494
Notes
Notes:
svn path=/head/; revision=327485
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/uma.h | 8 | ||||
-rw-r--r-- | sys/vm/uma_core.c | 12 | ||||
-rw-r--r-- | sys/vm/uma_int.h | 4 |
3 files changed, 18 insertions, 6 deletions
diff --git a/sys/vm/uma.h b/sys/vm/uma.h index 1ea8ee06245b..1bd366416cbc 100644 --- a/sys/vm/uma.h +++ b/sys/vm/uma.h @@ -698,4 +698,12 @@ struct uma_percpu_stat { void uma_reclaim_wakeup(void); void uma_reclaim_worker(void *); +unsigned long uma_limit(void); + +/* Return the amount of memory managed by UMA. */ +unsigned long uma_size(void); + +/* Return the amount of memory remaining. May be negative. */ +long uma_avail(void); + #endif /* _VM_UMA_H_ */ diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index 81c953a48383..0dd16dd9c325 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$"); #include <sys/eventhandler.h> #include <sys/kernel.h> #include <sys/types.h> +#include <sys/limits.h> #include <sys/queue.h> #include <sys/malloc.h> #include <sys/ktr.h> @@ -148,7 +149,7 @@ static struct mtx uma_boot_pages_mtx; static struct sx uma_drain_lock; /* kmem soft limit. */ -static unsigned long uma_kmem_limit; +static unsigned long uma_kmem_limit = LONG_MAX; static volatile unsigned long uma_kmem_total; /* Is the VM done starting up? */ @@ -3265,7 +3266,14 @@ unsigned long uma_size(void) { - return uma_kmem_total; + return (uma_kmem_total); +} + +long +uma_avail(void) +{ + + return (uma_kmem_limit - uma_kmem_total); } void diff --git a/sys/vm/uma_int.h b/sys/vm/uma_int.h index 158c2383c885..a8aca454f066 100644 --- a/sys/vm/uma_int.h +++ b/sys/vm/uma_int.h @@ -428,10 +428,6 @@ void uma_small_free(void *mem, vm_size_t size, uint8_t flags); /* Set a global soft limit on UMA managed memory. */ void uma_set_limit(unsigned long limit); -unsigned long uma_limit(void); - -/* Return the amount of memory managed by UMA. */ -unsigned long uma_size(void); #endif /* _KERNEL */ #endif /* VM_UMA_INT_H */ |