lkml.org 
[lkml]   [2010]   [Oct]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC][PATCH 5/7] jump_label: atomic_t interface
On Thu, Oct 14, 2010 at 10:34:09PM +0200, Peter Zijlstra wrote:
> Add an interface to allow usage of jump_labels with atomic counters
>
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
> ---
> include/linux/jump_label_ref.h | 44 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> Index: linux-2.6/include/linux/jump_label_ref.h
> ===================================================================
> --- /dev/null
> +++ linux-2.6/include/linux/jump_label_ref.h
> @@ -0,0 +1,44 @@
> +#ifndef _LINUX_JUMP_LABEL_REF_H
> +#define _LINUX_JUMP_LABEL_REF_H
> +
> +#include <linux/jump_label.h>
> +#include <asm/atomic.h>
> +
> +#ifdef HAVE_JUMP_LABEL
> +
> +static inline void jump_label_inc(atomic_t *key)
> +{
> + if (atomic_add_return(1, key) == 1)
> + jump_label_enable(key);
> +}
> +
> +static inline void jump_label_dec(atomic_t *key)
> +{
> + if (atomic_dec_and_test(key))
> + jump_label_disable(key);
> +}



Nice. I was trying to find a more self-explanatory name,
like jump_label_get/put or jump_label_inc_enable/jump_label_dec_disable.

But in fact the current name looks good eventually.

Acked-by: Frederic Weisbecker <fweisbec@gmail.com>




> +#else /* !HAVE_JUMP_LABEL */
> +
> +static inline void jump_label_inc(atomic_t *key)
> +{
> + atomic_inc(key);
> +}
> +
> +static inline void jump_label_dec(atomic_t *key)
> +{
> + atomic_dec(key);
> +}
> +
> +#undef JUMP_LABEL
> +#define JUMP_LABEL(key, label) \
> +do { \
> + if (unlikely(__builtin_choose_expr( \
> + __builtin_types_compatible_p(typeof(key), atomic_t *), \
> + atomic_read((atomic_t *)(key)), *(key)))) \
> + goto label; \
> +} while (0)
> +
> +#endif /* HAVE_JUMP_LABEL */
> +
> +#endif /* _LINUX_JUMP_LABEL_REF_H */
>
>



\
 
 \ /
  Last update: 2010-10-15 17:05    [W:0.142 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site