All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jamie Dolan <jldolan@linux.ibm.com>
To: linux-trace-devel@vger.kernel.org
Cc: frank.heimes@canonical.com, Jamie Dolan <jldolan@linux.ibm.com>
Subject: [PATCH] libtracefs utest: Apply min percent before setting buffer percent
Date: Wed, 18 Nov 2026 18:06:41 +0000	[thread overview]
Message-ID: <20261118180641.40630-1-jldolan@linux.ibm.com> (raw)

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


                 reply	other threads:[~2026-11-18 18:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261118180641.40630-1-jldolan@linux.ibm.com \
    --to=jldolan@linux.ibm.com \
    --cc=frank.heimes@canonical.com \
    --cc=linux-trace-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.