From: sashiko-bot@kernel.org
To: "Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
tglx@kernel.org, peterz@infradead.org
Cc: mingo@redhat.com, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
vschneid@redhat.com, kprateek.nayak@amd.com, paulmck@kernel.org,
boqun@kernel.org, shuah@kernel.org, kees@kernel.org,
viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz,
oleg@redhat.com, bestswngs@gmail.com, xmei5@asu.edu,
xujiakai24@mails.ucas.ac.cn, linux-mm@kvack.org
Subject: Re: [PATCH 14/17] selftests/rseq: Test the concurrency IDs after the affinity is widened
Date: Wed, 18 Nov 2026 16:17:39 +0000 [thread overview]
Message-ID: <sashiko-outbox-221457@kernel.org> (raw)
In-Reply-To: <05781fc46cb63b548588e58b356ab08b10619aac.1794932121.git.mathieu.desnoyers@efficios.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] selftests/rseq: missing release-acquire ordering on epoch in
measure()
--
commit c93d413e090ede336a58daf34cc339f9241ae7d4
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
selftests/rseq: Test the concurrency IDs after the affinity is widened
This commit adds a test case to mm_cid_bound_test that starts three
threads on two CPUs and then widens their CPU affinity to all CPUs to test
whether concurrency IDs are reassigned back to per-task mode.
> diff --git a/tools/testing/selftests/rseq/mm_cid_bound_test.c b/tools/testing/selftests/rseq/mm_cid_bound_test.c
> index 11332b9ff24b8..a751d89291380 100644
> --- a/tools/testing/selftests/rseq/mm_cid_bound_test.c
> +++ b/tools/testing/selftests/rseq/mm_cid_bound_test.c
[ ... ]
> @@ -228,6 +237,49 @@ static int run_child(const int *steps, int nr_steps)
> return ret;
> }
>
> +/*
> + * The process under test of the widening case. It starts on two CPUs.
> + * Return a mask of the OVER_* values.
> + */
> +static int run_child_widen(void)
> +{
> + int nr_workers = 0, ret = 0, cpu, err;
> + unsigned int cid;
> +
> + if (sched_getaffinity(0, sizeof(allowed), &allowed))
> + return CHILD_ERROR;
> + nr_allowed = CPU_COUNT(&allowed);
> +
> + err = set_workers(&nr_workers, WIDEN_THREADS - 1);
> + if (err)
> + return CHILD_ERROR;
> + measure(nr_workers, &cpu);
> + cid = measure(nr_workers, &cpu);
> + ksft_print_msg("%4d threads on %d CPUs: largest mm_cid %u on CPU %d\n",
> + WIDEN_THREADS, nr_allowed, cid, cpu);
> +
> + /* Each thread widens its own affinity at the end of its next tour. */
> + allowed = all_cpus;
> + nr_allowed = CPU_COUNT(&allowed);
> + if (sched_setaffinity(0, sizeof(allowed), &allowed))
> + ret |= CHILD_ERROR;
> + measure(nr_workers, &cpu);
[Severity: Low]
Can the worker threads still observe the old 2-CPU allowed mask in tour()
when measure() wakes them here?
Previously, allowed was only written before pthread_create() spawned the
workers. Here run_child_widen() updates allowed while workers are already
spinning in worker_fn(), but measure() and worker_fn() synchronize on
epoch with plain volatile accesses rather than release-acquire ordering:
tools/testing/selftests/rseq/mm_cid_bound_test.c:worker_fn() {
while (!RSEQ_READ_ONCE(w->stop)) {
unsigned int e = RSEQ_READ_ONCE(epoch);
if (e == seen) {
usleep(200);
continue;
}
tour(w);
...
}
tools/testing/selftests/rseq/mm_cid_bound_test.c:measure() {
...
RSEQ_WRITE_ONCE(epoch, e);
tour(&self);
...
}
CPU0 CPU1
run_child_widen() worker_fn()
allowed = all_cpus;
measure()
RSEQ_WRITE_ONCE(epoch, e);
e = RSEQ_READ_ONCE(epoch);
tour()
CPU_ISSET(cpu, &allowed)
sched_setaffinity(..., &allowed)
<-- reads stale 2-CPU allowed
Without rseq_smp_store_release(&epoch, e) in measure() paired with
rseq_smp_load_acquire(&epoch) in worker_fn(), either the compiler or a
weakly-ordered CPU can reorder the non-volatile reads of allowed in tour()
ahead of the load of epoch, leaving the workers pinned to the initial two
CPUs during the widening tour.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1794932121.git.mathieu.desnoyers@efficios.com?part=14
next prev parent reply other threads:[~2026-11-18 16:17 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 16:17 [PATCH 00/17] sched/mmcid: fixes for execve, mode switches and affinity Mathieu Desnoyers
2026-11-17 16:17 ` [PATCH 01/17] sched/mmcid: Give a CID to a task that joins its mm while running Mathieu Desnoyers
2026-11-17 16:17 ` [PATCH 02/17] sched/mmcid: Give no concurrency ID to user workers Mathieu Desnoyers
2026-11-18 16:17 ` sashiko-bot
2026-11-18 20:39 ` Mathieu Desnoyers
2026-11-17 16:17 ` [PATCH 03/17] sched/mmcid: Reset stale state when the first user joins an mm Mathieu Desnoyers
2026-11-17 16:17 ` [PATCH 04/17] sched/mmcid: Let a running joiner take its CID after the fixups Mathieu Desnoyers
2026-11-17 16:17 ` [PATCH 05/17] sched/mmcid: Take the allowed CPUs of the first user when it joins Mathieu Desnoyers
2026-11-17 16:17 ` [PATCH 06/17] sched/mmcid: Synchronize MM teardown with affinity updates Mathieu Desnoyers
2026-11-17 16:17 ` [PATCH 07/17] selftests/rseq: Test the concurrency ID after a failed execve Mathieu Desnoyers
2026-11-17 16:17 ` [PATCH 08/17] selftests/rseq: Test the concurrency ID after the last user fails execve Mathieu Desnoyers
2026-11-17 16:17 ` [PATCH 09/17] selftests/rseq: Test the concurrency IDs across ownership mode switches Mathieu Desnoyers
2026-11-17 16:17 ` [PATCH 10/17] selftests/rseq: Test the upper bound of the concurrency IDs Mathieu Desnoyers
2026-11-17 16:17 ` [PATCH 11/17] selftests/rseq: Test affinity changes made by another process Mathieu Desnoyers
2026-11-17 16:17 ` [PATCH 12/17] selftests/rseq: Test an affinity change by another process during execve Mathieu Desnoyers
2026-11-17 16:17 ` [PATCH 13/17] selftests/rseq: Test concurrent thread creation and forced migration Mathieu Desnoyers
2026-11-17 16:17 ` [PATCH 14/17] selftests/rseq: Test the concurrency IDs after the affinity is widened Mathieu Desnoyers
2026-11-18 16:17 ` sashiko-bot [this message]
2026-11-18 20:39 ` Mathieu Desnoyers
2026-11-17 16:17 ` [PATCH 15/17] selftests/rseq: Test two race windows of the concurrency ID mode switches Mathieu Desnoyers
2026-11-17 16:17 ` [PATCH 16/17] selftests/rseq: Test affinity changes while a task replaces or drops its mm Mathieu Desnoyers
2026-11-18 16:17 ` sashiko-bot
2026-11-18 20:40 ` Mathieu Desnoyers
2026-11-17 16:17 ` [PATCH 17/17] selftests/rseq: Test the last user after an affinity change during execve Mathieu Desnoyers
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=sashiko-outbox-221457@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bestswngs@gmail.com \
--cc=boqun@kernel.org \
--cc=brauner@kernel.org \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=jack@suse.cz \
--cc=juri.lelli@redhat.com \
--cc=kees@kernel.org \
--cc=kprateek.nayak@amd.com \
--cc=linux-mm@kvack.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shuah@kernel.org \
--cc=tglx@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=viro@zeniv.linux.org.uk \
--cc=vschneid@redhat.com \
--cc=xmei5@asu.edu \
--cc=xujiakai24@mails.ucas.ac.cn \
/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.