Re: TUNABLE_INT vs TUNABLE_INT_FETCH

From: Luigi Rizzo <rizzo_at_iet.unipi.it>
Date: Thu, 23 Aug 2012 18:05:43 +0200
On Thu, Aug 23, 2012 at 03:52:56PM +0100, Attilio Rao wrote:
> On 8/23/12, Luigi Rizzo <rizzo_at_iet.unipi.it> wrote:
> > Hi,
> > I am a bit unclear on what are the pros and cons of using
> > TUNABLE_INT vs TUNABLE_INT_FETCH within a device driver.
> 
> TUNABLE_INT is basically the "statically initializer" version of
> TUNABLE_INT_FETCH.
> In short terms, you will use TUNABLE_INT_FETCH() in normal functions,
> while TUNABLE_INT() in data declaration.

The thing is, do we need the data declaration at all ?

Using getenv_*() to read the value of a tunable (which is
what TUNABLE_INT_FETCH() translates into) has the additional
making sure that the variable does not change under your feet
e.g. as a result of a kenv.

FWIW, the reason i do not particularly like the non-fetch version
is the way they are defined:

    #define TUNABLE_INT(path, var)                                  \
        static struct tunable_int __CONCAT(__tunable_int_, __LINE__) = { \
                (path),                                         \
                (var),                                          \
        };                                                      \
        SYSINIT(__CONCAT(__Tunable_init_, __LINE__),            \
            SI_SUB_TUNABLES, SI_ORDER_MIDDLE, tunable_int_init, \
            &__CONCAT(__tunable_int_, __LINE__))

note how the identifier uses __LINE__ to make it unique,
which means that you cannot have more than one TUNABLE_INT()
within the body of another macro (this just hit me yesterday).

cheers
luigi
Received on Thu Aug 23 2012 - 13:46:36 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:30 UTC