Patch "perf: Fix default aux_watermark calculation" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    perf: Fix default aux_watermark calculation

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     perf-fix-default-aux_watermark-calculation.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 7ff322bcbc9c69cd542f1b2dcfa222d941781bc9
Author: Adrian Hunter <adrian.hunter@xxxxxxxxx>
Date:   Mon Jun 24 23:11:00 2024 +0300

    perf: Fix default aux_watermark calculation
    
    [ Upstream commit 43deb76b19663a96ec2189d8f4eb9a9dc2d7623f ]
    
    The default aux_watermark is half the AUX area buffer size. In general,
    on a 64-bit architecture, the AUX area buffer size could be a bigger than
    fits in a 32-bit type, but the calculation does not allow for that
    possibility.
    
    However the aux_watermark value is recorded in a u32, so should not be
    more than U32_MAX either.
    
    Fix by doing the calculation in a correctly sized type, and limiting the
    result to U32_MAX.
    
    Fixes: d68e6799a5c8 ("perf: Cap allocation order at aux_watermark")
    Signed-off-by: Adrian Hunter <adrian.hunter@xxxxxxxxx>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240624201101.60186-7-adrian.hunter@xxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 45965f13757e4..f3a3c294ff2b3 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -683,7 +683,9 @@ int rb_alloc_aux(struct perf_buffer *rb, struct perf_event *event,
 		 * max_order, to aid PMU drivers in double buffering.
 		 */
 		if (!watermark)
-			watermark = nr_pages << (PAGE_SHIFT - 1);
+			watermark = min_t(unsigned long,
+					  U32_MAX,
+					  (unsigned long)nr_pages << (PAGE_SHIFT - 1));
 
 		/*
 		 * Use aux_watermark as the basis for chunking to




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux