lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5e48ee14-118d-4183-a88e-0d68414a2c53@lucifer.local>
Date: Wed, 13 Aug 2025 07:00:55 +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 08/15] perf: Use guard() for aux_mutex in perf_mmap()

On Tue, Aug 12, 2025 at 12:39:06PM +0200, Peter Zijlstra wrote:
> After duplicating the common code into the rb/aux branches is it
> possible to use a simple guard() for the aux_mutex. Making the aux
> branch self-contained.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>

LGTM, I really am going to look into how we can use guards in mm to
simplify things... :)

So:

Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>

> ---
>  kernel/events/core.c |    6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
>
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -6975,7 +6975,6 @@ static int perf_mmap(struct file *file,
>  	struct perf_event *event = file->private_data;
>  	unsigned long vma_size, nr_pages;
>  	long user_extra = 0, extra = 0;
> -	struct mutex *aux_mutex = NULL;
>  	struct perf_buffer *rb = NULL;
>  	int ret, flags = 0;
>  	mapped_f mapped;
> @@ -7098,8 +7097,7 @@ static int perf_mmap(struct file *file,
>  		if (!rb)
>  			goto unlock;
>
> -		aux_mutex = &rb->aux_mutex;
> -		mutex_lock(aux_mutex);
> +		guard(mutex)(&rb->aux_mutex);
>
>  		aux_offset = READ_ONCE(rb->user_page->aux_offset);
>  		aux_size = READ_ONCE(rb->user_page->aux_size);
> @@ -7159,8 +7157,6 @@ static int perf_mmap(struct file *file,
>  	}
>
>  unlock:
> -	if (aux_mutex)
> -		mutex_unlock(aux_mutex);
>  	mutex_unlock(&event->mmap_mutex);
>
>  	if (ret)
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ