From nobody Sun Jun 14 04:10:44 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 59A8329DB6C for ; Mon, 4 May 2026 06:56:18 +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=1777877779; cv=none; b=QOuFuYSrqdFHrY5MvzQVOehf2ZLSfQf397+4rcr8GhCCJBb8BezrJhmwjrkIS4QbZYQoo74sKRM/UEa0QKsHoPgjrIJY3toDMEi6V6e8/DiyBGTLKlbxS5UIVz306scXKBV/6sSe/AJjj6Y7RrbpEx8kADT5Jdy54CeQrZmtJws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777877779; c=relaxed/simple; bh=cEyzSpMblLH4KmoVwplwToL7pqhBDmDyf89ExldUbgc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=MC4+E0Wb14/S2DlOj3MgBvjIsMDZ2Pr74n03BJCRW+veZHnrbJS7Qkx9bnIC1T2q/oOIbtDyGgoT0FSFkyP2+tsE9hqeBvVKb6csnFfEvHwqkZm+rmPjfsuOOiPPiST70umdNWiu7/Y12koj5P9JDXQobkXYJ7KhEBTe+3AsHTg= 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=O/bIiRqL; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=nPQLMNjd; 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="O/bIiRqL"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="nPQLMNjd" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777877777; 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=SoYhqD7XkVjHAwYYj7LuQv4rIkX+KAVUgMejdAPFvRs=; b=O/bIiRqLrGUjx2LKEiIRkhYjsVl3tOINwqI96YunO/li4k2Cy7XJJNq8yN3RVHqqrhSGPK QMDUMBO0rvHAOsyq8I41os6lF2c2vSeiEAOa6BPBQmWnE+CbCjO7ZFGed/geMwNSqvhdlc N63GLficG80U8yVyAvCLKo3GbM0KprIs8vXcTBIiSLizMXI6HC4gG+4BzpdAPZKkb8BnNt JFnKEB0mhzaNiR8gCBHtXuZEFxyrwFt7D/RpgndDEOIWUHzcZtoeTTtxn0NS8V1PqvIoQB k/mkSx/EN2RwZCX19viH0z7vmlvfz6mQDNqeYoIUo6mHIYw2iNu1BYMP3I90Vg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777877777; 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=SoYhqD7XkVjHAwYYj7LuQv4rIkX+KAVUgMejdAPFvRs=; b=nPQLMNjdlaXCwad/jcBxV/qEhMSZiNApH9MWZegL371RSsID5OhbJfzgYgBASMdiePOcoV qpAT9T4SjCuuSTBA== Date: Mon, 04 May 2026 08:56:10 +0200 Subject: [PATCH v2] 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: <20260504-hrtimer-next_event-v2-1-7a5d0550b42f@linutronix.de> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/32NQQrCMBBFr1JmbaQJMVZX3kOK2HbGDmhaJjFUS u5u7AFcvgf//RUCCmOAc7WCYOLAky9gdhX0490/UPFQGExtXG3rkxol8gtFeVziDRP6qMh1R9I dueZAUIazIPGyRa9t4ZFDnOSzfST9s39zSSutBrLGkukbZ/Tlyf4dZfK87AeENuf8BTw2eTW4A AAA 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=1777877776; l=3527; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=cEyzSpMblLH4KmoVwplwToL7pqhBDmDyf89ExldUbgc=; b=uXksjBdOsVsIcsJwVPNZv2pHzey8xPKNDcxKTAhURn+2eq02+vVidwuY33ad0Nv139aLnicBE lh5zQdXwZGdAhs0ExxCXDUbuNQ3bh47plvKT0/UJuXFgqVBZHCUayfh 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 --- Changes in v2: - Rebase on v7.1-rc1 - Link to v1: https://patch.msgid.link/20260409-hrtimer-next_event-v1-1-df4= 24f2c8621@linutronix.de --- 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: 254f49634ee16a731174d2ae34bc50bd5f45e731 change-id: 20260409-hrtimer-next_event-f6b7f1bf685f Best regards, -- =20 Thomas Wei=C3=9Fschuh