diff options
author | Ryan Libby <rlibby@FreeBSD.org> | 2019-12-11 06:50:55 +0000 |
---|---|---|
committer | Ryan Libby <rlibby@FreeBSD.org> | 2019-12-11 06:50:55 +0000 |
commit | 6d204a6a0e5d5e3ca8464ce403ae6e88dad2d49e (patch) | |
tree | 30a0d59a99eda4c53a09e5db90e9335fca79e059 | |
parent | a9365f4a1739c01c15667d2310dc5311809ab6c4 (diff) | |
download | src-6d204a6a0e5d5e3ca8464ce403ae6e88dad2d49e.tar.gz src-6d204a6a0e5d5e3ca8464ce403ae6e88dad2d49e.zip |
uma: pretty print zone flags sysctl
Requested by: jeff
Reviewed by: jeff, markj
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D22748
Notes
Notes:
svn path=/head/; revision=355605
-rw-r--r-- | sys/vm/uma_core.c | 24 | ||||
-rw-r--r-- | sys/vm/uma_int.h | 26 |
2 files changed, 48 insertions, 2 deletions
diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index d6d2b4c50efc..0daed9db0a9a 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -289,6 +289,7 @@ static int sysctl_vm_zone_count(SYSCTL_HANDLER_ARGS); static int sysctl_vm_zone_stats(SYSCTL_HANDLER_ARGS); static int sysctl_handle_uma_zone_allocs(SYSCTL_HANDLER_ARGS); static int sysctl_handle_uma_zone_frees(SYSCTL_HANDLER_ARGS); +static int sysctl_handle_uma_zone_flags(SYSCTL_HANDLER_ARGS); #ifdef INVARIANTS static bool uma_dbg_kskip(uma_keg_t keg, void *mem); @@ -1896,8 +1897,9 @@ zone_alloc_sysctl(uma_zone_t zone, void *unused) oid = zone->uz_oid; SYSCTL_ADD_U32(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, "size", CTLFLAG_RD, &zone->uz_size, 0, "Allocation size"); - SYSCTL_ADD_U32(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, - "flags", CTLFLAG_RD, &zone->uz_flags, 0, + SYSCTL_ADD_PROC(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, + "flags", CTLFLAG_RD | CTLTYPE_STRING | CTLFLAG_MPSAFE, + zone, 0, sysctl_handle_uma_zone_flags, "A", "Allocator configuration flags"); SYSCTL_ADD_U16(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, "bucket_size", CTLFLAG_RD, &zone->uz_bucket_size, 0, @@ -4408,6 +4410,24 @@ sysctl_handle_uma_zone_frees(SYSCTL_HANDLER_ARGS) return (sysctl_handle_64(oidp, &cur, 0, req)); } +static int +sysctl_handle_uma_zone_flags(SYSCTL_HANDLER_ARGS) +{ + struct sbuf sbuf; + uma_zone_t zone = arg1; + int error; + + sbuf_new_for_sysctl(&sbuf, NULL, 0, req); + if (zone->uz_flags != 0) + sbuf_printf(&sbuf, "0x%b", zone->uz_flags, PRINT_UMA_ZFLAGS); + else + sbuf_printf(&sbuf, "0"); + error = sbuf_finish(&sbuf); + sbuf_delete(&sbuf); + + return (error); +} + #ifdef INVARIANTS static uma_slab_t uma_dbg_getslab(uma_zone_t zone, void *item) diff --git a/sys/vm/uma_int.h b/sys/vm/uma_int.h index 262a23f09a37..0fc8438d1291 100644 --- a/sys/vm/uma_int.h +++ b/sys/vm/uma_int.h @@ -420,6 +420,32 @@ struct uma_zone { #define UMA_ZFLAG_INHERIT \ (UMA_ZFLAG_INTERNAL | UMA_ZFLAG_CACHEONLY | UMA_ZFLAG_BUCKET) +#define PRINT_UMA_ZFLAGS "\20" \ + "\40CACHEONLY" \ + "\37TRASH" \ + "\36INTERNAL" \ + "\35BUCKET" \ + "\34RECLAIMING" \ + "\33CACHE" \ + "\22MINBUCKET" \ + "\21NUMA" \ + "\20PCPU" \ + "\17NODUMP" \ + "\16VTOSLAB" \ + "\15CACHESPREAD" \ + "\14MAXBUCKET" \ + "\13NOBUCKET" \ + "\12SECONDARY" \ + "\11HASH" \ + "\10VM" \ + "\7MTXCLASS" \ + "\6NOFREE" \ + "\5MALLOC" \ + "\4OFFPAGE" \ + "\3STATIC" \ + "\2ZINIT" \ + "\1PAGEABLE" + #undef UMA_ALIGN #ifdef _KERNEL |