]> granicus.if.org Git - zfs/commitdiff
Name anonymous enum of KMC_BIT constants
authorSerapheim Dimitropoulos <serapheim@delphix.com>
Fri, 18 Oct 2019 17:25:44 +0000 (10:25 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 18 Oct 2019 17:25:44 +0000 (13:25 -0400)
Giving a name to this enum makes it discoverable from
debugging tools like DRGN and SDB. For example, with
the name proposed on this patch we can iterate over
these values in DRGN:
```
>>> prog.type('enum kmc_bit').enumerators
(('KMC_BIT_NOTOUCH', 0), ('KMC_BIT_NODEBUG', 1),
('KMC_BIT_NOMAGAZINE', 2), ('KMC_BIT_NOHASH', 3),
('KMC_BIT_QCACHE', 4), ('KMC_BIT_KMEM', 5),
('KMC_BIT_VMEM', 6), ('KMC_BIT_SLAB', 7),
...
```
This enables SDB to easily pretty-print the flags of
the spl_kmem_caches in the system like this:
```
> spl_kmem_caches -o "name,flags,total_memory"
name                                       flags total_memory
------------------------ ----------------------- ------------
abd_t                    KMC_NOMAGAZINE|KMC_SLAB        4.5MB
arc_buf_hdr_t_full       KMC_NOMAGAZINE|KMC_SLAB       12.3MB
... <cropped> ...
ddt_cache                               KMC_VMEM      583.7KB
ddt_entry_cache          KMC_NOMAGAZINE|KMC_SLAB         0.0B
... <cropped> ...
zio_buf_1048576             KMC_NODEBUG|KMC_VMEM         0.0B
... <cropped> ...
```

Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Closes #9478

include/os/linux/spl/sys/kmem_cache.h

index e5c53ab989d7ed49409a5a044a9d7b7ec9350881..3584eefdfc9f91a6fbea05d4949be53947965276 100644 (file)
@@ -35,7 +35,7 @@
  * size.  This slab implementation also supports both constructors and
  * destructors which the Linux slab does not.
  */
-enum {
+typedef enum kmc_bit {
        KMC_BIT_NOTOUCH         = 0,    /* Don't update ages */
        KMC_BIT_NODEBUG         = 1,    /* Default behavior */
        KMC_BIT_NOMAGAZINE      = 2,    /* XXX: Unsupported */
@@ -52,7 +52,7 @@ enum {
        KMC_BIT_TOTAL           = 18,   /* Proc handler helper bit */
        KMC_BIT_ALLOC           = 19,   /* Proc handler helper bit */
        KMC_BIT_MAX             = 20,   /* Proc handler helper bit */
-};
+} kmc_bit_t;
 
 /* kmem move callback return values */
 typedef enum kmem_cbrc {