[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250813083244.GL4067720@noisy.programming.kicks-ass.net>
Date: Wed, 13 Aug 2025 10:32:44 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
Cc: tglx@...utronix.de, linux-kernel@...r.kernel.org,
torvalds@...uxfoundation.org, mingo@...nel.org, namhyung@...nel.org,
acme@...hat.com, kees@...nel.org
Subject: Re: [PATCH v3 13/15] perf: Use scoped_guard() for mmap_mutex in
perf_mmap()
On Wed, Aug 13, 2025 at 07:42:41AM +0100, Lorenzo Stoakes wrote:
> > + scoped_guard (mutex, &event->mmap_mutex) {
> > + /*
> > + * This relies on __pmu_detach_event() taking mmap_mutex after marking
> > + * the event REVOKED. Either we observe the state, or __pmu_detach_event()
> > + * will detach the rb created here.
> > + */
> > + if (event->state <= PERF_EVENT_STATE_REVOKED) {
> > + ret = -ENODEV;
> > + break;
>
> I don't absolutely love this break-for-what-is-not-obviously-a-for-loop
> formulation (I know scoped_guard in practice _is_ a for loop, but obviously
> that's hidden by macro), but I guess hey it's C, and we have to do what we
> have to do :)
Right, don't love it either, but the alternative was a goto and that's
arguably worse, so meh.
> > + }
> >
> > + if (vma->vm_pgoff == 0)
> > + ret = perf_mmap_rb(vma, event, nr_pages);
> > + else
> > + ret = perf_mmap_aux(vma, event, nr_pages);
> > }
> >
> > if (ret)
> > return ret;
> >
> >
> >
Powered by blists - more mailing lists