mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Eva Kurchatova" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Eva Kurchatova <eva.kurchatova@virtuozzo.com>,
	Thomas Gleixner <tglx@kernel.org>,
	John Stultz <jstultz@google.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: timers/core] selftests: timers: Measure the CPU timers on the clock they count
Date: Tue, 29 Sep 2026 20:05:49 -0000	[thread overview]
Message-ID: <179071234992.3910103.2731078353172024952.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20260917015237.2462954-2-eva.kurchatova@virtuozzo.com>

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     b03638013add0609d35aaa8291548dea92cb9484
Gitweb:        https://git.kernel.org/tip/b03638013add0609d35aaa8291548dea92cb9484
Author:        Eva Kurchatova <eva.kurchatova@virtuozzo.com>
AuthorDate:    Thu, 17 Sep 2026 04:52:32 +03:00
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Tue, 29 Sep 2026 22:03:31 +02:00

selftests: timers: Measure the CPU timers on the clock they count

Commit b00385b8d081 ("selftests/posix_timers: Use CLOCK_THREAD_CPUTIME_ID
for ITIMER_PROF measurements") gave ITIMER_PROF the clock it counts, as
measuring a CPU timer against the wall says nothing on a machine where
the task does not have a CPU to itself. The other CPU timers are still
measured against CLOCK_REALTIME and fail the same way. With four busy
loops on the two CPUs of a test machine:

  not ok 2 ITIMER_VIRTUAL
  not ok 5 timer_create() per CLOCK_THREAD_CPUTIME_ID
  not ok 6 timer_create() per CLOCK_PROCESS_CPUTIME_ID

ITIMER_VIRTUAL counts the time the task spends in userspace, so take
CLOCK_THREAD_CPUTIME_ID for it as well; the loop it runs stays in
userspace, so what that clock adds for system time is far inside the
half a second the check allows. check_timer_create() arms its timer on
the clock it is given, so measure on that one.

The test then passes whole on that machine, 19 of 19, busy or idle.

Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Acked-by: John Stultz <jstultz@google.com>
Link: https://patch.msgid.link/20260917015237.2462954-2-eva.kurchatova@virtuozzo.com
---
 tools/testing/selftests/timers/posix_timers.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/timers/posix_timers.c b/tools/testing/selftests/timers/posix_timers.c
index a92d4b9..52b7289 100644
--- a/tools/testing/selftests/timers/posix_timers.c
+++ b/tools/testing/selftests/timers/posix_timers.c
@@ -113,9 +113,10 @@ static void check_itimer(int which, const char *name)
 
 	done = 0;
 
-	if (which == ITIMER_VIRTUAL)
+	if (which == ITIMER_VIRTUAL) {
+		clock_id = CLOCK_THREAD_CPUTIME_ID;
 		signal(SIGVTALRM, sig_handler);
-	else if (which == ITIMER_PROF) {
+	} else if (which == ITIMER_PROF) {
 		clock_id = CLOCK_THREAD_CPUTIME_ID;
 		signal(SIGPROF, sig_handler);
 	}
@@ -148,7 +149,7 @@ static void check_timer_create(int which)
 	struct itimerspec val = {
 		.it_value.tv_sec = DELAY,
 	};
-	int clock_id = CLOCK_REALTIME;
+	int clock_id = which;
 	timer_t id;
 
 	done = 0;

  parent reply	other threads:[~2026-09-29 20:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17  1:52 [PATCH 1/2] selftests: timers: count what tick is worth in the drift estimate Eva Kurchatova
2026-09-17  1:52 ` [PATCH 2/2] selftests: timers: measure the CPU timers on the clock they count Eva Kurchatova
2026-09-24 19:29   ` John Stultz
2026-09-29 20:05   ` tip-bot2 for Eva Kurchatova [this message]
2026-09-24 19:40 ` [PATCH 1/2] selftests: timers: count what tick is worth in the drift estimate John Stultz
2026-09-29 20:05 ` [tip: timers/core] selftests: timers: Count " tip-bot2 for Eva Kurchatova

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=179071234992.3910103.2731078353172024952.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=eva.kurchatova@virtuozzo.com \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=tglx@kernel.org \
    --cc=x86@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®