From nobody Tue Sep 29 06:08:55 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 5C517453A36; Tue, 11 Aug 2026 16:14:20 +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=1786464862; cv=none; b=hhrs2fwTe71kQCuzhq/Ze2FIkt/99a6Zclmi0jM2gPmqcZmDhWmP9ofNwuO0Tzvu/luJKCce7qTsKYHbMnTd26Ryns25SIpGc5cWwzrAOGU6GeixbwcQrQngp6sxYb9yLr17QYtFwyJmnj9rHH3FMPjWis9d+2hhjsria7X/tQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786464862; c=relaxed/simple; bh=6niT/oOvFNNhI3VKfwfL4fGrjtP4NYwZC6VSjdkd2R0=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=EFNNBrh1NbKOdiQ8ig+8YN7WcSpM5B3QxoHnTDKd78zOHVIHh3AvUK/18377qkrbIgPoY9YnsvVQH64NAeIeut7+pWUlagejZ1XZOt6NdqLzloeiTG/7lmYWP4fQ2uYj8FU+6PaQ1IE0dWZQnkLyWgWXUeWPxBFrs/u3jMNOUZI= 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=wL2IZI3p; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=/Kz8IlCZ; 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="wL2IZI3p"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="/Kz8IlCZ" Date: Tue, 11 Aug 2026 16:14:16 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1786464858; h=from:from:sender:sender:reply-to: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: in-reply-to:in-reply-to:references:references; bh=P0r0tZI1zeNRo243b7K26kH8NMe/EKaxZoYVkn6jrTc=; b=wL2IZI3pzDwFzX11/63M5kLI4IMQrNzKcIkkG6n+4fVpIALANfX7zY6huMNEzUa5NFRuy3 AdGWcnoifN3o0AP7R4WbAH5tIkKikZMsnm2+hJ9I+K1vm/werbLK7DiuycmFqfUhlKG/fS 2azcdIfk2+6EdnfjQ1NR8EPX44fl+H9Mw7OALwrtj8Np8JrMfnvrws3O1YgcnJ49tKfkea PjPE3pupG3pSFAb5c9ZOm9LjU/5xWg0/DiZJhkaa6HdAum392LWvCAP11a8Fqs3S6xau1s Ihh2EQPa6j8nGOatVHVSJu5IAJ14Mj0dZkIiYHPbpLtrO27CDMU+6zOSMqq2xA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1786464858; h=from:from:sender:sender:reply-to: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: in-reply-to:in-reply-to:references:references; bh=P0r0tZI1zeNRo243b7K26kH8NMe/EKaxZoYVkn6jrTc=; b=/Kz8IlCZfKcmiThramGe4ddgOME+4dxOgKT9sZAjc3VSV2rj5u8QateTsF9bRsJqQ/38Wv vDX8D+gaUq7YGyBA== From: tip-bot2 for Thomas =?utf-8?q?Wei=C3=9Fschuh_=28Schneider_Electric=29?= Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] timer_list: Use ktime_t over nanoseconds Cc: thomas.weissschuh@linutronix.de, Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260803-auxclock-nanosleep-prep-v2-5-910cbd485390@linutronix.de> References: <20260803-auxclock-nanosleep-prep-v2-5-910cbd485390@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178646485692.442315.8170288796459373772.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the timers/core branch of tip: Commit-ID: 859b069ec5a328bd0bca301f6b9d87ff1dfc4b1d Gitweb: https://git.kernel.org/tip/859b069ec5a328bd0bca301f6b9d87ff1= dfc4b1d Author: Thomas Wei=C3=9Fschuh (Schneider Electric) AuthorDate: Mon, 03 Aug 2026 12:04:36 +02:00 Committer: Thomas Gleixner CommitterDate: Tue, 11 Aug 2026 18:11:20 +02:00 timer_list: Use ktime_t over nanoseconds hrtimers use ktime_t in their implementation and API. The timer list performs a lot of unnecessary conversion to nanoseconds which make the code harder to read and are also wrong in case the values ever become negative. Remove the conversions. Signed-off-by: Thomas Wei=C3=9Fschuh (Schneider Electric) Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20260803-auxclock-nanosleep-prep-v2-5-910cbd= 485390@linutronix.de --- kernel/time/timer_list.c | 57 ++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c index ccbbb2a..0406bf4 100644 --- a/kernel/time/timer_list.c +++ b/kernel/time/timer_list.c @@ -20,7 +20,7 @@ struct timer_list_iter { int cpu; bool second_pass; - u64 now; + ktime_t now; }; =20 /* @@ -44,19 +44,19 @@ static void SEQ_printf(struct seq_file *m, const char *= fmt, ...) =20 static void print_timer(struct seq_file *m, struct hrtimer *taddr, struct hrtimer *tim= er, - int idx, u64 now) + int idx, ktime_t now) { SEQ_printf(m, " #%d: <%p>, %ps", idx, taddr, ACCESS_PRIVATE(timer, functi= on)); SEQ_printf(m, ", S:%02x", timer->is_queued); SEQ_printf(m, "\n"); - SEQ_printf(m, " # expires at %llu-%llu nsecs [in %lld to %lld nsecs]\n", - (unsigned long long)ktime_to_ns(hrtimer_get_softexpires(timer)), - (unsigned long long)ktime_to_ns(hrtimer_get_expires(timer)), - (long long)(ktime_to_ns(hrtimer_get_softexpires(timer)) - now), - (long long)(ktime_to_ns(hrtimer_get_expires(timer)) - now)); + SEQ_printf(m, " # expires at %lld-%lld nsecs [in %lld to %lld nsecs]\n", + (long long)hrtimer_get_softexpires(timer), + (long long)hrtimer_get_expires(timer), + (long long)ktime_sub(hrtimer_get_softexpires(timer), now), + (long long)ktime_sub(hrtimer_get_expires(timer), now)); } =20 -static void print_active_timers(struct seq_file *m, struct hrtimer_clock_b= ase *base, u64 now) +static void print_active_timers(struct seq_file *m, struct hrtimer_clock_b= ase *base, ktime_t now) { struct timerqueue_linked_node *curr; struct hrtimer *timer, tmp; @@ -94,7 +94,7 @@ next_one: } =20 static void -print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now) +print_base(struct seq_file *m, struct hrtimer_clock_base *base, ktime_t no= w) { SEQ_printf(m, " .base: %p\n", base); SEQ_printf(m, " .index: %d\n", base->index); @@ -105,10 +105,10 @@ print_base(struct seq_file *m, struct hrtimer_clock_b= ase *base, u64 now) (long long) base->offset); #endif SEQ_printf(m, "active timers:\n"); - print_active_timers(m, base, now + ktime_to_ns(base->offset)); + print_active_timers(m, base, ktime_add(now, base->offset)); } =20 -static void print_cpu(struct seq_file *m, int cpu, u64 now) +static void print_cpu(struct seq_file *m, int cpu, ktime_t now) { struct hrtimer_cpu_base *cpu_base =3D &per_cpu(hrtimer_bases, cpu); int i; @@ -124,12 +124,11 @@ static void print_cpu(struct seq_file *m, int cpu, u6= 4 now) #define P(x) \ SEQ_printf(m, " .%-15s: %llu\n", #x, \ (unsigned long long)DIAG_READ(cpu_base->x)) -#define P_ns(x) \ - SEQ_printf(m, " .%-15s: %llu nsecs\n", #x, \ - (unsigned long long)ktime_to_ns(DIAG_READ(cpu_base->x))) +#define P_ktime(x) \ + SEQ_printf(m, " .%-15s: %lld nsecs\n", #x, (long long)DIAG_READ(cpu_base= ->x)) =20 #ifdef CONFIG_HIGH_RES_TIMERS - P_ns(expires_next); + P_ktime(expires_next); P(hres_active); P(nr_events); P(nr_retries); @@ -137,15 +136,14 @@ static void print_cpu(struct seq_file *m, int cpu, u6= 4 now) P(max_hang_time); #endif #undef P -#undef P_ns +#undef P_ktime =20 #ifdef CONFIG_TICK_ONESHOT # define P(x) \ SEQ_printf(m, " .%-15s: %llu\n", #x, \ (unsigned long long)DIAG_READ(ts->x)) -# define P_ns(x) \ - SEQ_printf(m, " .%-15s: %llu nsecs\n", #x, \ - (unsigned long long)ktime_to_ns(DIAG_READ(ts->x))) +# define P_ktime(x) \ + SEQ_printf(m, " .%-15s: %lld nsecs\n", #x, (long long)DIAG_READ(ts->x)) # define P_flag(x, f) \ SEQ_printf(m, " .%-15s: %d\n", #x, !!(DIAG_READ(ts->flags) & (f))) =20 @@ -153,22 +151,22 @@ static void print_cpu(struct seq_file *m, int cpu, u6= 4 now) struct tick_sched *ts =3D tick_get_tick_sched(cpu); P_flag(nohz, TS_FLAG_NOHZ); P_flag(highres, TS_FLAG_HIGHRES); - P_ns(last_tick); + P_ktime(last_tick); P_flag(tick_stopped, TS_FLAG_STOPPED); P(idle_calls); P(idle_sleeps); - P_ns(idle_entrytime); - P_ns(idle_waketime); + P_ktime(idle_entrytime); + P_ktime(idle_waketime); P(last_jiffies); P(next_timer); - P_ns(idle_expires); + P_ktime(idle_expires); SEQ_printf(m, "jiffies: %llu\n", (unsigned long long)jiffies); } #endif =20 #undef P -#undef P_ns +#undef P_ktime #undef P_flag #undef DIAG_READ SEQ_printf(m, "\n"); @@ -201,8 +199,7 @@ print_tickdevice(struct seq_file *m, struct tick_device= *td, int cpu) SEQ_printf(m, " mult: %u\n", dev->mult); SEQ_printf(m, " shift: %u\n", dev->shift); SEQ_printf(m, " mode: %d\n", clockevent_get_state(dev)); - SEQ_printf(m, " next_event: %lld nsecs\n", - (unsigned long long) ktime_to_ns(dev->next_event)); + SEQ_printf(m, " next_event: %lld nsecs\n", (long long)dev->next_event= ); =20 SEQ_printf(m, " set_next_event: %ps\n", dev->set_next_event); =20 @@ -255,17 +252,17 @@ static void timer_list_show_tickdevices_header(struct= seq_file *m) } #endif =20 -static inline void timer_list_header(struct seq_file *m, u64 now) +static inline void timer_list_header(struct seq_file *m, ktime_t now) { SEQ_printf(m, "Timer List Version: v0.11\n"); SEQ_printf(m, "HRTIMER_MAX_CLOCK_BASES: %d\n", HRTIMER_MAX_CLOCK_BASES); - SEQ_printf(m, "now at %lld nsecs\n", (unsigned long long)now); + SEQ_printf(m, "now at %lld nsecs\n", (long long)now); SEQ_printf(m, "\n"); } =20 void sysrq_timer_list_show(void) { - u64 now =3D ktime_to_ns(ktime_get()); + ktime_t now =3D ktime_get(); int cpu; =20 timer_list_header(NULL, now); @@ -323,7 +320,7 @@ static void *timer_list_start(struct seq_file *file, lo= ff_t *offset) struct timer_list_iter *iter =3D file->private; =20 if (!*offset) - iter->now =3D ktime_to_ns(ktime_get()); + iter->now =3D ktime_get(); iter->cpu =3D -1; iter->second_pass =3D false; return move_iter(iter, *offset);