diff options
| author | Paul E. McKenney <paulmck@kernel.org> | 2026-06-02 13:15:37 -0700 |
|---|---|---|
| committer | Paul E. McKenney <paulmck@kernel.org> | 2026-07-23 10:00:26 -0700 |
| commit | 8f30a8a9044cd08e01e13be7b5d2b8a97d1832f6 (patch) | |
| tree | 88b9e8a256383f18d621fcb636ccefa0e5416d4e | |
| parent | 488445203f1688ed14d5bc621398137c49bea414 (diff) | |
| download | linux-next-8f30a8a9044cd08e01e13be7b5d2b8a97d1832f6.tar.gz linux-next-8f30a8a9044cd08e01e13be7b5d2b8a97d1832f6.zip | |
hazptrtorture: Split hazptr_torture_reader_tail() from hazptr_torture_reader()
This commit splits a new hazptr_torture_reader_tail() function out
of hazptr_torture_reader(). This will allow hazptr_torture_reader()
to pass hazard pointers off to other tasks and to various types of
handlers, and those hazard pointers can in turn be passed to this new
hazptr_torture_reader_tail() function to complete processing.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Boqun Feng <boqun@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: <rcu@vger.kernel.org>
Cc: <lkmm@lists.linux.dev>
| -rw-r--r-- | kernel/rcu/hazptrtorture.c | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/kernel/rcu/hazptrtorture.c b/kernel/rcu/hazptrtorture.c index c0ebabdcc72e..8672169f7868 100644 --- a/kernel/rcu/hazptrtorture.c +++ b/kernel/rcu/hazptrtorture.c @@ -352,6 +352,31 @@ hazptr_torture_writer(void *arg) } /* + * Do the delay, the accounting, and the release. This in intended to + * be invoked from hazptr_torture_reader, but also for hazard pointers + * sent off to interrupt handlers and the like. + */ +static void hazptr_torture_reader_tail(struct hazptr_ctx *hcp, struct hazptr_torture *htp, + struct torture_random_state *trsp) +{ + int pipe_count; + + cur_ops->read_delay(trsp); + preempt_disable(); + pipe_count = READ_ONCE(htp->htort_pipe_count); + if (pipe_count > HAZPTR_TORTURE_PIPE_LEN) { + // Should not happen in a correct hazptr implementation, + // happens quite often for TBD torture_type=busted. + pipe_count = HAZPTR_TORTURE_PIPE_LEN; + } + if (pipe_count > 1) + rcu_ftrace_dump(DUMP_ALL); + __this_cpu_inc(hazptr_torture_count[pipe_count]); + preempt_enable(); + cur_ops->readunlock(hcp, htp); +} + +/* * Hazard-pointer torture reader kthread. Repeatedly dereferences * hazptr_torture_current, incrementing the corresponding element of the * pipeline array. The counter in the element should never be greater @@ -365,7 +390,6 @@ static int hazptr_torture_reader(void *arg) unsigned long lastsleep = jiffies; long myid = (long)arg; int mynumonline = myid % nr_cpu_ids; - int pipe_count; DEFINE_TORTURE_RANDOM(rand); VERBOSE_TOROUT_STRING("hazptr_torture_reader task started"); @@ -373,6 +397,8 @@ static int hazptr_torture_reader(void *arg) do { htp = cur_ops->readlock(&hcp); if (!htp) { + // Still starting up or allocation failure, + // so get out of the way. schedule_timeout_interruptible(HZ / 10); continue; } @@ -380,19 +406,7 @@ static int hazptr_torture_reader(void *arg) torture_hrtimeout_us(500, 1000, &rand); lastsleep = jiffies + 10; } - cur_ops->read_delay(&rand); - preempt_disable(); - pipe_count = READ_ONCE(htp->htort_pipe_count); - if (pipe_count > HAZPTR_TORTURE_PIPE_LEN) { - // Should not happen in a correct RCU implementation, - // happens quite often for torture_type=busted. - pipe_count = HAZPTR_TORTURE_PIPE_LEN; - } - if (pipe_count > 1) - rcu_ftrace_dump(DUMP_ALL); - __this_cpu_inc(hazptr_torture_count[pipe_count]); - preempt_enable(); - cur_ops->readunlock(hcp, htp); + hazptr_torture_reader_tail(hcp, htp, &rand); while (!torture_must_stop() && (torture_num_online_cpus() < mynumonline || !rcu_inkernel_boot_has_ended())) schedule_timeout_interruptible(HZ / 5); |
