[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <cf3021f1-b4a4-4969-87c1-cf2580d58b33@lucifer.local>
Date: Mon, 11 Aug 2025 15:10:34 +0100
From: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: LKML <linux-kernel@...r.kernel.org>,
Linus Torvalds <torvalds@...uxfoundation.org>,
Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Kees Cook <kees@...nel.org>
Subject: Re: [patch V2 RESEND 5/6] perf/core: Split the ringbuffer mmap() and
allocation code out
> On Mon, Aug 11, 2025 at 02:36:37PM +0200, Thomas Gleixner wrote:
> > ---
> > kernel/events/core.c | 176 ++++++++++++++++++++++-----------------------------
> > 1 file changed, 78 insertions(+), 98 deletions(-)
> >
> > --- a/kernel/events/core.c
> > +++ b/kernel/events/core.c
> > @@ -6970,6 +6970,70 @@ static void perf_mmap_account(struct vm_
> > atomic64_add(extra, &vma->vm_mm->pinned_vm);
> > }
> >
> > +static int perf_mmap_rb(struct vm_area_struct *vma, struct perf_event *event,
> > + unsigned long nr_pages)
> > +{
> > + long user_extra = nr_pages, extra = 0;
> > + struct perf_buffer *rb = event->rb;
> > + int rb_flags = 0;
...
> > + perf_mmap_account(vma, user_extra, extra);
> > + atomic_set(&event->mmap_count, 1);
OK so just one question - here we move from an atomic_inc() below, to an
atomic_set() here, which resolves the issue we saw before with use of
refcounts.
Is it definitely safe to do so and not breaking some expectation that this
might somehow be raced by something?
Thanks!
> > + return 0;
> > +}
> > +
> > /*
> > * Don't allow mmap() of inherited per-task counters. This would
> > @@ -7071,114 +7133,32 @@ static int perf_mmap(struct file *file,
> > if (vma_size != PAGE_SIZE * nr_pages)
> > return -EINVAL;
> >
...
> > -unlock:
> > - if (!ret) {
> > - perf_mmap_account(vma, user_extra, extra);
> > - atomic_inc(&event->mmap_count);
> > }
Powered by blists - more mailing lists