lkml.org 
[lkml]   [2012]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 00/10] jump label: introduce very_[un]likely + cleanups + docs
* Ingo Molnar (mingo@elte.hu) wrote:
>
> * Ingo Molnar <mingo@elte.hu> wrote:
>
> > So, a modified scheme would be:
> >
> > #include <linux/static_key.h>
> >
> > struct static_key key = STATIC_KEY_INIT_TRUE;
> >
> > if (static_key_false(&key))
> > do unlikely code
> > else
> > do likely code
> >
> > Or:
> >
> > if (static_key_true(&key))
> > do likely code
> > else
> > do unlikely code
> >
> > The static key is modified via:
> >
> > static_key_slow_inc(&key);
> > ...
> > static_key_slow_dec(&key);
> >
> > Is that API fine? I'll rework the series to such an effect if
> > everyone agrees.
>
> I.e. something like the patch below on top of
> tip:perf/jump-labels.
>
> Untested - will test it and will refactor the series if
> everyone's happy.

Hi Ingo,

Reading your documentation updates makes me realise that adding the
"inline" keyword in there would make the whole thing even clearer:

struct static_key key = STATIC_KEY_INLINE_TRUE_INIT;
struct static_key key = STATIC_KEY_INLINE_FALSE_INIT;

static_key_inline_true() / static_key_inline_false()

to show that the "true/false" in there does not mean that the key will
always be true or false (the key value can indeed by changed by calling
static_key_slow_inc/dec), but that the inlined path is either the true
of false branch.

The rest looks fine.

Best regards,

Mathieu

--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com


\
 
 \ /
  Last update: 2012-02-24 00:21    [W:0.110 / U:4.532 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site