Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Aug 2010 01:30:19 +0200
From:      Ivan Voras <ivoras@freebsd.org>
To:        =?UTF-8?Q?Dag=2DErling_Sm=C3=B8rgrav?= <des@des.no>
Cc:        freebsd-hackers@freebsd.org, Garrett Cooper <gcooper@freebsd.org>
Subject:   Re: Why is TUNABLE_INT discouraged?
Message-ID:  <AANLkTinraF50O%2Bcp_h1m6TODnoz_7R3WXfjTanh-86mn@mail.gmail.com>
In-Reply-To: <864of680wv.fsf@ds4.des.no>
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>

next in thread | previous in thread | raw e-mail | index | archive | help
2010/8/8 Dag-Erling Sm=C3=B8rgrav <des@des.no>:
> Garrett Cooper <gcooper@FreeBSD.org> writes:
>> Dag-Erling Sm=C3=B8rgrav <des@des.no> writes:
>> > Perhaps. =C2=A0I don't remember all the details; I can't find a discus=
sion 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 Karlsru=
he.
>> > 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. =C2=A0The original issue was that someone had use=
d
> TUNABLE_INT() for something that was actually a memory address. =C2=A0I
> changed it to TUNABLE_ULONG(). =C2=A0Of course, if your tunable is a bool=
ean
> value or something like maxprocs, an int is fine - but so is a long.

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTinraF50O%2Bcp_h1m6TODnoz_7R3WXfjTanh-86mn>