On Wed, Mar 01, 2023 at 05:55:44PM +0900, Sergey Senozhatsky wrote: > On (23/02/28 14:53), Minchan Kim wrote: > > BTW, I still prefer the enum instead of 10 define. > > > > enum fullness_group { > > ZS_EMPTY, > > ZS_INUSE_RATIO_MIN, > > ZS_INUSE_RATIO_ALMOST_FULL = 7, > > ZS_INUSE_RATIO_MAX = 10, > > ZS_FULL, > > NR_ZS_FULLNESS, > > } > > For educational purposes, may I ask what do enums give us? We > always use integers - int:4 in zspage fullness, int for arrays > offsets and we cast to plain integers in get/set stats. So those > enums exist only at declaration point, and plain int otherwise. > What are the benefits over #defines? Well, I just didn't like the 12 hard coded define *list* values and never used other places except zs_stats_size_show since I thought we could handle zs_stats_size_show in the loop without the specific each ratio definary. Furthermore, above example, the special ZS_INUSE_RATIO_MAX will be definary instead of hard coded 10. ZS_INUSE_RATIO_MAX = ZS_INUSE_RATIO_MIN + ZS_INUSER_RATIO_CLASS_SIZE so, if we want to change the ratio later, we would need minimal changes all the places instead of changing all the hard codeded definary.