John Baldwin wrote: > > This is actually what I was saying was bad: a static function > > per mutex declaration. > > Umm, no, there is _one_ global function that we call. Why not check > the actual code?
Are you talking about a P4 branch, and not the main repository? > Why don't you read the code? > > Here, I'll quote it for you: > > struct mtx_args { > struct mtx *ma_mtx; > const char *ma_desc; > int ma_opts; > }; > > #define MTX_SYSINIT(name, mtx, desc, opts) \ > static struct mtx_args name##_args = { \ > mtx, \ > desc, \ > opts \ > }; \ > SYSINIT(name##_mtx_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ > mtx_sysinit, &name##_args) This is *EXACTLY* what I thought should be avoided. The linker set should not contain the address of a bunch of static mtx_args structs, because there shouldn't *be* a bunch of static mtx_args structs. And the ability to pass different initialization values to different mutex instances is broken, in that it makes it impossible to look at a mutex, and know what you need to know about it, merely because it's a mutex. Minimally, you are going to add 12 bytes per mutex (24 on 64 bit machines), plus however much memory is taken up by the "ma_desc", plus it makes the memory unrecoverable, because the address of the string that's in the supposedly "recoverable" data segment can't be recovered any more, because making the data segment "go away" would invalidate dereferences of the pointer. This is about as ugly the mutex code taking parameters (we've had that discussion before). > Note no static function, instead we use the global function mtx_sysinit() > in kern_mutex.c: > > /* > * General init routine used by the MTX_SYSINIT() macro. > */ > void > mtx_sysinit(void *arg) > { > struct mtx_args *margs = arg; > > mtx_init(margs->ma_mtx, margs->ma_desc, NULL, margs->ma_opts); > } On a per instance basis. For which you create not only an mtx_args structure, but also a sysinit structure, to act as a container for the reference to the mtx_args struct address, and the mtx_sysinit function, etc.. Bleh. 8-). -- Terry To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-net" in the body of the message