Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Aug 2010 02:31:44 -0700
From:      Garrett Cooper <gcooper@FreeBSD.org>
To:        Ivan Voras <ivoras@freebsd.org>
Cc:        =?ISO-8859-1?Q?Dag=2DErling_Sm=F8rgrav?= <des@des.no>, freebsd-hackers@freebsd.org
Subject:   Re: Why is TUNABLE_INT discouraged?
Message-ID:  <AANLkTikU6fLzWL-n6fCtvaTsXWGis7ydKM1qJaV=WRJ%2B@mail.gmail.com>
In-Reply-To: <AANLkTinraF50O%2Bcp_h1m6TODnoz_7R3WXfjTanh-86mn@mail.gmail.com>
References:  <AANLkTinKaiGFhKRgqQ%2BFjm=02VfWCxULe0a68y-PkJx6@mail.gmail.com> <86fwyq8rsc.fsf@ds4.des.no> <i3kbis$73l$1@dough.gmane.org> <86d3tujh72.fsf@ds4.des.no> <AANLkTi=puD%2B-WeZ%2BFGdtZtw1v%2BNnGD_htwNa%2BEn9fcML@mail.gmail.com> <864of680wv.fsf@ds4.des.no> <AANLkTinraF50O%2Bcp_h1m6TODnoz_7R3WXfjTanh-86mn@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
2010/8/7 Ivan Voras <ivoras@freebsd.org>:
> 2010/8/8 Dag-Erling Sm=F8rgrav <des@des.no>:
>> Garrett Cooper <gcooper@FreeBSD.org> writes:
>>> Dag-Erling Sm=F8rgrav <des@des.no> writes:
>>> > Perhaps. =A0I don't remember all the details; I can't find a discussi=
on in
>>> > the list archives (other than me announcing the change in response to=
 a
>>> > bug report), but there must have been one, either on IRC or in Karlsr=
uhe.
>>> > In any case, I never removed TUNABLE_INT(), so...
>>> It does matter for integers on 64-bit vs 32-bit architectures though,
>>> right
>>
>> Not sure what you mean. =A0The original issue was that someone had used
>> TUNABLE_INT() for something that was actually a memory address. =A0I
>> changed it to TUNABLE_ULONG(). =A0Of course, if your tunable is a boolea=
n
>> value or something like maxprocs, an int is fine - but so is a long.

Why would someone express a tunable in a memory address (not being
sarcastic... I just don't see why it makes sense right now, but if
there's a valid reason I'm more than happy to be educated :)..)?

> Semantically valid but using TUNABLE_INT to hold pointers is a
> developer bug, not the fault of the API, and there's nothing wrong
> with "int" as a data type in this context.
>
> Unless there is a real hidden danger in using TUNABLE_INT (and/or
> adding TUNABLE_UINT etc.) in the expected way, I'd vote for either
> removing the cautioning comment or rewriting it to say something like
> "developers are hereby warned that ints cannot hold pointers on all
> architectures", if it is indeed such a little known fact among kernel
> developers :P

*grins cheekily in agreement* :).

Thanks,
-Garrett



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTikU6fLzWL-n6fCtvaTsXWGis7ydKM1qJaV=WRJ%2B>