Sysctls and mutexes.

From: Pawel Jakub Dawidek (nick_at_garage.freebsd.pl)
Date: 06/29/03

  • Next message: Edward Tiruvsky: "Questions"
    Date: Sun, 29 Jun 2003 09:12:11 +0200
    To: freebsd-hackers@freebsd.org
    
    
    

    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@dawidek.net
    UNIX Systems Programmer/Administrator     http://garage.freebsd.pl
    Am I Evil? Yes, I Am!                     http://cerber.sourceforge.net
    
    



  • Next message: Edward Tiruvsky: "Questions"