[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140506222118.GB23991@suse.de>
Date: Tue, 6 May 2014 23:21:18 +0100
From: Mel Gorman <mgorman@...e.de>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Linux-MM <linux-mm@...ck.org>,
Linux-FSDevel <linux-fsdevel@...r.kernel.org>,
Johannes Weiner <hannes@...xchg.org>,
Vlastimil Babka <vbabka@...e.cz>, Jan Kara <jack@...e.cz>,
Michal Hocko <mhocko@...e.cz>, Hugh Dickins <hughd@...gle.com>,
Linux Kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 03/17] mm: page_alloc: Use jump labels to avoid checking
number_of_cpusets
On Tue, May 06, 2014 at 10:23:50PM +0200, Peter Zijlstra wrote:
> On Thu, May 01, 2014 at 09:44:34AM +0100, Mel Gorman wrote:
> > If cpusets are not in use then we still check a global variable on every
> > page allocation. Use jump labels to avoid the overhead.
> >
> > Signed-off-by: Mel Gorman <mgorman@...e.de>
> > ---
> > include/linux/cpuset.h | 31 +++++++++++++++++++++++++++++++
> > kernel/cpuset.c | 8 ++++++--
> > mm/page_alloc.c | 3 ++-
> > 3 files changed, 39 insertions(+), 3 deletions(-)
> >
> > diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
> > index b19d3dc..2b89e07 100644
> > --- a/include/linux/cpuset.h
> > +++ b/include/linux/cpuset.h
> > @@ -17,6 +17,35 @@
> >
> > extern int number_of_cpusets; /* How many cpusets are defined in system? */
> >
> > +#ifdef HAVE_JUMP_LABEL
> > +extern struct static_key cpusets_enabled_key;
> > +static inline bool cpusets_enabled(void)
> > +{
> > + return static_key_false(&cpusets_enabled_key);
> > +}
> > +#else
> > +static inline bool cpusets_enabled(void)
> > +{
> > + return number_of_cpusets > 1;
> > +}
> > +#endif
> > +
> > +static inline void cpuset_inc(void)
> > +{
> > + number_of_cpusets++;
> > +#ifdef HAVE_JUMP_LABEL
> > + static_key_slow_inc(&cpusets_enabled_key);
> > +#endif
> > +}
> > +
> > +static inline void cpuset_dec(void)
> > +{
> > + number_of_cpusets--;
> > +#ifdef HAVE_JUMP_LABEL
> > + static_key_slow_dec(&cpusets_enabled_key);
> > +#endif
> > +}
>
> Why the HAVE_JUMP_LABEL and number_of_cpusets thing? When
> !HAVE_JUMP_LABEL the static_key thing reverts to an atomic_t and
> static_key_false() becomes:
>
Because number_of_cpusets is used to size a kmalloc(). Potentially I could
abuse the internals of static keys and use the value of key->enabled but
that felt like abuse of the API.
--
Mel Gorman
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists