From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: sashiko-reviews@lists.linux.dev
Cc: bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v2 15/16] selftests/membarrier: Check the memory barriers of each thread
Date: Fri, 27 Nov 2026 14:27:17 -0500 [thread overview]
Message-ID: <51c3bb03-c712-4982-9d02-e21206c7ece9@efficios.com> (raw)
In-Reply-To: <sashiko-outbox-238151@kernel.org>
> [Severity: Medium]
> Can run_target() read MBT_SCHED_IN_MISSED before the target thread has
> scheduled out to flush state->owed?
[...]
> If the child is not preempted during that round, the schedule-out on
> cpus[1] only happens at _exit(0) after run_target() has already recorded
> stats->sched_in_missed, so a missing scheduler barrier on that switch-in
> will go undetected.
Yes. The BPF program counts a missed barrier only when the CPU leaves
the thread. So the last switch-in of a target is never checked. This
holds for every test case, not only for the lazy TLB one.
I checked it with a variant of the test which does not probe the
barriers of a switch-in. Each switch-in then counts as a missed
barrier. global_expedited_lazy_tlb ran about 47 rounds. Before the fix,
it counted 48 missed barriers. After the fix, it counted 95, so one more
per round.
Planned fix for the next round: run_target() waits until the CPU leaves
the target before it reads MBT_SCHED_IN_MISSED. It sleeps until the BPF
program has counted a schedule-out.
> Also, sampling first_sched_in after pin_to_cpu(target->cpu) subtracts out
> the MBT_SCHED_IN increment from that initial migration onto target->cpu
> when computing stats->sched_in. Should first_sched_in be read before
> pin_to_cpu(), and should run_target() force a schedule-out (e.g. via
> sched_yield() or migrating off target->cpu) before reading
> MBT_SCHED_IN_MISSED?
No change planned for first_sched_in. Only EXPECT_NO_IPI uses
stats->sched_in. It allows one IPI for each switch-in, and run_target()
starts counting both at the same point. The switch-in onto target->cpu
happens before the caller starts, so no IPI can follow it.
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
next prev parent reply other threads:[~2026-11-27 19:27 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 18:58 [PATCH v2 00/16] membarrier: fixes, selftests and documentation Mathieu Desnoyers
2026-11-27 18:58 ` Mathieu Desnoyers
2026-11-27 18:58 ` [PATCH v2 01/16] sched/membarrier: Fix stale runqueue state after a lazy mm switch Mathieu Desnoyers
2026-11-27 18:58 ` [PATCH v2 02/16] sched/membarrier: Report only completed registrations Mathieu Desnoyers
2026-11-27 18:58 ` [PATCH v2 03/16] selftests/membarrier: Rebuild the tests when their header changes Mathieu Desnoyers
2026-11-27 18:58 ` [PATCH v2 04/16] selftests/membarrier: Issue the sync core command in its test Mathieu Desnoyers
2026-11-27 18:58 ` [PATCH v2 05/16] selftests/membarrier: Run the tests on nohz_full kernels Mathieu Desnoyers
2026-11-27 18:58 ` [PATCH v2 06/16] selftests/membarrier: Test which CPUs the expedited commands interrupt Mathieu Desnoyers
2026-11-27 18:58 ` [PATCH v2 07/16] selftests/membarrier: Test command arguments and registration lifetime Mathieu Desnoyers
2026-11-27 18:58 ` [PATCH v2 08/16] LoongArch: membarrier: Add full memory barrier in switch_mm() Mathieu Desnoyers
2026-11-29 4:00 ` Huacai Chen
2026-11-27 18:58 ` [PATCH v2 09/16] parisc: " Mathieu Desnoyers
2026-11-27 18:58 ` [PATCH v2 10/16] Documentation/membarrier: Update the per-architecture barrier list Mathieu Desnoyers
2026-11-27 18:58 ` Mathieu Desnoyers
2026-11-27 18:58 ` [PATCH v2 11/16] Documentation/features: Update the membarrier sync core requirements Mathieu Desnoyers
2026-11-27 18:58 ` [PATCH v2 12/16] x86/entry: Remove stale membarrier sync core comments Mathieu Desnoyers
2026-11-27 18:58 ` [PATCH v2 13/16] selftests/membarrier: Add litmus tests of the memory ordering Mathieu Desnoyers
2026-11-27 18:58 ` [PATCH v2 14/16] MAINTAINERS: Add the membarrier selftests to MEMBARRIER SUPPORT Mathieu Desnoyers
2026-11-27 18:58 ` [PATCH v2 15/16] selftests/membarrier: Check the memory barriers of each thread Mathieu Desnoyers
2026-11-27 19:15 ` sashiko-bot
2026-11-27 19:27 ` Mathieu Desnoyers [this message]
2026-11-27 23:45 ` Alexei Starovoitov
2026-11-27 18:58 ` [PATCH v2 16/16] selftests/membarrier: Check the core serialization of the sync core command 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=51c3bb03-c712-4982-9d02-e21206c7ece9@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=bpf@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.