Why is TUNABLE_INT discouraged?
gcooper at FreeBSD.org
Sat Aug 7 17:42:04 UTC 2010
2010/8/7 Dag-Erling Smørgrav <des at des.no>:
> Garrett Cooper <gcooper at FreeBSD.org> writes:
>> 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
> You're supposed to use TUNABLE_LONG or TUNABLE_ULONG instead. From
> digging in the -current archives, it seems that the motivation was a bug
> that resulted from using a TUNABLE_INT for a value that was actually an
> address. It was doubly broken: first because it was too small on 64-bit
> systems, and second because it was signed.
Thanks for the explanation.
I just found it interesting how the interfaces to [PCI BUS] resources,
sysctls, and tunables are inconsistent in terms of what data types
they support; resources only supports signed integers of various
widths, sysctls support everything under the sun, and we know the
story on tunables now.
It's ok most of the time, but as we all know there are limits to the
ranges for integers, and there's something a bit quirky about some of
the code in sound(4) that I'm experimenting with to see whether or not
it was there's an issue with bad casting, comparison, an uninitialized
value, or another random race condition, that's wreaking havoc with my
Audigy card every time I attach the driver as a module.
More information about the freebsd-hackers