[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110105171516.GB1692@nowhere>
Date: Wed, 5 Jan 2011 18:15:18 +0100
From: Frederic Weisbecker <fweisbec@...il.com>
To: Jason Baron <jbaron@...hat.com>
Cc: peterz@...radead.org, mathieu.desnoyers@...ymtl.ca, hpa@...or.com,
rostedt@...dmis.org, mingo@...e.hu, tglx@...utronix.de,
andi@...stfloor.org, roland@...hat.com, rth@...hat.com,
masami.hiramatsu.pt@...achi.com, avi@...hat.com,
davem@...emloft.net, sam@...nborg.org, ddaney@...iumnetworks.com,
michael@...erman.id.au, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] jump label: introduce static_branch()
On Wed, Jan 05, 2011 at 10:43:12AM -0500, Jason Baron wrote:
> diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
> index 152f7de..0ad9c2e 100644
> --- a/include/linux/jump_label.h
> +++ b/include/linux/jump_label.h
> @@ -22,6 +22,11 @@ struct module;
>
> #ifdef HAVE_JUMP_LABEL
>
> +static __always_inline bool static_branch(struct jump_label_key *key)
> +{
> + return __static_branch(key);
Not very important, but __static_branch() would be more self-explained
if it was called arch_static_branch().
> +}
> +
> extern struct jump_entry __start___jump_table[];
> extern struct jump_entry __stop___jump_table[];
>
> @@ -42,11 +47,12 @@ struct jump_label_key {
> int state;
> };
>
> -#define JUMP_LABEL(key, label) \
> -do { \
> - if (unlikely(((struct jump_label_key *)key)->state)) \
> - goto label; \
> -} while (0)
> +static __always_inline bool static_branch(struct jump_label_key *key)
> +{
> + if (unlikely(key->state))
> + return true;
> + return false;
> +}
>
> static inline int jump_label_enabled(struct jump_label_key *key)
> {
> @@ -78,14 +84,4 @@ static inline void jump_label_unlock(void) {}
>
> #endif
>
> -#define COND_STMT(key, stmt) \
> -do { \
> - __label__ jl_enabled; \
> - JUMP_LABEL_ELSE_ATOMIC_READ(key, jl_enabled); \
> - if (0) { \
> -jl_enabled: \
> - stmt; \
> - } \
> -} while (0)
> -
> #endif
> diff --git a/include/linux/jump_label_ref.h b/include/linux/jump_label_ref.h
> index 8a76e89..5178696 100644
> --- a/include/linux/jump_label_ref.h
> +++ b/include/linux/jump_label_ref.h
> @@ -7,19 +7,23 @@
> struct jump_label_key_counter {
> atomic_t ref;
> struct jump_label_key key;
> -}
> +};
>
> #ifdef HAVE_JUMP_LABEL
>
> -#define JUMP_LABEL_ELSE_ATOMIC_READ(key, label, counter) JUMP_LABEL(key, label)
> +static __always_inline bool static_branch_else_atomic_read(struct jump_label_key *key, atomic_t *count)
> +{
> + return __static_branch(key);
> +}
How about having only static_branch() but the key would be handled only
by ways of get()/put().
Simple boolean key enablement would work in this scheme as well as branches
based on refcount. So that the users could avoid maintaining both key and count,
this would be transparently handled by the jump label API.
Or am I missing something?
Other than that, looks like a very nice patch!
--
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