2020-05-13 20:51:00

by Frederic Weisbecker

[permalink] [raw]
Subject: [PATCH 00/10] rcu: Allow a CPU to leave and reenter NOCB state

This is a necessary step toward making nohz_full controllable through
cpuset. Next step should be to allow a CPU to be nocb even if it wasn't
part of the nocb set on boot.

The core design of this set is mostly based on suggestions from Paul
of course.

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git
rcu/nohz

HEAD: 31cb4ee9da4e9cc6314498ff22d83f0d872b1a88

Thanks,
Frederic
---

Frederic Weisbecker (10):
rcu: Directly lock rdp->nocb_lock on nocb code entrypoints
rcu: Use direct rdp->nocb_lock operations on local calls
rcu: Make locking explicit in do_nocb_deferred_wakeup_common()
rcu: Implement rcu_segcblist_is_offloaded() config dependent
rcu: Remove useless conditional nocb unlock
rcu: Make nocb_cb kthread parkable
rcu: Temporarily assume that nohz full CPUs might not be NOCB
rcu: Allow to deactivate nocb on a CPU
rcu: Allow to re-offload a CPU that used to be nocb
rcu: Nocb (de)activate through sysfs


include/linux/rcu_segcblist.h | 2 +
include/linux/rcupdate.h | 4 ++
kernel/cpu.c | 23 +++++++
kernel/rcu/rcu_segcblist.c | 6 +-
kernel/rcu/rcu_segcblist.h | 8 ++-
kernel/rcu/tree.c | 24 +++----
kernel/rcu/tree.h | 2 +-
kernel/rcu/tree_plugin.h | 149 ++++++++++++++++++++++++++++++++++--------
8 files changed, 172 insertions(+), 46 deletions(-)


2020-05-13 20:51:11

by Frederic Weisbecker

[permalink] [raw]
Subject: [PATCH 06/10] rcu: Make nocb_cb kthread parkable

This will be necessary to correctly implement rdp de-offloading. We
don't want rcu_do_batch() in nocb_cb kthread to race with local
rcu_do_batch().

Signed-off-by: Frederic Weisbecker <[email protected]>
Cc: Paul E. McKenney <[email protected]>
Cc: Josh Triplett <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Mathieu Desnoyers <[email protected]>
Cc: Lai Jiangshan <[email protected]>
Cc: Joel Fernandes <[email protected]>
---
kernel/rcu/tree_plugin.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 1dd3fdd675a1..43ecc047af26 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -2104,7 +2104,9 @@ static void nocb_cb_wait(struct rcu_data *rdp)
if (needwake_gp)
rcu_gp_kthread_wake();
swait_event_interruptible_exclusive(rdp->nocb_cb_wq,
- !READ_ONCE(rdp->nocb_cb_sleep));
+ !READ_ONCE(rdp->nocb_cb_sleep) ||
+ kthread_should_park());
+
if (!smp_load_acquire(&rdp->nocb_cb_sleep)) { /* VVV */
/* ^^^ Ensure CB invocation follows _sleep test. */
return;
@@ -2125,6 +2127,8 @@ static int rcu_nocb_cb_kthread(void *arg)
// if there are no more ready callbacks, waits for them.
for (;;) {
nocb_cb_wait(rdp);
+ if (kthread_should_park())
+ kthread_parkme();
cond_resched_tasks_rcu_qs();
}
return 0;
--
2.25.0

2020-05-13 20:52:42

by Paul E. McKenney

[permalink] [raw]
Subject: Re: [PATCH 00/10] rcu: Allow a CPU to leave and reenter NOCB state

On Wed, May 13, 2020 at 06:47:04PM +0200, Frederic Weisbecker wrote:
> This is a necessary step toward making nohz_full controllable through
> cpuset. Next step should be to allow a CPU to be nocb even if it wasn't
> part of the nocb set on boot.
>
> The core design of this set is mostly based on suggestions from Paul
> of course.
>
> git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git
> rcu/nohz
>
> HEAD: 31cb4ee9da4e9cc6314498ff22d83f0d872b1a88

Very cool!!! A few comments on individual commits on a quick first
scan, and more later.

Thanx, Paul

> Thanks,
> Frederic
> ---
>
> Frederic Weisbecker (10):
> rcu: Directly lock rdp->nocb_lock on nocb code entrypoints
> rcu: Use direct rdp->nocb_lock operations on local calls
> rcu: Make locking explicit in do_nocb_deferred_wakeup_common()
> rcu: Implement rcu_segcblist_is_offloaded() config dependent
> rcu: Remove useless conditional nocb unlock
> rcu: Make nocb_cb kthread parkable
> rcu: Temporarily assume that nohz full CPUs might not be NOCB
> rcu: Allow to deactivate nocb on a CPU
> rcu: Allow to re-offload a CPU that used to be nocb
> rcu: Nocb (de)activate through sysfs
>
>
> include/linux/rcu_segcblist.h | 2 +
> include/linux/rcupdate.h | 4 ++
> kernel/cpu.c | 23 +++++++
> kernel/rcu/rcu_segcblist.c | 6 +-
> kernel/rcu/rcu_segcblist.h | 8 ++-
> kernel/rcu/tree.c | 24 +++----
> kernel/rcu/tree.h | 2 +-
> kernel/rcu/tree_plugin.h | 149 ++++++++++++++++++++++++++++++++++--------
> 8 files changed, 172 insertions(+), 46 deletions(-)

2020-06-11 01:36:54

by Joel Fernandes

[permalink] [raw]
Subject: Re: [PATCH 06/10] rcu: Make nocb_cb kthread parkable

On Wed, May 13, 2020 at 06:47:10PM +0200, Frederic Weisbecker wrote:
> This will be necessary to correctly implement rdp de-offloading. We
> don't want rcu_do_batch() in nocb_cb kthread to race with local
> rcu_do_batch().
>
> Signed-off-by: Frederic Weisbecker <[email protected]>
> Cc: Paul E. McKenney <[email protected]>
> Cc: Josh Triplett <[email protected]>
> Cc: Steven Rostedt <[email protected]>
> Cc: Mathieu Desnoyers <[email protected]>
> Cc: Lai Jiangshan <[email protected]>
> Cc: Joel Fernandes <[email protected]>

Reviewed-by: Joel Fernandes (Google) <[email protected]>

thanks,

- Joel


> ---
> kernel/rcu/tree_plugin.h | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
> index 1dd3fdd675a1..43ecc047af26 100644
> --- a/kernel/rcu/tree_plugin.h
> +++ b/kernel/rcu/tree_plugin.h
> @@ -2104,7 +2104,9 @@ static void nocb_cb_wait(struct rcu_data *rdp)
> if (needwake_gp)
> rcu_gp_kthread_wake();
> swait_event_interruptible_exclusive(rdp->nocb_cb_wq,
> - !READ_ONCE(rdp->nocb_cb_sleep));
> + !READ_ONCE(rdp->nocb_cb_sleep) ||
> + kthread_should_park());
> +
> if (!smp_load_acquire(&rdp->nocb_cb_sleep)) { /* VVV */
> /* ^^^ Ensure CB invocation follows _sleep test. */
> return;
> @@ -2125,6 +2127,8 @@ static int rcu_nocb_cb_kthread(void *arg)
> // if there are no more ready callbacks, waits for them.
> for (;;) {
> nocb_cb_wait(rdp);
> + if (kthread_should_park())
> + kthread_parkme();
> cond_resched_tasks_rcu_qs();
> }
> return 0;
> --
> 2.25.0
>