From: sashiko-bot@kernel.org
To: "Jaidev Shastri" <jaidevshastri@vt.edu>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 3/3] perf/core: publish perf_event_cache with release semantics
Date: Tue, 22 Sep 2026 01:24:08 +0000 [thread overview]
Message-ID: <20260922012409.4DD601F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260921-mb-perf-core-v1-3-ac56a719c02b@vt.edu>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] perf: unnecessary and inconsistent memory barriers for boot-initialized variable
--
commit 502c74ee5072b4297e79a78cf708d77e31d6b0e5
Author: Jaidev Shastri <jaidevshastri@vt.edu>
Subject: perf/core: publish perf_event_cache with release semantics
This patch replaces plain reads and writes of perf_event_cache with
smp_store_release() and smp_load_acquire() to address a static checker
warning about memory consistency.
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 3b5c592630e17..74cfb13fec7c0 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -5313,7 +5313,8 @@ static void free_event_rcu(struct rcu_head *head)
> put_pid_ns(event->ns);
> perf_event_free_filter(event);
> kfree(event->addr_filter_ranges);
> - kmem_cache_free(perf_event_cache, event);
> + /* Pairs with the smp_store_release() in perf_event_init(). */
> + kmem_cache_free(smp_load_acquire(&perf_event_cache), event);
[Severity: Low]
Is this acquire barrier necessary? Since perf_event_cache is initialized
synchronously during early kernel boot, it should already be causally
guaranteed to be fully visible across all CPUs by the time any tasks are
spawned to interact with it.
Additionally, if a memory barrier were required to prevent data races, is
it problematic that the allocation path still uses a plain load?
kernel/events/core.c:perf_event_alloc() {
...
event = kmem_cache_alloc_node(perf_event_cache, GFP_KERNEL | __GFP_ZERO, node);
...
}
[ ... ]
> @@ -15404,7 +15405,8 @@ void __init perf_event_init(void)
> ret = init_hw_breakpoint();
> WARN(ret, "hw_breakpoint initialization failed with: %d", ret);
>
> - perf_event_cache = KMEM_CACHE(perf_event, SLAB_PANIC);
> + /* Pairs with the smp_load_acquire() in free_event_rcu(). */
> + smp_store_release(&perf_event_cache, KMEM_CACHE(perf_event, SLAB_PANIC));
[Severity: Low]
Since perf_event_init() is an __init function that runs synchronously during
early system boot before tasks could potentially allocate or free perf events,
does this require a release barrier?
Instead of adding synchronization overhead to silence the static checker,
would it be more appropriate to annotate the declaration of perf_event_cache
with __ro_after_init? This documents the initialization phase ordering and
safely silences static checkers while avoiding unnecessary code complexity.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260921-mb-perf-core-v1-0-ac56a719c02b@vt.edu?part=3
prev parent reply other threads:[~2026-09-22 1:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 1:13 [PATCH 0/3] perf/core: order three publications against their readers Jaidev Shastri via B4 Relay
2026-09-22 1:13 ` [PATCH 1/3] perf/core: publish the aux_event link with release semantics Jaidev Shastri via B4 Relay
2026-09-22 1:24 ` sashiko-bot
2026-09-22 1:13 ` [PATCH 2/3] perf/core: install the guest callbacks before the guest_state gate Jaidev Shastri via B4 Relay
2026-09-22 1:25 ` sashiko-bot
2026-09-22 1:13 ` [PATCH 3/3] perf/core: publish perf_event_cache with release semantics Jaidev Shastri via B4 Relay
2026-09-22 1:24 ` sashiko-bot [this message]
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=20260922012409.4DD601F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=jaidevshastri@vt.edu \
--cc=linux-perf-users@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