From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
linux-kernel@vger.kernel.org, tglx@linutronix.de
Subject: Re: [PATCH 2/3] kernel/SRCU: provide a static initializer
Date: Fri, 05 Apr 2013 15:21:29 +0800 [thread overview]
Message-ID: <515E7B79.2020707@cn.fujitsu.com> (raw)
In-Reply-To: <1363702606-31586-2-git-send-email-bigeasy@linutronix.de>
On 03/19/2013 10:16 PM, Sebastian Andrzej Siewior wrote:
> There are macros for static initializer for the three out of four
> possible notifier types, that are:
> ATOMIC_NOTIFIER_HEAD()
> BLOCKING_NOTIFIER_HEAD()
> RAW_NOTIFIER_HEAD()
>
> This patch provides a static initilizer for the forth type to make it
> complete.
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> include/linux/notifier.h | 26 +++++++++++++++++++++-----
> include/linux/srcu.h | 6 +++---
> 2 files changed, 24 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/notifier.h b/include/linux/notifier.h
> index d65746e..6bfd703 100644
> --- a/include/linux/notifier.h
> +++ b/include/linux/notifier.h
> @@ -42,9 +42,7 @@
> * in srcu_notifier_call_chain(): no cache bounces and no memory barriers.
> * As compensation, srcu_notifier_chain_unregister() is rather expensive.
> * SRCU notifier chains should be used when the chain will be called very
> - * often but notifier_blocks will seldom be removed. Also, SRCU notifier
> - * chains are slightly more difficult to use because they require special
> - * runtime initialization.
> + * often but notifier_blocks will seldom be removed.
> */
>
> struct notifier_block {
> @@ -85,7 +83,7 @@ struct srcu_notifier_head {
> (name)->head = NULL; \
> } while (0)
>
> -/* srcu_notifier_heads must be initialized and cleaned up dynamically */
> +/* srcu_notifier_heads must be cleaned up dynamically */
> extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
> #define srcu_cleanup_notifier_head(name) \
> cleanup_srcu_struct(&(name)->srcu);
> @@ -98,7 +96,13 @@ extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
> .head = NULL }
> #define RAW_NOTIFIER_INIT(name) { \
> .head = NULL }
> -/* srcu_notifier_heads cannot be initialized statically */
> +
> +#define SRCU_NOTIFIER_INIT(name, pcpu) \
> + { \
> + .mutex = __MUTEX_INITIALIZER(name.mutex), \
> + .head = NULL, \
> + .srcu = __SRCU_STRUCT_INIT(name.srcu, pcpu), \
> + }
Hi, Sebastian
I don't want to expose __SRCU_STRUCT_INIT(),
due to it has strong coupling with the percpu array.
I hope other structure which uses SRCU should use init_srcu_struct().
Thanks,
Lai
>
> #define ATOMIC_NOTIFIER_HEAD(name) \
> struct atomic_notifier_head name = \
> @@ -110,6 +114,18 @@ extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
> struct raw_notifier_head name = \
> RAW_NOTIFIER_INIT(name)
>
> +#define _SRCU_NOTIFIER_HEAD(name, mod) \
> + static DEFINE_PER_CPU(struct srcu_struct_array, \
> + name##_head_srcu_array); \
> + mod struct srcu_notifier_head name = \
> + SRCU_NOTIFIER_INIT(name, name##_head_srcu_array)
> +
> +#define SRCU_NOTIFIER_HEAD(name) \
> + _SRCU_NOTIFIER_HEAD(name, )
> +
> +#define SRCU_NOTIFIER_HEAD_STATIC(name) \
> + _SRCU_NOTIFIER_HEAD(name, static)
> +
> #ifdef __KERNEL__
>
> extern int atomic_notifier_chain_register(struct atomic_notifier_head *nh,
> diff --git a/include/linux/srcu.h b/include/linux/srcu.h
> index d04acb8..fe9efd4 100644
> --- a/include/linux/srcu.h
> +++ b/include/linux/srcu.h
> @@ -84,10 +84,10 @@ int init_srcu_struct(struct srcu_struct *sp);
>
> void process_srcu(struct work_struct *work);
>
> -#define __SRCU_STRUCT_INIT(name) \
> +#define __SRCU_STRUCT_INIT(name, pcpu_name) \
> { \
> .completed = -300, \
> - .per_cpu_ref = &name##_srcu_array, \
> + .per_cpu_ref = &pcpu_name, \
> .queue_lock = __SPIN_LOCK_UNLOCKED(name.queue_lock), \
> .running = false, \
> .batch_queue = RCU_BATCH_INIT(name.batch_queue), \
> @@ -105,7 +105,7 @@ void process_srcu(struct work_struct *work);
> #define _DEFINE_SRCU(name, mod) \
> static DEFINE_PER_CPU(struct srcu_struct_array, name##_srcu_array);\
> mod struct srcu_struct name = \
> - __SRCU_STRUCT_INIT(name);
> + __SRCU_STRUCT_INIT(name, name##_srcu_array);
>
> #define DEFINE_SRCU(name) _DEFINE_SRCU(name, )
> #define DEFINE_STATIC_SRCU(name) _DEFINE_SRCU(name, static)
next prev parent reply other threads:[~2013-04-05 7:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-19 14:16 [PATCH 1/3] kernel/srcu: merge common code into a macro Sebastian Andrzej Siewior
2013-03-19 14:16 ` [PATCH 2/3] kernel/SRCU: provide a static initializer Sebastian Andrzej Siewior
2013-04-05 7:21 ` Lai Jiangshan [this message]
2013-04-08 10:03 ` Sebastian Andrzej Siewior
2013-04-09 1:09 ` Lai Jiangshan
2013-04-11 17:04 ` Sebastian Andrzej Siewior
2013-04-12 2:56 ` Lai Jiangshan
2013-04-16 18:20 ` Paul E. McKenney
2013-03-19 14:16 ` [PATCH 3/3] cpufreq: use static initializer for the SRCU notifier Sebastian Andrzej Siewior
2013-03-19 16:22 ` [PATCH 1/3] kernel/srcu: merge common code into a macro Joe Perches
2013-03-19 18:15 ` Sebastian Andrzej Siewior
2013-04-05 7:21 ` Lai Jiangshan
2013-04-08 10:05 ` Sebastian Andrzej Siewior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=515E7B79.2020707@cn.fujitsu.com \
--to=laijs@cn.fujitsu.com \
--cc=bigeasy@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.