libtracefs utest: Apply min percent before setting buffer percent
PATCH 1/1 libtracefs utest: Apply min percent before setting buffer percent
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-Ubuntu: https://launchpad.net/bugs/2062119
Signed-off-by Jamie Dolan <[email protected]>
--- utest/tracefs-utest.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
utest/tracefs-utest.c +13 -10
@@ -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 ;
Signature · 1 line
2.43.0