From: Peter Zijlstra Date: Tue, 12 Aug 2025 10:39:12 +0000 (+0200) Subject: perf: Identify the 0->1 transition for event::mmap_count X-Git-Tag: v6.18-rc1~196^2~43 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=59741451b49ce9964a9758c19d6f7df2a1255c75;p=thirdparty%2Fkernel%2Fstable.git perf: Identify the 0->1 transition for event::mmap_count Needed because refcount_inc() doesn't allow the 0->1 transition. Specifically, this is the case where we've created the RB, this means there was no RB, and as such there could not have been an mmap. Additionally we hold mmap_mutex to serialize everything. This must be the first. Suggested-by: Thomas Gleixner Signed-off-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/20250812104019.956479989@infradead.org --- diff --git a/kernel/events/core.c b/kernel/events/core.c index 41941dfadfcbc..f6211ab185036 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -7034,7 +7034,7 @@ static int perf_mmap_rb(struct vm_area_struct *vma, struct perf_event *event, perf_event_update_userpage(event); perf_mmap_account(vma, user_extra, extra); - atomic_inc(&event->mmap_count); + atomic_set(&event->mmap_count, 1); return 0; }