* [PATCH] libtracefs utest: Apply min percent before setting buffer percent
@ 2026-11-18 18:06 Jamie Dolan
0 siblings, 0 replies; only message in thread
From: Jamie Dolan @ 2026-11-18 18:06 UTC (permalink / raw)
To: linux-trace-devel; +Cc: frank.heimes, Jamie Dolan
The "trace cpu read_buf_percent" test raises the buffer percentage
to a higher minimum value to account for architectures with larger
sub-buffers, such as PowerPC with a 64K PAGE_SIZE.
However, the adjustment happens after the buffer percentage
has already been set in the kernel.
As a result, the kernel uses a lower threshold while the test
calculates its expected event count using the adjusted percentage.
This causes tracefs_cpu_read_buf() to return earlier than
expected, causing the test to fail with "data->done == false".
Move the min percent calculation before the buffer percentage is set.
Fixes: 05a5dc42733b ("libtracefs utest: Fix min percent test")
Bug: https://bugzilla.kernel.org/show_bug.cgi?id=219358
Bug-Ubuntu: https://launchpad.net/bugs/2062119
Signed-off-by: Jamie Dolan <jldolan@linux.ibm.com>
---
utest/tracefs-utest.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c
index e48232c..ec56327 100644
--- a/utest/tracefs-utest.c
+++ b/utest/tracefs-utest.c
@@ -1333,6 +1333,19 @@ static void test_cpu_read_buf_percent(struct test_cpu_data *data, int percent)
save_percent = tracefs_instance_get_buffer_percent(data->instance);
CU_TEST(save_percent >= 0);
+ if (percent) {
+ int min_percent;
+
+ /*
+ * For architectures like PowerPC with 64K PAGE_SIZE and thus
+ * large sub buffers, where we will not have over 100 sub buffers
+ * percent must at least cover more than 1 sub buffer.
+ */
+ min_percent = (100 + (data->nr_subbufs - 1)) / data->nr_subbufs;
+ if (percent < min_percent)
+ percent = min_percent;
+ }
+
ret = tracefs_instance_set_buffer_percent(data->instance, percent);
CU_TEST(ret == 0);
@@ -1350,16 +1363,6 @@ static void test_cpu_read_buf_percent(struct test_cpu_data *data, int percent)
/* For percent == 0, just test for any data */
if (percent) {
- int min_percent;
-
- /*
- * For architectures like PowerPC with 64K PAGE_SIZE and thus
- * large sub buffers, where we will not have over 100 sub buffers
- * percent must at least cover more than 1 sub buffer.
- */
- min_percent = (100 + (data->nr_subbufs - 1)) / data->nr_subbufs;
- if (percent < min_percent)
- percent = min_percent;
expect = data->nr_subbufs * data->events_per_buf * percent / 100;
--
2.43.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-18 18:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 18:06 [PATCH] libtracefs utest: Apply min percent before setting buffer percent Jamie Dolan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.