Why is TUNABLE_INT discouraged?

Garrett Cooper gcooper at FreeBSD.org
Sat Aug 7 06:48:20 UTC 2010

Hi Hackers,
    Poking around the sound(4) drivers, I looked into converting one
of the TUNABLE_INTs to an unsigned tunable for testing purposes. I
looked in kernel.h and I saw the following comment:

 * int
 * please avoid using for new tunables!

   I found the commit where it was made (by des@ -- cvs revision
1.120), but unfortunately I lack the context as to why that suggestion
is made; the commit isn't very explicit as to why integers tunables
should be discouraged -- and in the case of
hw.sound.feeder_rate_round, it makes just as much sense to use an
integer type or a long integer type, as accepted input values are
small enough to fit in an integer value with a _lot_ of headroom:

             Sample rate rounding threshold, to avoid large prime division at
             the cost of accuracy.  All requested sample rates will be rounded
             to the nearest threshold value.  Possible values range between 0
             (disabled) and 500.  Default is 25.

    It would be nice to know why TUNABLE_INT is discouraged :).

More information about the freebsd-hackers mailing list