lkml.org 
[lkml]   [2014]   [May]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 03/17] mm: page_alloc: Use jump labels to avoid checking number_of_cpusets
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@suse.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:

return unlikely(atomic_read(&key->enabled) > 0);



\
 
 \ /
  Last update: 2014-05-06 23:41    [W:0.278 / U:0.520 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site