diff options
author | attilio <attilio@FreeBSD.org> | 2011-05-08 14:29:25 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2011-05-08 14:29:25 +0000 |
commit | 10ea4d196652fe0eb9ae279f5d068bf297eae8c6 (patch) | |
tree | 5f1e533b90620752ba924fe1bc6a0b9a9e6eef13 /lib/libmemstat | |
parent | cf9c204572b33c27e35e696f54133ec1848e9d02 (diff) | |
download | FreeBSD-src-10ea4d196652fe0eb9ae279f5d068bf297eae8c6.zip FreeBSD-src-10ea4d196652fe0eb9ae279f5d068bf297eae8c6.tar.gz |
Revert MAXCPU introduction. In userland it is always 1.
Noted by: marcel
Diffstat (limited to 'lib/libmemstat')
-rw-r--r-- | lib/libmemstat/memstat.c | 2 | ||||
-rw-r--r-- | lib/libmemstat/memstat.h | 6 | ||||
-rw-r--r-- | lib/libmemstat/memstat_internal.h | 4 | ||||
-rw-r--r-- | lib/libmemstat/memstat_malloc.c | 13 | ||||
-rw-r--r-- | lib/libmemstat/memstat_uma.c | 5 |
5 files changed, 20 insertions, 10 deletions
diff --git a/lib/libmemstat/memstat.c b/lib/libmemstat/memstat.c index b2749e2..1a08d3f 100644 --- a/lib/libmemstat/memstat.c +++ b/lib/libmemstat/memstat.c @@ -193,7 +193,7 @@ _memstat_mt_reset_stats(struct memory_type *mtp) mtp->mt_zonefree = 0; mtp->mt_kegfree = 0; - for (i = 0; i < MAXCPU; i++) { + for (i = 0; i < MEMSTAT_MAXCPU; i++) { mtp->mt_percpu_alloc[i].mtp_memalloced = 0; mtp->mt_percpu_alloc[i].mtp_memfreed = 0; mtp->mt_percpu_alloc[i].mtp_numallocs = 0; diff --git a/lib/libmemstat/memstat.h b/lib/libmemstat/memstat.h index fa26944..5267e78 100644 --- a/lib/libmemstat/memstat.h +++ b/lib/libmemstat/memstat.h @@ -30,6 +30,12 @@ #define _MEMSTAT_H_ /* + * Number of CPU slots in library-internal data structures. This should be + * at least value of MAXCPU from param.h + */ +#define MEMSTAT_MAXCPU 32 + +/* * Amount of caller data to maintain for each caller data slot. Applications * must not request more than this number of caller save data, or risk * corrupting internal libmemstat(3) data structures. A compile time check diff --git a/lib/libmemstat/memstat_internal.h b/lib/libmemstat/memstat_internal.h index 8881e58..b7fdd71 100644 --- a/lib/libmemstat/memstat_internal.h +++ b/lib/libmemstat/memstat_internal.h @@ -100,11 +100,11 @@ struct memory_type { uint64_t mtp_sizemask; /* Per-CPU mt_sizemask. */ void *mtp_caller_pointer[MEMSTAT_MAXCALLER]; uint64_t mtp_caller_uint64[MEMSTAT_MAXCALLER]; - } mt_percpu_alloc[MAXCPU]; + } mt_percpu_alloc[MEMSTAT_MAXCPU]; struct { uint64_t mtp_free; /* Per-CPU cache free items. */ - } mt_percpu_cache[MAXCPU]; + } mt_percpu_cache[MEMSTAT_MAXCPU]; LIST_ENTRY(memory_type) mt_list; /* List of types. */ }; diff --git a/lib/libmemstat/memstat_malloc.c b/lib/libmemstat/memstat_malloc.c index a8d14f8..28a48c6 100644 --- a/lib/libmemstat/memstat_malloc.c +++ b/lib/libmemstat/memstat_malloc.c @@ -96,7 +96,7 @@ retry: return (-1); } - if (maxcpus > MAXCPU) { + if (maxcpus > MEMSTAT_MAXCPU) { list->mtl_error = MEMSTAT_ERROR_TOOMANYCPUS; return (-1); } @@ -160,7 +160,7 @@ retry: return (-1); } - if (mtshp->mtsh_maxcpus > MAXCPU) { + if (mtshp->mtsh_maxcpus > MEMSTAT_MAXCPU) { list->mtl_error = MEMSTAT_ERROR_TOOMANYCPUS; free(buffer); return (-1); @@ -295,7 +295,7 @@ memstat_kvm_malloc(struct memory_type_list *list, void *kvm_handle) void *kmemstatistics; int hint_dontsearch, j, mp_maxcpus, ret; char name[MEMTYPE_MAXNAME]; - struct malloc_type_stats mts[MAXCPU], *mtsp; + struct malloc_type_stats mts[MEMSTAT_MAXCPU], *mtsp; struct malloc_type_internal *mtip; struct malloc_type type, *typep; kvm_t *kvm; @@ -322,7 +322,7 @@ memstat_kvm_malloc(struct memory_type_list *list, void *kvm_handle) return (-1); } - if (mp_maxcpus > MAXCPU) { + if (mp_maxcpus > MEMSTAT_MAXCPU) { list->mtl_error = MEMSTAT_ERROR_TOOMANYCPUS; return (-1); } @@ -348,6 +348,11 @@ memstat_kvm_malloc(struct memory_type_list *list, void *kvm_handle) list->mtl_error = ret; return (-1); } + + /* + * Since our compile-time value for MAXCPU may differ from the + * kernel's, we populate our own array. + */ mtip = type.ks_handle; ret = kread(kvm, mtip->mti_stats, mts, mp_maxcpus * sizeof(struct malloc_type_stats), 0); diff --git a/lib/libmemstat/memstat_uma.c b/lib/libmemstat/memstat_uma.c index 3020937..8e2c4e8 100644 --- a/lib/libmemstat/memstat_uma.c +++ b/lib/libmemstat/memstat_uma.c @@ -27,7 +27,6 @@ */ #include <sys/param.h> -#include <sys/cpuset.h> #include <sys/sysctl.h> #define LIBMEMSTAT /* Cause vm_page.h not to include opt_vmpage.h */ @@ -106,7 +105,7 @@ retry: return (-1); } - if (maxcpus > MAXCPU) { + if (maxcpus > MEMSTAT_MAXCPU) { list->mtl_error = MEMSTAT_ERROR_TOOMANYCPUS; return (-1); } @@ -170,7 +169,7 @@ retry: return (-1); } - if (ushp->ush_maxcpus > MAXCPU) { + if (ushp->ush_maxcpus > MEMSTAT_MAXCPU) { list->mtl_error = MEMSTAT_ERROR_TOOMANYCPUS; free(buffer); return (-1); |