From nobody Mon Jun 15 09:40:21 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCD013CD8C7 for ; Thu, 9 Apr 2026 12:47:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775738854; cv=none; b=Kuba1hm/t4HIubnH1pL1dNoldp8wZLHBtKaFQZYDTot3wf+c38wv9R1eW3SJEgsr6hfVEKPXxG6NXD6tlHPnG5qjDm+ZbdogMRh65MwDuqwixpU4VPOl7BeWM1JXdti1zpdu8lAUzzyl/iwH4/S2GJ1fU0A5GkCfHrggG+qVeWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775738854; c=relaxed/simple; bh=Uu9//9V94CBGvVAEi04F+fPgyTZQHY9yBAhcsREoUsU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=PCDk3hSnPI/Z0gC5XUv/GM3FbCWyw7rMh1JS4O4WomCd7mtmWcLkK8skKfFBH/Pibla5kcACAeYHnsOx/6MaJbScnpTRZ3lCYWW2JDtImMbkwXtkp7ozb69i70ztxunMvnwVk7SJz50tDbNDaPw3Egn5N5Ge2xMN5yTU6H0cV+w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=HVlQIZM2; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=7TqVdP7J; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="HVlQIZM2"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="7TqVdP7J" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1775738847; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=V6AUzO23Rkfxcm+TKz1W8ikbmhbFH7JydnV2bpYdH0I=; b=HVlQIZM2V35XqMiMg/H2Qm6tpny0yeAiLP+V+9sgcoWT5gc8xGtNhFtk34aXseOq5R/AcO kXMdZY+CXo0INe2fib5cumVsmOSK5/Imn5KIL4fyiVZhA2f4NmPNiceeHQEBPWOyAT+0F8 ksjTKEgZLpgSuOAb2jGwRummTrorB5aOsveF1rJU50Xq8P4lNsPKm0Kf5bi0I8wmqn3YHX sV6gi03n47naO6WJcFKRS7nb+XUKAbjcu07cMcPWWXjFyfPQP93ehH9lINkjDS9QBbxOkF bjuh/3tzGcSuqruJ4GsTu4yqBM8+iQTBi1xuw7+X7qD76aYtf2p/VDqAqJE6jA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1775738847; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=V6AUzO23Rkfxcm+TKz1W8ikbmhbFH7JydnV2bpYdH0I=; b=7TqVdP7Jexx3Wji62VyJcYIekOOkwDvzepLFiLwW0biyBytl5sEjG7/CBJnFq7iK37cSll jY32jMqumpMbqDBg== Date: Thu, 09 Apr 2026 14:47:22 +0200 Subject: [PATCH] hrtimer: Return ktime_t from hrtimer_get_next_event()/hrtimer_next_event_without() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260409-hrtimer-next_event-v1-1-df424f2c8621@linutronix.de> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIzMDEwNL3Yyikszc1CLdvNSKkvjUstS8Et00syTzNMOkNDML0zQloMaCotS 0zAqwodGxtbUAneuLcWQAAAA= X-Change-ID: 20260409-hrtimer-next_event-f6b7f1bf685f To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Ingo Molnar Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1775738847; l=3416; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=Uu9//9V94CBGvVAEi04F+fPgyTZQHY9yBAhcsREoUsU=; b=RWYfJZ3kCJzsP/tHf+L36meq+SGus+WlIiFWgvi/UClqkqli2x6tlv4pMmhBh8Z3H/hQQS1/+ LgUnDv+UcGcBa9+MAQG89q9uwm90Q1pQqT8B5TXAzC/oeNbvxbEpy2X X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= These functions really work in terms of ktime_t and not u64. Change their return types and adapt the callers. Signed-off-by: Thomas Wei=C3=9Fschuh --- Based on tip/timers/core. --- include/linux/hrtimer.h | 4 ++-- kernel/time/hrtimer.c | 8 ++++---- kernel/time/tick-sched.c | 3 +-- kernel/time/timer.c | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 9ced498fefaa..1898706d0b87 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -254,8 +254,8 @@ static inline ktime_t hrtimer_get_remaining(const struc= t hrtimer *timer) return __hrtimer_get_remaining(timer, false); } =20 -extern u64 hrtimer_get_next_event(void); -extern u64 hrtimer_next_event_without(const struct hrtimer *exclude); +extern ktime_t hrtimer_get_next_event(void); +extern ktime_t hrtimer_next_event_without(const struct hrtimer *exclude); =20 extern bool hrtimer_active(const struct hrtimer *timer); =20 diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 5bd6efe598f0..2f41e55cc524 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1681,10 +1681,10 @@ EXPORT_SYMBOL_GPL(__hrtimer_get_remaining); * * Returns the next expiry time or KTIME_MAX if no timer is pending. */ -u64 hrtimer_get_next_event(void) +ktime_t hrtimer_get_next_event(void) { struct hrtimer_cpu_base *cpu_base =3D this_cpu_ptr(&hrtimer_bases); - u64 expires =3D KTIME_MAX; + ktime_t expires =3D KTIME_MAX; =20 guard(raw_spinlock_irqsave)(&cpu_base->lock); if (!hrtimer_hres_active(cpu_base)) @@ -1700,10 +1700,10 @@ u64 hrtimer_get_next_event(void) * Returns the next expiry time over all timers except for the @exclude on= e or * KTIME_MAX if none of them is pending. */ -u64 hrtimer_next_event_without(const struct hrtimer *exclude) +ktime_t hrtimer_next_event_without(const struct hrtimer *exclude) { struct hrtimer_cpu_base *cpu_base =3D this_cpu_ptr(&hrtimer_bases); - u64 expires =3D KTIME_MAX; + ktime_t expires =3D KTIME_MAX; unsigned int active; =20 guard(raw_spinlock_irqsave)(&cpu_base->lock); diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index cbbb87a0c6e7..3026a301dff7 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1407,8 +1407,7 @@ ktime_t tick_nohz_get_sleep_length(ktime_t *delta_nex= t) * If the next highres timer to expire is earlier than 'next_event', the * idle governor needs to know that. */ - next_event =3D min_t(u64, next_event, - hrtimer_next_event_without(&ts->sched_timer)); + next_event =3D min(next_event, hrtimer_next_event_without(&ts->sched_time= r)); =20 return ktime_sub(next_event, now); } diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 04d928c21aba..655a8c6cd84d 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1932,7 +1932,7 @@ static void timer_recalc_next_expiry(struct timer_bas= e *base) */ static u64 cmp_next_hrtimer_event(u64 basem, u64 expires) { - u64 nextevt =3D hrtimer_get_next_event(); + u64 nextevt =3D ktime_to_ns(hrtimer_get_next_event()); =20 /* * If high resolution timers are enabled --- base-commit: 9734946b6c4065628972b6eb2cc79a6d7ce8fce4 change-id: 20260409-hrtimer-next_event-f6b7f1bf685f Best regards, -- =20 Thomas Wei=C3=9Fschuh