Name anonymous enum of KMC_BIT constants

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
This commit is contained in:
Serapheim Dimitropoulos 2019-10-18 10:25:44 -07:00 committed by Brian Behlendorf
parent 851eda3566
commit 9f3c72a2a8

View File

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