public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: linux-kernel@vger.kernel.org, mingo@kernel.org,
	jiangshanlai@gmail.com, dipankar@in.ibm.com,
	akpm@linux-foundation.org, mathieu.desnoyers@efficios.com,
	josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org,
	dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com,
	oleg@redhat.com, joel@joelfernandes.org,
	Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH tip/core/rcu 3/3] srcu: Make early-boot call_srcu() reuse workqueue lists
Date: Wed, 29 Aug 2018 21:56:16 -0400	[thread overview]
Message-ID: <20180829215616.1c10e476@vmware.local.home> (raw)
In-Reply-To: <20180829212313.22903-3-paulmck@linux.vnet.ibm.com>

On Wed, 29 Aug 2018 14:23:13 -0700
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com> wrote:

> Allocating a list_head structure that is almost never used, and, when
> used, is used only during early boot (rcu_init() and earlier), is a bit
> wasteful.  This commit therefore eliminates that list_head in favor of
> the one in the work_struct structure.  This is safe because the work_struct
> structure cannot be used until after rcu_init() returns.
> 
> Reported-by: Steven Rostedt <rostedt@goodmis.org>
> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Lai Jiangshan <jiangshanlai@gmail.com>
> ---
>  include/linux/srcutiny.h |  2 --
>  include/linux/srcutree.h |  3 +--
>  kernel/rcu/srcutiny.c    | 10 +++++-----
>  kernel/rcu/srcutree.c    | 11 +++++------
>  4 files changed, 11 insertions(+), 15 deletions(-)
> 
> diff --git a/include/linux/srcutiny.h b/include/linux/srcutiny.h
> index 2b5c0822e683..f41d2fb09f87 100644
> --- a/include/linux/srcutiny.h
> +++ b/include/linux/srcutiny.h
> @@ -36,7 +36,6 @@ struct srcu_struct {
>  	struct rcu_head *srcu_cb_head;	/* Pending callbacks: Head. */
>  	struct rcu_head **srcu_cb_tail;	/* Pending callbacks: Tail. */
>  	struct work_struct srcu_work;	/* For driving grace periods. */
> -	struct list_head srcu_boot_entry; /* Early-boot callbacks. */
>  #ifdef CONFIG_DEBUG_LOCK_ALLOC
>  	struct lockdep_map dep_map;
>  #endif /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
> @@ -49,7 +48,6 @@ void srcu_drive_gp(struct work_struct *wp);
>  	.srcu_wq = __SWAIT_QUEUE_HEAD_INITIALIZER(name.srcu_wq),	\
>  	.srcu_cb_tail = &name.srcu_cb_head,				\
>  	.srcu_work = __WORK_INITIALIZER(name.srcu_work, srcu_drive_gp),	\
> -	.srcu_boot_entry = LIST_HEAD_INIT(name.srcu_boot_entry),	\
>  	__SRCU_DEP_MAP_INIT(name)					\
>  }
>  
> diff --git a/include/linux/srcutree.h b/include/linux/srcutree.h
> index 9cfa4610113a..0ae91b3a7406 100644
> --- a/include/linux/srcutree.h
> +++ b/include/linux/srcutree.h
> @@ -94,7 +94,6 @@ struct srcu_struct {
>  						/*  callback for the barrier */
>  						/*  operation. */
>  	struct delayed_work work;
> -	struct list_head srcu_boot_entry;	/* Early-boot callbacks. */
>  #ifdef CONFIG_DEBUG_LOCK_ALLOC
>  	struct lockdep_map dep_map;
>  #endif /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
> @@ -110,7 +109,7 @@ struct srcu_struct {
>  	.sda = &pcpu_name,						\
>  	.lock = __SPIN_LOCK_UNLOCKED(name.lock),			\
>  	.srcu_gp_seq_needed = -1UL,					\
> -	.srcu_boot_entry = LIST_HEAD_INIT(name.srcu_boot_entry),	\
> +	.work = __DELAYED_WORK_INITIALIZER(name.work, NULL, 0),		\

Thanks!

-- Steve

>  	__SRCU_DEP_MAP_INIT(name)					\
>  }
>  
> diff --git a/kernel/rcu/srcutiny.c b/kernel/rcu/srcutiny.c
> index d233f0c63f6f..b46e6683f8c9 100644
> --- a/kernel/rcu/srcutiny.c
> +++ b/kernel/rcu/srcutiny.c
> @@ -48,7 +48,7 @@ static int init_srcu_struct_fields(struct srcu_struct *sp)
>  	sp->srcu_gp_waiting = false;
>  	sp->srcu_idx = 0;
>  	INIT_WORK(&sp->srcu_work, srcu_drive_gp);
> -	INIT_LIST_HEAD(&sp->srcu_boot_entry);
> +	INIT_LIST_HEAD(&sp->srcu_work.entry);
>  	return 0;
>  }
>  
> @@ -185,8 +185,8 @@ void call_srcu(struct srcu_struct *sp, struct rcu_head *rhp,
>  	if (!READ_ONCE(sp->srcu_gp_running)) {
>  		if (likely(srcu_init_done))
>  			schedule_work(&sp->srcu_work);
> -		else if (list_empty(&sp->srcu_boot_entry))
> -			list_add(&sp->srcu_boot_entry, &srcu_boot_list);
> +		else if (list_empty(&sp->srcu_work.entry))
> +			list_add(&sp->srcu_work.entry, &srcu_boot_list);
>  	}
>  }
>  EXPORT_SYMBOL_GPL(call_srcu);
> @@ -224,8 +224,8 @@ void __init srcu_init(void)
>  	srcu_init_done = true;
>  	while (!list_empty(&srcu_boot_list)) {
>  		sp = list_first_entry(&srcu_boot_list,
> -				      struct srcu_struct, srcu_boot_entry);
> -		list_del_init(&sp->srcu_boot_entry);
> +				      struct srcu_struct, srcu_work.entry);
> +		list_del_init(&sp->srcu_work.entry);
>  		schedule_work(&sp->srcu_work);
>  	}
>  }
> diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
> index e79c1929328f..36a2857c84e0 100644
> --- a/kernel/rcu/srcutree.c
> +++ b/kernel/rcu/srcutree.c
> @@ -186,7 +186,6 @@ static int init_srcu_struct_fields(struct srcu_struct *sp, bool is_static)
>  	mutex_init(&sp->srcu_barrier_mutex);
>  	atomic_set(&sp->srcu_barrier_cpu_cnt, 0);
>  	INIT_DELAYED_WORK(&sp->work, process_srcu);
> -	INIT_LIST_HEAD(&sp->srcu_boot_entry);
>  	if (!is_static)
>  		sp->sda = alloc_percpu(struct srcu_data);
>  	init_srcu_struct_nodes(sp, is_static);
> @@ -709,8 +708,8 @@ static void srcu_funnel_gp_start(struct srcu_struct *sp, struct srcu_data *sdp,
>  		if (likely(srcu_init_done))
>  			queue_delayed_work(rcu_gp_wq, &sp->work,
>  					   srcu_get_delay(sp));
> -		else if (list_empty(&sp->srcu_boot_entry))
> -			list_add(&sp->srcu_boot_entry, &srcu_boot_list);
> +		else if (list_empty(&sp->work.work.entry))
> +			list_add(&sp->work.work.entry, &srcu_boot_list);
>  	}
>  	spin_unlock_irqrestore_rcu_node(sp, flags);
>  }
> @@ -1324,10 +1323,10 @@ void __init srcu_init(void)
>  
>  	srcu_init_done = true;
>  	while (!list_empty(&srcu_boot_list)) {
> -		sp = list_first_entry(&srcu_boot_list,
> -				      struct srcu_struct, srcu_boot_entry);
> +		sp = list_first_entry(&srcu_boot_list, struct srcu_struct,
> +				      work.work.entry);
>  		check_init_srcu_struct(sp);
> -		list_del_init(&sp->srcu_boot_entry);
> +		list_del_init(&sp->work.work.entry);
>  		queue_work(rcu_gp_wq, &sp->work.work);
>  	}
>  }


  reply	other threads:[~2018-08-30  1:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-29 21:20 [PATCH tip/core/rcu 0/3] SRCU updates for v4.20/v5.0 Paul E. McKenney
2018-08-29 21:23 ` [PATCH tip/core/rcu 1/3] srcu: Make call_srcu() available during very early boot Paul E. McKenney
2018-08-30 18:24   ` [PATCH tip/core/rcu v2 " Paul E. McKenney
2018-08-29 21:23 ` [PATCH tip/core/rcu 2/3] rcutorture: Test early boot call_srcu() Paul E. McKenney
2018-08-29 21:23 ` [PATCH tip/core/rcu 3/3] srcu: Make early-boot call_srcu() reuse workqueue lists Paul E. McKenney
2018-08-30  1:56   ` Steven Rostedt [this message]
2018-08-30  2:07     ` Paul E. McKenney
2018-08-30  2:46       ` Steven Rostedt
2018-08-30  3:23         ` Paul E. McKenney
2018-08-30 16:44           ` Steven Rostedt
2018-08-30 17:35             ` Paul E. McKenney
2018-08-30 17:37               ` Paul E. McKenney
2018-08-30 18:36                 ` Steven Rostedt
2018-08-30 23:12                   ` Paul E. McKenney
2018-08-30 23:53                     ` Steven Rostedt
2018-08-31  0:09                       ` Paul E. McKenney
2018-08-31  0:55                         ` Steven Rostedt

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=20180829215616.1c10e476@vmware.local.home \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=edumazet@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jiangshanlai@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox