Malloc(9) and uma(9) naming consistency

From: Robert Watson <rwatson_at_FreeBSD.org>
Date: Sun, 17 Jul 2005 13:47:33 +0100 (BST)
Now that libmemstat(3) allows the mechanical retrieval of memory 
information from the kernel, I will start adapting tools that currently do 
this monitoring in ad hoc ways to use libmemstat(3) instead.  For example, 
I have patches that caus netstat -mb to use libmemstat(3) instead of 
separate frobs for retrieving mbuf allocator information.  In general, 
memory types are recognized, found, etc, by name.  In the case of uma(9) 
zones, it is the zone name passed to uma_zcreate(9).  In the case of 
malloc(9), it is the "short description" passed to MALLOC_DEFINE(9). 
There are several reasons why improved name consistency is desirable -- 
here are the ones I came up with off-hand:

(1) Currently, the output of vmstat -m and vmstat -z is not consistently
     parseable using scripts.  Names contain spaces, may not fit in the
     available space, etc.

(2) As programs begin to look up information "by name", the stability of
     those names becomes important, as the tools won't be able to find
     their memory type information if the names are changed.

(3) Names sometimes collide, as they're used in multiple places to refer
     to different memory types.  There's at least one instance of this in
     the NFS code, where a type is used by the client and server code under
     the same name.

(4) Names are sometimes un-informative, not even identifying the kernel
     subsystem they might be used by.

So now is a good time to do a sweep through the kernel and fix these. 
Here's what I'd specifically like to do:

- Convert all spaces to "_"s, or remove them in some cases for consistency
   with related memory types.  This is specifically aimed at addressing
   (1).

- Shorten any long names so that they are 24 characters or less.  Maybe
   16.  This will easy rendering in monitoring interfaces designed for
   terminals, where every space counts.

- Convert all names to use only lower case letters.  This is the
   convention in almost all other system name spaces, and I think it makes
   sense to do it here.

- Generally, limit the characters used in names to alphabet + '_', again
   in the name of making it easier to parse, render, process, and so on.

- Disambiguate colliding names.

This requires touching several hundred kernel files, so I'd like to do it 
in one pass.  If there are any specific improvements on these changes that 
you can think of ("solve this other problem while you're at it!"), please 
let me know.  I'll touch everything but the contrib tree, I think.

The target branches for these changes are 6.x and 7.x, although they could 
be merged to 5.x if there's sufficient interest.  I've already had one 
inquiry about back-porting libmemstat(3) to 5.x, and will investigate it. 
A hand might be appreciated. :-)

Robert N M Watson
Received on Sun Jul 17 2005 - 10:46:59 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:39 UTC