Linux Trace Kernel
 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: [RFC PATCH 15/16] selftests/membarrier: Check the memory barriers of each thread
Date: Fri, 13 Nov 2026 09:37:32 -0500	[thread overview]
Message-ID: <9b274b15-7b4d-4611-b894-d1651b99c490@efficios.com> (raw)
In-Reply-To: <sashiko-outbox-212919@kernel.org>

> [Severity: Medium]
> Does setting setup_broken = true before bpf_object__load() and
> bpf_program__attach() cause main() to fail instead of skipping when the
> kernel lacks required BPF features?
>
> A kernel with CONFIG_DEBUG_INFO_BTF=y and CONFIG_PROC_KCORE=y can still
> lack CONFIG_BPF_EVENTS=y (needed to load kprobe/tracing programs and
> BPF_MAP_TYPE_TASK_STORAGE) or have BPF JIT disabled (needed to attach
> tp_btf/sched_switch).

Yes for CONFIG_BPF_EVENTS. The same holds for CONFIG_KPROBE_EVENTS,
which the kprobes of the test need. The test should skip in both cases.

The BPF JIT is not needed. The sched_switch program is attached as a raw
tracepoint, which does not use a BPF trampoline. I built a kernel
without CONFIG_BPF_JIT: the test attaches and all 13 test cases pass.

Planned fix for the next round: bpf_setup() checks both options before
it treats an error as a failure. It probes the kprobe program type with
libbpf_probe_bpf_prog_type(), and it looks for the kprobe PMU in sysfs.
I tested this on a kernel without each option: the test is skipped.

> [Severity: Medium]
> Does calling pin_to_cpu(target->cpu) before map_counters() miss the
> lazy-TLB context switch in global_expedited_lazy_tlb?

[...]

> As a result, sched_switch never sets OWES_BARRIER or increments
> MBT_SCHED_IN for that lazy-TLB switch.  Calling map_counters() before
> pin_to_cpu(target->cpu) registers the thread in task_slot before it
> migrates back to cpus[1].

Yes. The target moves back to its CPU before it has a counter slot. The
BPF program does not see that switch, so the barrier which the scheduler
owes the target there is not checked.

The checks of each call start after the registration, so they are not
affected. Without the fix of patch 1, the test case still fails.

Planned fix for the next round: run_target() calls map_counters() before
pin_to_cpu().

> [Severity: Low]
> Can zeroing shared->next_slot in reset_shared() let an exiting task from a
> finished test case clobber the BPF counters of a new thread in the next
> test case?

[...]

> Preserving shared->next_slot across reset_shared() avoids reusing counter
> slots across test cases.

Yes, this window exists. I did not reproduce it.

Planned fix for the next round: reset_shared() keeps next_slot. The 13
test cases use about 270 of the 512 slots at most.

Thanks,

Mathieu


-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com

  reply	other threads:[~2026-11-13 14:37 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 13:18 [RFC PATCH 00/16] membarrier: fixes, selftests and documentation Mathieu Desnoyers
2026-11-13 13:18 ` [RFC PATCH 01/16] sched/membarrier: Fix stale runqueue state after a lazy mm switch Mathieu Desnoyers
2026-11-13 13:18 ` [RFC PATCH 02/16] sched/membarrier: Report only completed registrations Mathieu Desnoyers
2026-11-13 13:18 ` [RFC PATCH 03/16] selftests/membarrier: Rebuild the tests when their header changes Mathieu Desnoyers
2026-11-13 13:18 ` [RFC PATCH 04/16] selftests/membarrier: Issue the sync core command in its test Mathieu Desnoyers
2026-11-13 13:18 ` [RFC PATCH 05/16] selftests/membarrier: Run the tests on nohz_full kernels Mathieu Desnoyers
2026-11-13 13:18 ` [RFC PATCH 06/16] selftests/membarrier: Test which CPUs the expedited commands interrupt Mathieu Desnoyers
2026-11-13 13:18 ` [RFC PATCH 07/16] selftests/membarrier: Test command arguments and registration lifetime Mathieu Desnoyers
2026-11-13 13:18 ` [RFC PATCH 08/16] LoongArch: membarrier: Add full memory barrier in switch_mm() Mathieu Desnoyers
2026-11-13 13:18 ` [RFC PATCH 09/16] parisc: " Mathieu Desnoyers
2026-11-13 13:18 ` [RFC PATCH 10/16] Documentation/membarrier: Update the per-architecture barrier list Mathieu Desnoyers
2026-11-13 13:18 ` [RFC PATCH 11/16] Documentation/features: Update the membarrier sync core requirements Mathieu Desnoyers
2026-11-13 13:18 ` [RFC PATCH 12/16] x86/entry: Remove stale membarrier sync core comments Mathieu Desnoyers
2026-11-13 13:19 ` [RFC PATCH 13/16] selftests/membarrier: Add litmus tests of the memory ordering Mathieu Desnoyers
2026-11-13 13:19 ` [RFC PATCH 14/16] MAINTAINERS: Add the membarrier selftests to MEMBARRIER SUPPORT Mathieu Desnoyers
2026-11-13 13:19 ` [RFC PATCH 15/16] selftests/membarrier: Check the memory barriers of each thread Mathieu Desnoyers
2026-11-13 13:46   ` sashiko-bot
2026-11-13 14:37     ` Mathieu Desnoyers [this message]
2026-11-13 13:19 ` [RFC PATCH 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=9b274b15-7b4d-4611-b894-d1651b99c490@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