On Wed, Aug 06, 2025 at 10:12:54PM +0200, Thomas Gleixner wrote:
> It is already checked whether the VMA size is the same as
> nr_pages * PAGE_SIZE, so later checking both:
Yeah I see near the start of perf_mmap();
if (vma_size != PAGE_SIZE * nr_pages)
return -EINVAL;
>
> aux_size == vma_size && aux_size == nr_pages * PAGE_SIZE
>
> is redundant. Remove the vma_size check as nr_pages is what is actually
> used in the allocation function. That prepares for splitting out the buffer
> allocation into seperate functions, so that only nr_pages needs to be
> handed in.
>
> No functional change.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
So this seems obviously correct:
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> ---
> kernel/events/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -7043,7 +7043,7 @@ static int perf_mmap(struct file *file,
> if (rb_has_aux(rb) && rb->aux_pgoff != vma->vm_pgoff)
> goto aux_unlock;
>
> - if (aux_size != vma_size || aux_size != nr_pages * PAGE_SIZE)
> + if (aux_size != nr_pages * PAGE_SIZE)
> goto aux_unlock;
>
> /* already mapped with a different size */
>