Sysctls and mutexes.

Pawel Jakub Dawidek nick at garage.freebsd.pl
Sun Jun 29 00:08:34 PDT 2003


Hello.

I want to discuss two things about sysctls.

1. If there is need to use M_WAITOK when allocating memory?
   Every SYSCTL_ADD_* macro returns pointer that could be tested if it isn't
   NULL (when malloc(9) failed). I'm talking about dynamic sysctls.
2. Secound thing. I'm wondering if there is no need to and one more field
   to those macros: mutex that protects given value. Then standard functions
   sysctl_handle_*() could use those mutexes when accessing to those values.

Look at sysctl creation in /sys/dev/sound/pcm/mixer.c in function
mixer_hwvol_init() or at sysctls in /sys/kern/kern_jail.c and many others
as I susspect.

There is no need to break anything. We could create for now new macros:
SYSCTL_ADD_INT_MTX(), etc. that will create int sysctl, but with information
about its mutex. We should also teach sysctl_handle_int and friends how to
lock those mutexes and that they should ignore locking when this field is NULL.

-- 
Pawel Jakub Dawidek                       pawel at dawidek.net
UNIX Systems Programmer/Administrator     http://garage.freebsd.pl
Am I Evil? Yes, I Am!                     http://cerber.sourceforge.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 305 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20030629/eb1c8825/attachment.bin


More information about the freebsd-hackers mailing list