Subject: Re: Replacing the sysctl() interface.
To: Jaromír Doleček <firstname.lastname@example.org>
From: Chris G. Demetriou <email@example.com>
Date: 06/05/2000 09:41:58
Jaromír Doleček <firstname.lastname@example.org> writes:
> I have to aggree with itojun here. I do not like the way FreeBSD
> did it, at the very least. See how many times is the MALLOC_DEFINE() used
> in e.g. syssrc/sys/ntfs/, they declare same values again and
> again in each file.
(1) i don't know why you couldn't declare things in a module-specific
header, then use them where needed.
(2) i actually just grepped in a 4.0 kernel source tree, and found:
ntfs_ihash.c:MALLOC_DEFINE(M_NTFSNTHASH, "NTFS nthash", "NTFS ntnode hash tables");
ntfs_subr.c:MALLOC_DEFINE(M_NTFSNTVATTR, "NTFS vattr", "NTFS file attribute information");
ntfs_subr.c:MALLOC_DEFINE(M_NTFSRDATA, "NTFS res data", "NTFS resident data");
ntfs_subr.c:MALLOC_DEFINE(M_NTFSRUN, "NTFS vrun", "NTFS vrun storage");
ntfs_subr.c:MALLOC_DEFINE(M_NTFSDECOMP, "NTFS decomp", "NTFS decompression temporary");
ntfs_vfsops.c:MALLOC_DEFINE(M_NTFSMNT, "NTFS mount", "NTFS mount structure");
ntfs_vfsops.c:MALLOC_DEFINE(M_NTFSNTNODE,"NTFS ntnode", "NTFS ntnode information");
ntfs_vfsops.c:MALLOC_DEFINE(M_NTFSFNODE,"NTFS fnode", "NTFS fnode information");
ntfs_vfsops.c:MALLOC_DEFINE(M_NTFSDIR,"NTFS dir", "NTFS dir buffer");
So, I think either you're mistaken, things have changed for the worse
in their current sources, or i'm badly missing something. Another way
of looking at it: "do you have an actual example of a problem, or is
this just FUD?"
> Compared to FreeBSD style, NetBSD style seems more elegant, far less
> insane, and encouradges good programming style. The *DEFINE() add just too
> much unneeded "magic", add complexity and make finding dependencies
> harder, at the very least.
Uh, I'd disagree that it's good programming style, at the very least.
In general, it's good programming style to keep module-specific data
and definitions in one place, close to the module. The existing way
NetBSD does things makes that effectively impossible (and creates
extra maintenance work, too).
Perhaps the right thing, then, is to force hand-crafted init code to
add each malloc type, etc., as needed. However, it seems wasteful and
still causes unnecessarily maintenance (why do it by hand when you can
get the compiler/linker to do it for you)?