[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <67684870-bd46-43bf-9d3e-efa9f4074ad4@lucifer.local>
Date: Wed, 13 Aug 2025 09:52:00 +0100
From: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
To: Peter Zijlstra <peterz@...radead.org>
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 10:44:48AM +0200, Peter Zijlstra wrote:
> On Wed, Aug 13, 2025 at 10:32:44AM +0200, Peter Zijlstra wrote:
> > 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;
> > > >
>
> Nah, I'm an idiot.. How's this?
Right yeah, you could just return instead of break :))
Powered by blists - more mailing lists