Skip to contentSkip to conversation

Reduce synchronize_rcu() latency(v6)

PATCH Applied Uladzislau Rezki (Sony) 2 participants 10 messages Mar 8, 2024 – Mar 11, 2024

Subsystems (3)
lore
Share & tools
lore

Uladzislau Rezki (Sony)

author maintainer
#0 lore raw

v6 cover Reduce synchronize_rcu() latency(v6)

This is v6. It is based on the Paul's "dev" branch:

HEAD: f1bfe538c7970283040a7188a291aca9f18f0c42

please note, that patches should be applied from scratch, i.e. the v5 has to be dropped from the "dev".

v5 -> v6:
- Fix a race due to realising a wait-head from the gp-kthread;
- Use our own private workqueue with WQ_MEM_RECLAIM to have at least one execution context.

v5: https://lore.kernel.org/lkml/[email protected]/
v4: https://lore.kernel.org/lkml/[email protected]/T/
v3: https://lore.kernel.org/lkml/cd45b0b5-f86b-43fb-a5f3-47d340cd4f9f@paulmck-laptop/T/
v2: https://lore.kernel.org/all/[email protected]/T/
v1: https://lore.kernel.org/lkml/[email protected]/T/

Uladzislau Rezki (Sony) (6):
rcu: Add data structures for synchronize_rcu()
rcu: Reduce synchronize_rcu() latency
rcu: Add a trace event for synchronize_rcu_normal()
rcu: Support direct wake-up of synchronize_rcu() users
rcu: Do not release a wait-head from a GP kthread
rcu: Allocate WQ with WQ_MEM_RECLAIM bit set

 .../admin-guide/kernel-parameters.txt         |  14 +
 include/trace/events/rcu.h                    |  27 ++
 kernel/rcu/tree.c                             | 361 +++++++++++++++++-
 kernel/rcu/tree.h                             |  20 +
 kernel/rcu/tree_exp.h                         |   2 +-
 5 files changed, 422 insertions(+), 2 deletions(-)
Signature · 1 line
2.39.2
author maintainer
#1 lore raw

PATCH v6 1/6 rcu: Add data structures for synchronize_rcu()

The synchronize_rcu() call is going to be reworked, thus this patch adds dedicated fields into the rcu_state structure.

---
 kernel/rcu/tree.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
kernel/rcu/tree.h +14 -0
index df48160b3136..b942b9437438 100644
@@ -315,6 +315,13 @@ do {									\
 	__set_current_state(TASK_RUNNING);				\
 } while (0)
 
+#define SR_NORMAL_GP_WAIT_HEAD_MAX 5
+
+struct sr_wait_node {
+	atomic_t inuse;
+	struct llist_node node;
+};
+
 /*
  * RCU global state, including node hierarchy.  This hierarchy is
  * represented in "heap" form in a dense array.  The root (first level)
@@ -400,6 +407,13 @@ struct rcu_state {
 						/* Synchronize offline with */
 						/*  GP pre-initialization. */
 	int nocb_is_setup;			/* nocb is setup from boot */
+
+	/* synchronize_rcu() part. */
+	struct llist_head srs_next;	/* request a GP users. */
+	struct llist_node *srs_wait_tail; /* wait for GP users. */
+	struct llist_node *srs_done_tail; /* ready for GP users. */
+	struct sr_wait_node srs_wait_nodes[SR_NORMAL_GP_WAIT_HEAD_MAX];
+	struct work_struct srs_cleanup_work;
 };
 
 /* Values for rcu_state structure's gp_flags field. */
Signature · 1 line
2.39.2
author maintainer
#2 lore raw

PATCH v6 2/6 rcu: Reduce synchronize_rcu() latency

In reply to Uladzislau Rezki (Sony)

A call to a synchronize_rcu() can be optimized from a latency point of view. Workloads which depend on this can benefit of it.

The delay of wakeme_after_rcu() callback, which unblocks a waiter, depends on several factors:

- how fast a process of offloading is started. Combination of:
- !CONFIG_RCU_NOCB_CPU/CONFIG_RCU_NOCB_CPU;
- !CONFIG_RCU_LAZY/CONFIG_RCU_LAZY;
- other.
- when started, invoking path is interrupted due to:
- time limit;
- need_resched();
- if limit is reached.
- where in a nocb list it is located;
- how fast previous callbacks completed;

Example:

1. On our embedded devices i can easily trigger the scenario when it is a last in the list out of ~3600 callbacks:

<snip>
<...>-29 [001] d..1. 21950.145313: rcu_batch_start: rcu_preempt CBs=3613 bl=28
...

  <...>-29      [001] ..... 21950.152578: rcu_invoke_callback: rcu_preempt rhp=00000000b2d6dee8 func=__free_vm_area_struct.cfi_jt
  <...>-29      [001] ..... 21950.152579: rcu_invoke_callback: rcu_preempt rhp=00000000a446f607 func=__free_vm_area_struct.cfi_jt
  <...>-29      [001] ..... 21950.152580: rcu_invoke_callback: rcu_preempt rhp=00000000a5cab03b func=__free_vm_area_struct.cfi_jt
  <...>-29      [001] ..... 21950.152581: rcu_invoke_callback: rcu_preempt rhp=0000000013b7e5ee func=__free_vm_area_struct.cfi_jt
  <...>-29      [001] ..... 21950.152582: rcu_invoke_callback: rcu_preempt rhp=000000000a8ca6f9 func=__free_vm_area_struct.cfi_jt
  <...>-29      [001] ..... 21950.152583: rcu_invoke_callback: rcu_preempt rhp=000000008f162ca8 func=wakeme_after_rcu.cfi_jt
  <...>-29      [001] d..1. 21950.152625: rcu_batch_end: rcu_preempt CBs-invoked=3612 idle=....

<snip>

2. We use cpuset/cgroup to classify tasks and assign them into different cgroups. For example "backgrond" group which binds tasks only to little CPUs or "foreground" which makes use of all CPUs. Tasks can be migrated between groups by a request if an acceleration is needed.

See below an example how "surfaceflinger" task gets migrated. Initially it is located in the "system-background" cgroup which allows to run only on little cores. In order to speed it up it can be temporary moved into "foreground" cgroup which allows to use big/all CPUs:

cgroup_attach_task():
-> cgroup_migrate_execute()
-> cpuset_can_attach()

     -> percpu_down_write()
       -> rcu_sync_enter()
         -> synchronize_rcu()

-> now move tasks to the new cgroup.
-> cgroup_migrate_finish()

<snip>

         rcuop/1-29      [000] .....  7030.528570: rcu_invoke_callback: rcu_preempt rhp=00000000461605e0 func=wakeme_after_rcu.cfi_jt
    PERFD-SERVER-1855    [000] d..1.  7030.530293: cgroup_attach_task: dst_root=3 dst_id=22 dst_level=1 dst_path=/foreground pid=1900 comm=surfaceflinger
   TimerDispatch-2768    [002] d..5.  7030.537542: sched_migrate_task: comm=surfaceflinger pid=1900 prio=98 orig_cpu=0 dest_cpu=4

<snip>

"Boosting a task" depends on synchronize_rcu() latency:

- first trace shows a completion of synchronize_rcu();
- second shows attaching a task to a new group;
- last shows a final step when migration occurs.

3. To address this drawback, maintain a separate track that consists of synchronize_rcu() callers only. After completion of a grace period users are deferred to a dedicated worker to process requests.

4. This patch reduces the latency of synchronize_rcu() approximately by ~30-40% on synthetic tests. The real test case, camera launch time, shows(time is in milliseconds):

1-run 542 vs 489 improvement 9%
2-run 540 vs 466 improvement 13%
3-run 518 vs 468 improvement 9%
4-run 531 vs 457 improvement 13%
5-run 548 vs 475 improvement 13%
6-run 509 vs 484 improvement 4%

Synthetic test(no "noise" from other callbacks):
Hardware: x86_64 64 CPUs, 64GB of memory
Linux-6.6

- 10K tasks(simultaneous);
- each task does(1000 loops)

     synchronize_rcu();
     kfree(p);

default: CONFIG_RCU_NOCB_CPU: takes 54 seconds to complete all users;
patch: CONFIG_RCU_NOCB_CPU: takes 35 seconds to complete all users.

Running 60K gives approximately same results on my setup. Please note it is without any interaction with another type of callbacks, otherwise it will impact a lot a default case.

5. By default it is disabled. To enable this perform one of the below sequence:

echo 1 > /sys/module/rcutree/parameters/rcu_normal_wake_from_gp or pass a boot parameter "rcutree.rcu_normal_wake_from_gp=1"

---
 .../admin-guide/kernel-parameters.txt         |  14 +
 kernel/rcu/tree.c                             | 330 +++++++++++++++++-
 kernel/rcu/tree_exp.h                         |   2 +-
 3 files changed, 344 insertions(+), 2 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +14 -0
index 94314d0eb301..3f894fbb4916 100644
@@ -5052,6 +5052,20 @@
 			delay, memory pressure or callback list growing too
 			big.
 
+	rcutree.rcu_normal_wake_from_gp= [KNL]
+			Reduces a latency of synchronize_rcu() call. This approach
+			maintains its own track of synchronize_rcu() callers, so it
+			does not interact with regular callbacks because it does not
+			use a call_rcu[_hurry]() path. Please note, this is for a
+			normal grace period.
+
+			How to enable it:
+
+			echo 1 > /sys/module/rcutree/parameters/rcu_normal_wake_from_gp
+			or pass a boot parameter "rcutree.rcu_normal_wake_from_gp=1"
+
+			Default is 0.
+
 	rcuscale.gp_async= [KNL]
 			Measure performance of asynchronous
 			grace-period primitives such as call_rcu().
kernel/rcu/tree.c +329 -1

382 lines not on this page · raw message

kernel/rcu/tree_exp.h +1 -1
index 6b83537480b1..8a1d9c8bd9f7 100644
@@ -930,7 +930,7 @@ void synchronize_rcu_expedited(void)
 
 	/* If expedited grace periods are prohibited, fall back to normal. */
 	if (rcu_gp_is_normal()) {
-		wait_rcu_gp(call_rcu_hurry);
+		synchronize_rcu_normal();
 		return;
 	}
 
Signature · 1 line
2.39.2
author maintainer
#3 lore raw

PATCH v6 3/6 rcu: Add a trace event for synchronize_rcu_normal()

In reply to Uladzislau Rezki (Sony)

Add an rcu_sr_normal() trace event. It takes three arguments first one is the name of RCU flavour, second one is a user id which triggeres synchronize_rcu_normal() and last one is an event.

There are two traces in the synchronize_rcu_normal(). On entry, when a new request is registered and on exit point when request is completed.

Please note, CONFIG_RCU_TRACE=y is required to activate traces.

---
 include/trace/events/rcu.h | 27 +++++++++++++++++++++++++++
 kernel/rcu/tree.c          |  7 ++++++-
 2 files changed, 33 insertions(+), 1 deletion(-)
include/trace/events/rcu.h +27 -0
index 2ef9c719772a..31b3e0d3e65f 100644
@@ -707,6 +707,33 @@ TRACE_EVENT_RCU(rcu_invoke_kfree_bulk_callback,
 		__entry->rcuname, __entry->p, __entry->nr_records)
 );
 
+/*
+ * Tracepoint for a normal synchronize_rcu() states. The first argument
+ * is the RCU flavor, the second argument is a pointer to rcu_head the
+ * last one is an event.
+ */
+TRACE_EVENT_RCU(rcu_sr_normal,
+
+	TP_PROTO(const char *rcuname, struct rcu_head *rhp, const char *srevent),
+
+	TP_ARGS(rcuname, rhp, srevent),
+
+	TP_STRUCT__entry(
+		__field(const char *, rcuname)
+		__field(void *, rhp)
+		__field(const char *, srevent)
+	),
+
+	TP_fast_assign(
+		__entry->rcuname = rcuname;
+		__entry->rhp = rhp;
+		__entry->srevent = srevent;
+	),
+
+	TP_printk("%s rhp=0x%p event=%s",
+		__entry->rcuname, __entry->rhp, __entry->srevent)
+);
+
 /*
  * Tracepoint for exiting rcu_do_batch after RCU callbacks have been
  * invoked.  The first argument is the name of the RCU flavor,
kernel/rcu/tree.c +6 -1
index 42a31d4d279b..dcc1764e8fad 100644
@@ -3887,9 +3887,11 @@ static void synchronize_rcu_normal(void)
 {
 	struct rcu_synchronize rs;
 
+	trace_rcu_sr_normal(rcu_state.name, &rs.head, TPS("request"));
+
 	if (!READ_ONCE(rcu_normal_wake_from_gp)) {
 		wait_rcu_gp(call_rcu_hurry);
-		return;
+		goto trace_complete_out;
 	}
 
 	init_rcu_head_on_stack(&rs.head);
@@ -3910,6 +3912,9 @@ static void synchronize_rcu_normal(void)
 	/* Now we can wait. */
 	wait_for_completion(&rs.completion);
 	destroy_rcu_head_on_stack(&rs.head);
+
+trace_complete_out:
+	trace_rcu_sr_normal(rcu_state.name, &rs.head, TPS("complete"));
 }
 
 /**
Signature · 1 line
2.39.2
author maintainer
#4 lore raw

PATCH v6 4/6 rcu: Support direct wake-up of synchronize_rcu() users

In reply to Uladzislau Rezki (Sony)

This patch introduces a small enhancement which allows to do a direct wake-up of synchronize_rcu() callers. It occurs after a completion of grace period, thus by the gp-kthread.

Number of clients is limited by the hard-coded maximum allowed threshold. The remaining part, if still exists is deferred to a main worker.

---
 kernel/rcu/tree.c | 32 ++++++++++++++++++++++++++++++--
 kernel/rcu/tree.h |  6 ++++++
 2 files changed, 36 insertions(+), 2 deletions(-)
kernel/rcu/tree.c +30 -2
index dcc1764e8fad..063200613444 100644
@@ -1672,7 +1672,8 @@ static void rcu_sr_normal_gp_cleanup_work(struct work_struct *work)
  */
 static void rcu_sr_normal_gp_cleanup(void)
 {
-	struct llist_node *wait_tail;
+	struct llist_node *wait_tail, *next, *rcu;
+	int done = 0;
 
 	wait_tail = rcu_state.srs_wait_tail;
 	if (wait_tail == NULL)
@@ -1680,12 +1681,39 @@ static void rcu_sr_normal_gp_cleanup(void)
 
 	rcu_state.srs_wait_tail = NULL;
 	ASSERT_EXCLUSIVE_WRITER(rcu_state.srs_wait_tail);
+	WARN_ON_ONCE(!rcu_sr_is_wait_head(wait_tail));
+
+	/*
+	 * Process (a) and (d) cases. See an illustration. Apart of
+	 * that it handles the scenario when all clients are done,
+	 * wait-head is released if last. The worker is not kicked.
+	 */
+	llist_for_each_safe(rcu, next, wait_tail->next) {
+		if (rcu_sr_is_wait_head(rcu)) {
+			if (!rcu->next) {
+				rcu_sr_put_wait_head(rcu);
+				wait_tail->next = NULL;
+			} else {
+				wait_tail->next = rcu;
+			}
+
+			break;
+		}
+
+		rcu_sr_normal_complete(rcu);
+		// It can be last, update a next on this step.
+		wait_tail->next = next;
+
+		if (++done == SR_MAX_USERS_WAKE_FROM_GP)
+			break;
+	}
 
 	// concurrent sr_normal_gp_cleanup work might observe this update.
 	smp_store_release(&rcu_state.srs_done_tail, wait_tail);
 	ASSERT_EXCLUSIVE_WRITER(rcu_state.srs_done_tail);
 
-	schedule_work(&rcu_state.srs_cleanup_work);
+	if (wait_tail->next)
+		schedule_work(&rcu_state.srs_cleanup_work);
 }
 
 /*
kernel/rcu/tree.h +6 -0
index b942b9437438..2832787cee1d 100644
@@ -315,6 +315,12 @@ do {									\
 	__set_current_state(TASK_RUNNING);				\
 } while (0)
 
+/*
+ * A max threshold for synchronize_rcu() users which are
+ * awaken directly by the rcu_gp_kthread(). Left part is
+ * deferred to the main worker.
+ */
+#define SR_MAX_USERS_WAKE_FROM_GP 5
 #define SR_NORMAL_GP_WAIT_HEAD_MAX 5
 
 struct sr_wait_node {
Signature · 1 line
2.39.2
author maintainer
#5 lore raw

PATCH v6 5/6 rcu: Do not release a wait-head from a GP kthread

In reply to Uladzislau Rezki (Sony)

Fix a below race by not releasing a wait-head from the GP-kthread as it can lead for reusing it whereas a worker can still access it thus execute newly added callbacks too early.

CPU 0 CPU 1
----- -----

// wait_tail == HEAD1

rcu_sr_normal_gp_cleanup() {
    // has passed SR_MAX_USERS_WAKE_FROM_GP
    wait_tail->next = next;
    // done_tail = HEAD1
    smp_store_release(&rcu_state.srs_done_tail, wait_tail);
    queue_work() {
        test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work)
        __queue_work()
    }
}
                               set_work_pool_and_clear_pending()
                               rcu_sr_normal_gp_cleanup_work() {
// new GP, wait_tail == HEAD2
rcu_sr_normal_gp_cleanup() {
    // executes all completion, but stop at HEAD1
    wait_tail->next = HEAD1;
    // done_tail = HEAD2
    smp_store_release(&rcu_state.srs_done_tail, wait_tail);
    queue_work() {
        test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work)
        __queue_work()
    }
}
                                 // done = HEAD2
                                 done = smp_load_acquire(&rcu_state.srs_done_tail);
                                 // head = HEAD1
                                 head = done->next;
                                 done->next = NULL;
                                 llist_for_each_safe() {
                                 // completes all callbacks, release HEAD1
                                 }
                               }
                               // Process second queue
                               set_work_pool_and_clear_pending()
                               rcu_sr_normal_gp_cleanup_work() {
                               // done = HEAD2
                               done = smp_load_acquire(&rcu_state.srs_done_tail);

// new GP, wait_tail == HEAD3

rcu_sr_normal_gp_cleanup() {
    // Finds HEAD2 with ->next == NULL at the end
    rcu_sr_put_wait_head(HEAD2)
    ...

// A few more GPs later

rcu_sr_normal_gp_init() {
     HEAD2 = rcu_sr_get_wait_head();
     llist_add(HEAD2, &rcu_state.srs_next);
                               // head == rcu_state.srs_next
                               head = done->next;
                               done->next = NULL;
                               llist_for_each_safe() {
                                // EXECUTE CALLBACKS TOO EARLY!!!
                                }
                               }
Fixes 05a10b921000 ("rcu: Support direct wake-up of synchronize_rcu() users")
---
 kernel/rcu/tree.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)
kernel/rcu/tree.c +8 -14
index 063200613444..d854115ff11f 100644
@@ -1684,21 +1684,11 @@ static void rcu_sr_normal_gp_cleanup(void)
 	WARN_ON_ONCE(!rcu_sr_is_wait_head(wait_tail));
 
 	/*
-	 * Process (a) and (d) cases. See an illustration. Apart of
-	 * that it handles the scenario when all clients are done,
-	 * wait-head is released if last. The worker is not kicked.
+	 * Process (a) and (d) cases. See an illustration.
 	 */
 	llist_for_each_safe(rcu, next, wait_tail->next) {
-		if (rcu_sr_is_wait_head(rcu)) {
-			if (!rcu->next) {
-				rcu_sr_put_wait_head(rcu);
-				wait_tail->next = NULL;
-			} else {
-				wait_tail->next = rcu;
-			}
-
+		if (rcu_sr_is_wait_head(rcu))
 			break;
-		}
 
 		rcu_sr_normal_complete(rcu);
 		// It can be last, update a next on this step.
@@ -1712,8 +1702,12 @@ static void rcu_sr_normal_gp_cleanup(void)
 	smp_store_release(&rcu_state.srs_done_tail, wait_tail);
 	ASSERT_EXCLUSIVE_WRITER(rcu_state.srs_done_tail);
 
-	if (wait_tail->next)
-		schedule_work(&rcu_state.srs_cleanup_work);
+	/*
+	 * We schedule a work in order to perform a final processing
+	 * of outstanding users(if still left) and releasing wait-heads
+	 * added by rcu_sr_normal_gp_init() call.
+	 */
+	schedule_work(&rcu_state.srs_cleanup_work);
 }
 
 /*
Signature · 1 line
2.39.2
author maintainer
#6 lore raw

PATCH v6 6/6 rcu: Allocate WQ with WQ_MEM_RECLAIM bit set

In reply to Uladzislau Rezki (Sony)

synchronize_rcu() users have to be processed regardless of memory pressure so our private WQ needs to have at least one execution context what WQ_MEM_RECLAIM flag guarantees.

---
 kernel/rcu/tree.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
kernel/rcu/tree.c +5 -1
index d854115ff11f..fe2e15c320dd 100644
@@ -1609,6 +1609,7 @@ static void rcu_sr_put_wait_head(struct llist_node *node)
 /* Disabled by default. */
 static int rcu_normal_wake_from_gp;
 module_param(rcu_normal_wake_from_gp, int, 0644);
+static struct workqueue_struct *sync_wq;
 
 static void rcu_sr_normal_complete(struct llist_node *node)
 {
@@ -1707,7 +1708,7 @@ static void rcu_sr_normal_gp_cleanup(void)
 	 * of outstanding users(if still left) and releasing wait-heads
 	 * added by rcu_sr_normal_gp_init() call.
 	 */
-	schedule_work(&rcu_state.srs_cleanup_work);
+	queue_work(sync_wq, &rcu_state.srs_cleanup_work);
 }
 
 /*
@@ -5609,6 +5610,9 @@ void __init rcu_init(void)
 	rcu_gp_wq = alloc_workqueue("rcu_gp", WQ_MEM_RECLAIM, 0);
 	WARN_ON(!rcu_gp_wq);
 
+	sync_wq = alloc_workqueue("sync_wq", WQ_MEM_RECLAIM, 0);
+	WARN_ON(!sync_wq);
+
 	/* Fill in default value for rcutree.qovld boot parameter. */
 	/* -After- the rcu_node ->lock fields are initialized! */
 	if (qovld < 0)
Signature · 1 line
2.39.2
maintainer Applied
#7 lore raw
In reply to Uladzislau Rezki (Sony)
Quoted 12 lines · Uladzislau Rezki (Sony)

This is v6. It is based on the Paul's "dev" branch:

HEAD: f1bfe538c7970283040a7188a291aca9f18f0c42

please note, that patches should be applied from scratch, i.e. the v5 has to be dropped from the "dev".

v5 -> v6:
- Fix a race due to realising a wait-head from the gp-kthread;
- Use our own private workqueue with WQ_MEM_RECLAIM to have at least one execution context.

Quoted 5 lines

v5: https://lore.kernel.org/lkml/[email protected]/
v4: https://lore.kernel.org/lkml/[email protected]/T/
v3: https://lore.kernel.org/lkml/cd45b0b5-f86b-43fb-a5f3-47d340cd4f9f@paulmck-laptop/T/
v2: https://lore.kernel.org/all/[email protected]/T/
v1: https://lore.kernel.org/lkml/[email protected]/T/

Queued in place of your earlier series, thank you!

Not urgent, but which rcutorture scenario should be pressed into service testing this?

Thanx, Paul

Quoted 18 lines

Uladzislau Rezki (Sony) (6):
rcu: Add data structures for synchronize_rcu()
rcu: Reduce synchronize_rcu() latency
rcu: Add a trace event for synchronize_rcu_normal()
rcu: Support direct wake-up of synchronize_rcu() users
rcu: Do not release a wait-head from a GP kthread
rcu: Allocate WQ with WQ_MEM_RECLAIM bit set

 .../admin-guide/kernel-parameters.txt         |  14 +
 include/trace/events/rcu.h                    |  27 ++
 kernel/rcu/tree.c                             | 361 +++++++++++++++++-
 kernel/rcu/tree.h                             |  20 +
 kernel/rcu/tree_exp.h                         |   2 +-
 5 files changed, 422 insertions(+), 2 deletions(-)
Signature · 1 line
2.39.2
author maintainer
#8 lore raw
Quoted 13 lines · Paul E. McKenney
Quoted 12 lines · Uladzislau Rezki (Sony)

This is v6. It is based on the Paul's "dev" branch:

HEAD: f1bfe538c7970283040a7188a291aca9f18f0c42

please note, that patches should be applied from scratch, i.e. the v5 has to be dropped from the "dev".

v5 -> v6:
- Fix a race due to realising a wait-head from the gp-kthread;
- Use our own private workqueue with WQ_MEM_RECLAIM to have at least one execution context.

Quoted 8 lines
Quoted 5 lines

v5: https://lore.kernel.org/lkml/[email protected]/
v4: https://lore.kernel.org/lkml/[email protected]/T/
v3: https://lore.kernel.org/lkml/cd45b0b5-f86b-43fb-a5f3-47d340cd4f9f@paulmck-laptop/T/
v2: https://lore.kernel.org/all/[email protected]/T/
v1: https://lore.kernel.org/lkml/[email protected]/T/

Queued in place of your earlier series, thank you!

Thank you!

Quoted 4 lines

Not urgent, but which rcutorture scenario should be pressed into service testing this?

I tested with setting '5*TREE01 5*TREE02 5*TREE03 5*TREE04' apart of that i used some private test cases. The rcutree.rcu_normal_wake_from_gp=1 has to be passed also.

Also, "rcuscale" can be used to stress the "cur_ops->sync()" path:

<snip>
#! /usr/bin/env bash

LOOPS=1

for (( i=0; i<$LOOPS; i++ )); do

        tools/testing/selftests/rcutorture/bin/kvm.sh --memory 10G --torture rcuscale \
    --allcpus \
      --kconfig CONFIG_NR_CPUS=64 \
      --kconfig CONFIG_RCU_NOCB_CPU=y \
      --kconfig CONFIG_RCU_NOCB_CPU_DEFAULT_ALL=y \
      --kconfig CONFIG_RCU_LAZY=n \
      --bootargs "rcuscale.nwriters=200 rcuscale.nreaders=220 rcuscale.minruntime=50000 \
                         torture.disable_onoff_at_boot rcutree.rcu_normal_wake_from_gp=1" --trust-make
        echo "Done $i"

done
<snip>

--
Uladzislau Rezki

maintainer
#9 lore raw
Quoted 49 lines · Uladzislau Rezki
Quoted 13 lines · Paul E. McKenney
Quoted 12 lines · Uladzislau Rezki (Sony)

This is v6. It is based on the Paul's "dev" branch:

HEAD: f1bfe538c7970283040a7188a291aca9f18f0c42

please note, that patches should be applied from scratch, i.e. the v5 has to be dropped from the "dev".

v5 -> v6:
- Fix a race due to realising a wait-head from the gp-kthread;
- Use our own private workqueue with WQ_MEM_RECLAIM to have at least one execution context.

Quoted 8 lines
Quoted 5 lines

v5: https://lore.kernel.org/lkml/[email protected]/
v4: https://lore.kernel.org/lkml/[email protected]/T/
v3: https://lore.kernel.org/lkml/cd45b0b5-f86b-43fb-a5f3-47d340cd4f9f@paulmck-laptop/T/
v2: https://lore.kernel.org/all/[email protected]/T/
v1: https://lore.kernel.org/lkml/[email protected]/T/

Queued in place of your earlier series, thank you!

Thank you!

Quoted 4 lines

Not urgent, but which rcutorture scenario should be pressed into service testing this?

I tested with setting '5*TREE01 5*TREE02 5*TREE03 5*TREE04' apart of that i used some private test cases. The rcutree.rcu_normal_wake_from_gp=1 has to be passed also.

Also, "rcuscale" can be used to stress the "cur_ops->sync()" path:

<snip>
#! /usr/bin/env bash

LOOPS=1

for (( i=0; i<$LOOPS; i++ )); do

        tools/testing/selftests/rcutorture/bin/kvm.sh --memory 10G --torture rcuscale \
    --allcpus \
      --kconfig CONFIG_NR_CPUS=64 \
      --kconfig CONFIG_RCU_NOCB_CPU=y \
      --kconfig CONFIG_RCU_NOCB_CPU_DEFAULT_ALL=y \
      --kconfig CONFIG_RCU_LAZY=n \
      --bootargs "rcuscale.nwriters=200 rcuscale.nreaders=220 rcuscale.minruntime=50000 \
                         torture.disable_onoff_at_boot rcutree.rcu_normal_wake_from_gp=1" --trust-make
        echo "Done $i"
Quoted 2 lines

done
<snip>

Very good, thank you!

Of those five options (TREE01, TREE02, TREE03, TREE04, and rcuscale), which one should be changed so that my own testing automatically covers the rcutree.rcu_normal_wake_from_gp=1 case? I would guess that we should leave out TREE03, since it covers tall rcu_node trees. TREE01 looks closest to the ChromeOS/Android use case, but you tell me!

And it might be time to rework the test cases to better align with the use cases. For example, I created TREE10 to cover Meta's fleet. But ChromeOS and Android have relatively small numbers of CPUs, so it should be possible to rework things a bit to make one of the existing tests cover that case, while modifying other tests to take up any situations that these changes exclude.

Thoughts?

Thanx, Paul