From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx> The test_instance_cpu_read() will test events_per_buf * 50 events. But on PowerPC64 which has 64K size subbuffers, there may not be 50 subbuffers in a per CPU ring buffer. That means the test will overflow and it will read less events than expected. Check to make sure that the number to test is not going to add more events than what a single ring buffer can hold. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=219358 Reported-by: Adrien Nader <adrien@xxxxxxxx> Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx> --- utest/tracefs-utest.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c index b5095a18bb16..46fa31c88cf6 100644 --- a/utest/tracefs-utest.c +++ b/utest/tracefs-utest.c @@ -1270,6 +1270,8 @@ static void test_cpu_read(struct test_cpu_data *data, int expect) static void test_instance_trace_cpu_read(struct tracefs_instance *instance, bool map) { struct test_cpu_data data; + size_t buffer_size; + int big_num = 50; if (setup_trace_cpu(instance, &data, true, map)) return; @@ -1278,7 +1280,14 @@ static void test_instance_trace_cpu_read(struct tracefs_instance *instance, bool test_cpu_read(&data, data.events_per_buf / 2); test_cpu_read(&data, data.events_per_buf); test_cpu_read(&data, data.events_per_buf + 1); - test_cpu_read(&data, data.events_per_buf * 50); + + buffer_size = tracefs_instance_get_buffer_size(instance, 0) * 1024; + if (data.events_per_buf * big_num > (buffer_size - data.events_per_buf)) { + big_num = (buffer_size / data.events_per_buf); + big_num -= data.events_per_buf * 2; + CU_TEST(big_num > 0); + } + test_cpu_read(&data, data.events_per_buf * big_num); shutdown_trace_cpu(&data); } -- 2.45.2