Re: [PATCH 03/17] mm: page_alloc: Use jump labels to avoid checking number_of_cpusets
From: Peter Zijlstra
Date: Tue May 06 2014 - 16:24:02 EST
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@xxxxxxx>
> ---
> 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);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/