Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Aug 2010 14:25:40 +0200
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no>
To:        Garrett Cooper <gcooper@FreeBSD.org>
Cc:        freebsd-hackers@freebsd.org, Ivan Voras <ivoras@freebsd.org>
Subject:   Re: Why is TUNABLE_INT discouraged?
Message-ID:  <8662zg586z.fsf@ds4.des.no>
In-Reply-To: <AANLkTimbkTQiNgYCYFnTXMpRe9koJGrq1%2BYoq5-fVmFD@mail.gmail.com> (Garrett Cooper's message of "Thu, 12 Aug 2010 01:08:48 -0700")
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> <AANLkTikU6fLzWL-n6fCtvaTsXWGis7ydKM1qJaV=WRJ%2B@mail.gmail.com> <8662zkurx9.fsf@ds4.des.no> <AANLkTimbkTQiNgYCYFnTXMpRe9koJGrq1%2BYoq5-fVmFD@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Garrett Cooper <gcooper@FreeBSD.org> writes:
> Dag-Erling Sm=C3=B8rgrav <des@des.no> writes:
> > It might be a good idea to introduce TUNABLE_POINTER and TUNABLE_SIZE.
> I would actually argue against doing that because it would only create
> divergence between sysctl and tunable KPIs...

Not if we also introduce corresponding SYSCTLs.  Note that my idea is to
have these as aliases for the correct primitive types.

> (BTW, when you say TUNABLE_SIZE, I assume it would be a size_t quantity?)

Yes.

> Something might need to be done to the values returned by the tunables
> though, because they don't respect boundaries, and can overflow right
> now (which exacerbates the issue with values crammed into smaller
> datatypes)...

Yes.  How about this:

 - rename getenv_quad() to getenv_signed() and getenv_unsigned()
 - add min / max arguments
 - implement getenv_quad() (and all the others) in terms of
   getenv_number()

e.g.=20

int
getenv_uint(const char *name, unsigned int *data)
{
        unsigned long long tmp;
        int rval;

        if ((rval =3D getenv_unsigned(name, &tmp, 0, UINT_MAX)) =3D=3D 0)
                *data =3D (unsigned int)tmp;
        return (rval);
}

(note that due to the min / max arguments, the complexity of handling
both signed and unsigned values in the same function probably exceeds
the complexity of having two very similar functions)

DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8662zg586z.fsf>