BPF List
 help / color / mirror / Atom feed
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

  reply	other threads:[~2026-11-27 19:27 UTC|newest]

Thread overview: 5+ 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 ` [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 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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox