From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
Linus Torvalds <torvalds@linuxfoundation.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Kees Cook <kees@kernel.org>
Subject: Re: [patch V2 RESEND 3/6] perf/core: Split out VM accounting
Date: Mon, 11 Aug 2025 13:58:24 +0100 [thread overview]
Message-ID: <3be7fd83-e209-49ec-8d81-ba6a60d4da94@lucifer.local> (raw)
In-Reply-To: <20250811123609.603671567@linutronix.de>
On Mon, Aug 11, 2025 at 02:36:33PM +0200, Thomas Gleixner wrote:
> Similary to the mlock limit calculation the VM accounting is required for
NIT: Similary -> similarly
> both the ringbuffer and the AUX buffer allocations.
>
> To prepare for splitting them out into seperate functions, move the
NIT: seperate -> separate
> accounting into a helper function.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
>
> ---
> kernel/events/core.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -6962,10 +6962,17 @@ static bool perf_mmap_calc_limits(struct
> return locked <= lock_limit || !perf_is_paranoid() || capable(CAP_IPC_LOCK);
> }
>
> +static void perf_mmap_account(struct vm_area_struct *vma, long user_extra, long extra)
> +{
> + struct user_struct *user = current_user();
> +
> + atomic_long_add(user_extra, &user->locked_vm);
> + atomic64_add(extra, &vma->vm_mm->pinned_vm);
> +}
> +
> static int perf_mmap(struct file *file, struct vm_area_struct *vma)
> {
> struct perf_event *event = file->private_data;
> - struct user_struct *user = current_user();
> unsigned long vma_size, nr_pages;
> long user_extra = 0, extra = 0;
> struct mutex *aux_mutex = NULL;
> @@ -7136,9 +7143,7 @@ static int perf_mmap(struct file *file,
>
> unlock:
> if (!ret) {
> - atomic_long_add(user_extra, &user->locked_vm);
> - atomic64_add(extra, &vma->vm_mm->pinned_vm);
> -
> + perf_mmap_account(vma, user_extra, extra);
> atomic_inc(&event->mmap_count);
> } else if (rb) {
> /* AUX allocation failed */
>
>
>
next prev parent reply other threads:[~2025-08-11 12:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-11 12:36 [patch V2 RESEND 0/6] perf: Convert mmap() related reference counts to refcount_t Thomas Gleixner
2025-08-11 12:36 ` [patch V2 RESEND 1/6] perf/core: Remove redundant condition for AUX buffer size Thomas Gleixner
2025-08-11 12:55 ` Lorenzo Stoakes
2025-08-11 12:36 ` [patch V2 RESEND 2/6] perf/core: Split out mlock limit handling Thomas Gleixner
2025-08-11 12:57 ` Lorenzo Stoakes
2025-08-11 12:36 ` [patch V2 RESEND 3/6] perf/core: Split out VM accounting Thomas Gleixner
2025-08-11 12:58 ` Lorenzo Stoakes [this message]
2025-08-11 12:36 ` [patch V2 RESEND 4/6] perf/core: Split out AUX buffer allocation Thomas Gleixner
2025-08-11 13:21 ` Lorenzo Stoakes
2025-08-12 10:06 ` Peter Zijlstra
2025-08-12 11:08 ` Lorenzo Stoakes
2025-08-11 12:36 ` [patch V2 RESEND 5/6] perf/core: Split the ringbuffer mmap() and allocation code out Thomas Gleixner
2025-08-11 13:56 ` Lorenzo Stoakes
2025-08-11 14:10 ` Lorenzo Stoakes
2025-08-11 12:36 ` [patch V2 RESEND 6/6] perf/core: Convert mmap() refcounts to refcount_t Thomas Gleixner
2025-08-11 14:12 ` Lorenzo Stoakes
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=3be7fd83-e209-49ec-8d81-ba6a60d4da94@lucifer.local \
--to=lorenzo.stoakes@oracle.com \
--cc=acme@redhat.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linuxfoundation.org \
/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