From: Peter Zijlstra <peterz@infradead.org>
To: Will Rosenberg <whrosenb@asu.edu>
Cc: yi1.lai@linux.intel.com, Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Thomas Gleixner <tglx@linutronix.de>,
"open list:PERFORMANCE EVENTS SUBSYSTEM"
<linux-perf-users@vger.kernel.org>,
"open list:PERFORMANCE EVENTS SUBSYSTEM"
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 RESEND] perf: Fix refcount warning on event->mmap_count increment
Date: Tue, 20 Jan 2026 13:23:50 +0100 [thread overview]
Message-ID: <20260120122350.GK831050@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20260119184956.801238-1-whrosenb@asu.edu>
On Mon, Jan 19, 2026 at 11:49:56AM -0700, Will Rosenberg wrote:
>
> Notes:
> v2 -> v3: Update patch to error out instead of incrementing.
>
> Thank you, this is a much better solution. I was not thinking
> that the mmap itself was unintended.
>
> I believe you are missing a "!" in your patch. After adding
> that, I tested the patch, and it fixed the bug.
D'0h indeed. Sometimes typing is so very hard ;-)
> I also wanted to check my understanding of the race with
> perf_mmap_close() to double check this patch will not cause
> an issue. perf_mmap_rb() should always hold the
> event->mmap_mutex, so there should be no race on
> event->mmap_count with perf_mmap_close()'s
> refcount_dec_and_mutex_lock(). If there was a race, we would
> risk returning -EBUSY when we should "continue as if !event->rb."
Since we're failing perf_mmap_rb(), it won't call ->close(), right?
Also, we already have an error path on data_page_nr() mismatch.
The caller of perf_mmap_rb() has if (ret) return ret; nothing is
modified before calling perf_mmap_rb() and perf_mmap_rb() itself hasn't
modified anytyhing yet at the point of failure.
So afaict we're good.
Anyway, thanks for the patch, I'll get it applied!
prev parent reply other threads:[~2026-01-20 12:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-29 21:03 [PATCH] perf: Fix refcount warning on event->mmap_count increment Will Rosenberg
2026-01-05 8:47 ` Lai, Yi
2026-01-05 16:51 ` [PATCH v2] " Will Rosenberg
2026-01-06 9:34 ` Peter Zijlstra
2026-01-06 20:35 ` [PATCH v3] " Will Rosenberg
2026-01-19 18:49 ` [PATCH v3 RESEND] " Will Rosenberg
2026-01-20 12:23 ` Peter Zijlstra [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=20260120122350.GK831050@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=tglx@linutronix.de \
--cc=whrosenb@asu.edu \
--cc=yi1.lai@linux.intel.com \
/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