From nobody Fri Oct 2 09:21:58 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 4942935C193; Mon, 3 Aug 2026 10:04:45 +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=1785751486; cv=none; b=S1+m+PrRJk7uIIhjz10ZiBQ8NbaVEhyWJh3nlNvMPG7AVSudlSGruNM180ugJMXGGr1UvIHdCVOIN+tBDR+9nAFmv0pb31Fff238mWj6skhVf9nS32r7QfanxMPfMudP8VOvuZ6zwZrrGX6PNzutqcUxinaT6ButH0g+ZmZmO34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785751486; c=relaxed/simple; bh=DALe5O/eshy9jMm/CQK7Kl8g0BzKVn3HeUUbe0nrhLQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mCBfmbHua2O7I16gN5b5wl7UDmMPfPT0Ir9y+gw/j7l/6YVHaGcMrV9tkVqILcz1n1jKkQcziWCsYrUyr9rt6R2N+n7JLLexU2Is1Y12EEM7aNDbhHhtZ0++SE37j3Rkc/dN4d8a8gc2lKnnRmDVvoApF5A+b0bmIAFsAdlbwh4= 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=uCOaWPuY; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=nS9egBUS; 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="uCOaWPuY"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="nS9egBUS" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1785751483; 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: in-reply-to:in-reply-to:references:references; bh=ZOgQf08Qajk4uNYNxNWJ7kvwTeDXyg7JpRXotsfCxmk=; b=uCOaWPuYnWDV0iELf3+4CwecDr33Ry3g49rHNsz0Tn623UrVPq0BjbYP2zSmXCcrctxTV2 GFIWVQ+LlZuCjN9H7sMeLJgmdNWl8oLmSH5LZnyHmi4BYsoxRJPsGTlM3BMMODKrU/sjCW MhhTJ48fiyNlb+MDeur0VxEUnZFutOunYyQlacZ+TNc8+ejzGmnUUA7Gp1lF0qERM14TV4 b1UrpQYUsoiRdrI1UDObSOrc9PrWSPEPa4t7dsl45l7tXibnW7P5SyqJlBn5625FJAADuK GlZVLa5iw/kpmX3xwOtqH/4SH32xkqXLjJdNeNDtcHx453SkmmvOheEorEDjkQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1785751483; 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: in-reply-to:in-reply-to:references:references; bh=ZOgQf08Qajk4uNYNxNWJ7kvwTeDXyg7JpRXotsfCxmk=; b=nS9egBUSe6VPeRSWyF7Pq9Y6m/biWVw/pJQ86e4uZUPd/EpWNwiQVpe1bkDohJt+Zj7d/e GOISJ7UsZWiX0AAw== Date: Mon, 03 Aug 2026 12:04:32 +0200 Subject: [PATCH v2 01/17] timekeeping: Rename clockid_aux_valid() to clockid_is_aux_clock() 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: <20260803-auxclock-nanosleep-prep-v2-1-910cbd485390@linutronix.de> References: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> In-Reply-To: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> To: John Stultz , Thomas Gleixner , Stephen Boyd , Miroslav Lichvar , Anna-Maria Behnsen , Frederic Weisbecker , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1785751481; l=1542; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=DALe5O/eshy9jMm/CQK7Kl8g0BzKVn3HeUUbe0nrhLQ=; b=b11PWU1E2eAZaVHeTXVxChEB9dAoV6Tg+cWBjz1R2EhMP6RPTRYDxBztMsIxl4IyxL6QyWJWy fyOnmW0gz4tDzWj38QBX7gIH8U8EdUfNmn6eeD2enwJNzkik0s1HUge X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The current name is not clear about its behavior. Rename it. Signed-off-by: Thomas Wei=C3=9Fschuh (Schneider Electric) --- include/linux/posix-timers.h | 2 +- kernel/time/timekeeping.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h index 4117827efdb8..9a1a0c61361c 100644 --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h @@ -37,7 +37,7 @@ static inline int clockid_to_fd(const clockid_t clk) return ~(clk >> 3); } =20 -static inline bool clockid_aux_valid(clockid_t id) +static inline bool clockid_is_aux_clock(clockid_t id) { return IS_ENABLED(CONFIG_POSIX_AUX_CLOCKS) && id >=3D CLOCK_AUX && id <= =3D CLOCK_AUX_LAST; } diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 97db2e9393f9..d4cdbcdcb9df 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -3129,7 +3129,7 @@ static inline unsigned int clockid_to_tkid(unsigned i= nt id) =20 static inline struct tk_data *aux_get_tk_data(clockid_t id) { - if (!clockid_aux_valid(id)) + if (!clockid_is_aux_clock(id)) return NULL; return &timekeeper_data[clockid_to_tkid(id)]; } @@ -3224,7 +3224,7 @@ EXPORT_SYMBOL_GPL(ktime_get_aux_ts64); =20 static int aux_get_res(clockid_t id, struct timespec64 *tp) { - if (!clockid_aux_valid(id)) + if (!clockid_is_aux_clock(id)) return -ENODEV; =20 tp->tv_sec =3D aux_clock_resolution_ns() / NSEC_PER_SEC; --=20 2.55.0 From nobody Fri Oct 2 09:21:58 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 8D22133FE2F; Mon, 3 Aug 2026 10:04:45 +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=1785751487; cv=none; b=QsQzEe7zvpUw/oFOp2QyPlj3uJg73OiU4BNODjzlw967Vrtadptf2FWNV7I9GcX/9bc48SRTEuWuvsEj/1A/WYki30pofsAX86fDzvo7gY/klmdFNFViAE/X9QD4jt6NkGICDGWhY5Rhvqa60b9APU0zmhInXF4TkX4hkCBas8M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785751487; c=relaxed/simple; bh=PTowp/FvLPE92NssmWbWusBpgoBwA0rg28qCtRx1VAE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=onTSnJsUnerkpS5tQ1Yb336uDq6ulWEQXXm5KRiitlSJbKNLdO2PRItyDnWQAYv0lh2LyTnSNpyEBJJG1VQaCxUxkInRXA+ERCC++MrQcABLXigsV+UpJVeB8w0qmQAOFtu9wjiEnbT5ut4iHQqEESBCzygH1qfkKl42vxZz4Pc= 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=LXdhTVs1; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=6WRp28WL; 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="LXdhTVs1"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="6WRp28WL" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1785751484; 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: in-reply-to:in-reply-to:references:references; bh=i3cxRIda73uUlRO0Uq3wYFJDAkzvVt74b1o3ZlJ+yuk=; b=LXdhTVs1mY2G+xGrw7leS0acY92NhSEEWG6Wj1hWiRi6KZEjip0ABKyvXetmWofQMAjBCc StXxzOw/kf10yVDN/uhUp/0i8U/ZbLzY8wMkMucMd5m4fd3icd7r9k0+vyIFh2HEwvKcKH O0pQP5wL2cEoGqbQd0IC+cOPUp0AnoZTi7subNzH70iKoLpcP6cQI5QNqxQPDQ6k+DC+sx olHYytVC/ozM9v21DygRl2IcZ1wEpUULzyqqfPV18vn4Q008AAslTEXwFGqLwGdPX8Te5h LyE9XzzHd489h20wyR13f6kmlJpbP/DDG1Z4AvIEDXOM3m2NSYoaPL7uVBQtoA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1785751484; 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: in-reply-to:in-reply-to:references:references; bh=i3cxRIda73uUlRO0Uq3wYFJDAkzvVt74b1o3ZlJ+yuk=; b=6WRp28WLyg5oidVHH72d9EqN8f1C5lTqza8RllCasHVLy/O7QsqhFviwxf47h/GTJIvxhp j6y42FxyZCFIqJDg== Date: Mon, 03 Aug 2026 12:04:33 +0200 Subject: [PATCH v2 02/17] timekeeping: Use u32 for clock_was_set_seq 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: <20260803-auxclock-nanosleep-prep-v2-2-910cbd485390@linutronix.de> References: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> In-Reply-To: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> To: John Stultz , Thomas Gleixner , Stephen Boyd , Miroslav Lichvar , Anna-Maria Behnsen , Frederic Weisbecker , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1785751481; l=3900; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=PTowp/FvLPE92NssmWbWusBpgoBwA0rg28qCtRx1VAE=; b=giS5LeM3LJ6PxsjPR712gj7TcZD+PE+IRORb5PQz0ZcrON31xmSO5wi00zYhsWizC7Ob97Dnu pa5gGctaxBiB2OYq8nf2/KvYmhiT0oxZEx5tETb3zlFuHiUymxZao5A X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Use an explicitly sized type to make the code a bit more consistent with other fields of the datastructure and other sequence counters. Signed-off-by: Thomas Wei=C3=9Fschuh (Schneider Electric) --- include/linux/hrtimer_bases.h | 2 +- include/linux/timekeeper_internal.h | 2 +- include/linux/timekeeping.h | 2 +- kernel/time/hrtimer.c | 2 +- kernel/time/timekeeping.c | 5 +++-- kernel/time/timekeeping.h | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/linux/hrtimer_bases.h b/include/linux/hrtimer_bases.h index 70b99e651168..d4c83ec5c0f8 100644 --- a/include/linux/hrtimer_bases.h +++ b/include/linux/hrtimer_bases.h @@ -84,7 +84,7 @@ struct hrtimer_cpu_base { raw_spinlock_t lock; unsigned int cpu; unsigned int active_bases; - unsigned int clock_was_set_seq; + u32 clock_was_set_seq; bool hres_active; bool deferred_rearm; bool deferred_needs_update; diff --git a/include/linux/timekeeper_internal.h b/include/linux/timekeeper= _internal.h index 9c198f65621b..fe077d97b5f8 100644 --- a/include/linux/timekeeper_internal.h +++ b/include/linux/timekeeper_internal.h @@ -169,7 +169,7 @@ struct timekeeper { u32 cs_ns_to_cyc_mult; u32 cs_ns_to_cyc_shift; u64 cs_ns_to_cyc_maxns; - unsigned int clock_was_set_seq; + u32 clock_was_set_seq; u8 cs_was_changed_seq; u8 clock_valid; =20 diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index b4191a873c39..1345550d45b4 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -301,7 +301,7 @@ struct system_time_snapshot { ktime_t monoraw; enum clocksource_ids cs_id; enum clocksource_ids hw_csid; - unsigned int clock_was_set_seq; + u32 clock_was_set_seq; u8 cs_was_changed_seq; u8 valid; }; diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 01890b7a5f98..957c619e4271 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -903,8 +903,8 @@ static void hrtimer_reprogram(struct hrtimer *timer, bo= ol reprogram) static bool update_needs_ipi(struct hrtimer_cpu_base *cpu_base, unsigned i= nt active) { struct hrtimer_clock_base *base; - unsigned int seq; ktime_t expires; + u32 seq; =20 /* * Update the base offsets unconditionally so the following diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index d4cdbcdcb9df..815861ce451b 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1563,10 +1563,11 @@ int get_device_system_crosststamp(int (*get_time_fn) struct system_device_crosststamp *xtstamp) { u64 syscnt_cycles, cycles, now, interval_start; - unsigned int seq, clock_was_set_seq =3D 0; ktime_t base_sys, base_raw, *offs; + u32 clock_was_set_seq =3D 0; u64 nsec_sys, nsec_raw; u8 cs_was_changed_seq; + unsigned int seq; bool do_interp; struct timekeeper *tk; struct tk_data *tkd; @@ -2873,7 +2874,7 @@ void do_timer(unsigned long ticks) * * Called from hrtimer_interrupt() or retrigger_next_event() */ -ktime_t ktime_get_update_offsets_now(unsigned int *cwsseq, ktime_t *offs_r= eal, +ktime_t ktime_get_update_offsets_now(u32 *cwsseq, ktime_t *offs_real, ktime_t *offs_boot, ktime_t *offs_tai) { struct timekeeper *tk =3D &tk_core.timekeeper; diff --git a/kernel/time/timekeeping.h b/kernel/time/timekeeping.h index 198d0608db74..4201f9e90813 100644 --- a/kernel/time/timekeeping.h +++ b/kernel/time/timekeeping.h @@ -4,7 +4,7 @@ /* * Internal interfaces for kernel/time/ */ -extern ktime_t ktime_get_update_offsets_now(unsigned int *cwsseq, +extern ktime_t ktime_get_update_offsets_now(u32 *cwsseq, ktime_t *offs_real, ktime_t *offs_boot, ktime_t *offs_tai); --=20 2.55.0 From nobody Fri Oct 2 09:21:58 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 E6C8E372B2F; Mon, 3 Aug 2026 10:04:45 +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=1785751487; cv=none; b=Z6SqowXALVenJbi3n0ByFMySls2VHwR5g8DqnhcRgERCCt1gmDVYPPHr98aUdjUnOAM04to9DjJFV3Re+IpmfeFvIZaMD1TLJDPuA2dgggzzJnJCO+f+EN7yHpGi2KWJ5yaUx3VDRPEwMElJ1QatrC5VfGzzHq1xM3bgErxEwfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785751487; c=relaxed/simple; bh=LlazCrVCSAoA7nQhANTzDxedg6EqyDm4a1QtRJTqUAg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZQOpokEU4Viy4ZgM/HLW2594qCtSON95QjgDPDGtCFIKyeVd7r2Ebn936IHMeIR72YqGyeyoi3Qf0jG+Iag9rAxtFZc9a+RUCJ53FHZKfpiOIgAE433zB1keXbpFispuioktE42/crn/6fqdwmLENPHtMnsO3W25mbXEzmqH/2I= 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=FyN3q/YX; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=utFAfzom; 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="FyN3q/YX"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="utFAfzom" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1785751484; 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: in-reply-to:in-reply-to:references:references; bh=Pw57SHParWAVAZJM5LNMTJHk4umVymwCjycA9VHiXio=; b=FyN3q/YXfgc4nBICaN0WJsf0D2I5SkwqUYwE6TJvtLhP5KYBTTIClTDcpopYbhpClA+esN POQVjr7KCRHLMWB+KT4SSAF688u/ehN8xA6pDhMvr/o25NlEIn6upei6UlTZHkeFIfzJAz 2Yye7eFTQ8qf6EyoAF8D2Io+8bZQQ5URsT8lZZddnFsbE0PPU9yurpY2gzbh+9K/YWLyQA TV88KUgQenBvW+z/fTUxqy67trHAR7FFl95Iz3rITnxXCfPRWTCevJynBHzszVH5ko1yrV lsqWqiFeksyaU8rrTqQ1A+u7rgKtdn9GRANwOJs+BulOG85fS0v+Vdh8af5XAg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1785751484; 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: in-reply-to:in-reply-to:references:references; bh=Pw57SHParWAVAZJM5LNMTJHk4umVymwCjycA9VHiXio=; b=utFAfzomFZfaNw1QK8Ln+PT+dGZCVhqjJql8FLpUB5DG0Y/5kxjf3KVuMn1HpQ153eqduv pKRes7d1ugIXn7AQ== Date: Mon, 03 Aug 2026 12:04:34 +0200 Subject: [PATCH v2 03/17] hrtimer: Add a lockdep assertion to hrtimer_update_base() 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: <20260803-auxclock-nanosleep-prep-v2-3-910cbd485390@linutronix.de> References: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> In-Reply-To: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> To: John Stultz , Thomas Gleixner , Stephen Boyd , Miroslav Lichvar , Anna-Maria Behnsen , Frederic Weisbecker , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1785751481; l=834; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=LlazCrVCSAoA7nQhANTzDxedg6EqyDm4a1QtRJTqUAg=; b=Io7tRhjDxYl7oxPEVwa1Ikg2H+6N95NxVBYTFLy1edlgCoVjimP1CEx70Eyv9Z7QbpMqAssF3 /69sm9/g9yaC2fYre+fwoC/aaqu3Qo3ZPWAzNDtYbFvNVzYLUo4hbBP X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Document and verify that the base's lock is held at this point. Signed-off-by: Thomas Wei=C3=9Fschuh (Schneider Electric) --- kernel/time/hrtimer.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 957c619e4271..91b2ea890730 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -677,6 +677,8 @@ static ktime_t hrtimer_update_next_event(struct hrtimer= _cpu_base *cpu_base) =20 static inline ktime_t hrtimer_update_base(struct hrtimer_cpu_base *base) { + lockdep_assert_held(&base->lock); + ktime_t *offs_real =3D &base->clock_base[HRTIMER_BASE_REALTIME].offset; ktime_t *offs_boot =3D &base->clock_base[HRTIMER_BASE_BOOTTIME].offset; ktime_t *offs_tai =3D &base->clock_base[HRTIMER_BASE_TAI].offset; --=20 2.55.0 From nobody Fri Oct 2 09:21:58 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 97BE6324716; Mon, 3 Aug 2026 10:04:46 +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=1785751488; cv=none; b=QfNQzN24/W/iQnl0b3N8EUVbo3lqFnoiDz8UmacGDW4KcukJ1SysPTFmSO5R69G4vlKv8zz23J1MHpacrOY6vvICstwnaZENiqo9xxFUVic1zwmkA0go91ry1K0jFtS3+ITzHsDZh8YmWanQoX/BHazY+MCQTEEX5DBxEl81MTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785751488; c=relaxed/simple; bh=Xl1ObBJJ9doKi1YLNZSXz+OTP8phEgGASrTbmMr6rO0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KGuPv4MGkLllPfsozqUowK0elximpnXqQX2fWMoPoPoD3fCILAFFsELd0PuFvwZ8fWA1BNneqgu/uGL/P/a22FPl1IOdaevkivsyxfOx47MbKxS4UMs/MRgVCrVNb0lRGh/wc7N9e1spN6Mxd6rbQ/U+dIVDmVN4e5vgzimAZJQ= 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=FmXaqu2t; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=9w1J7VWL; 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="FmXaqu2t"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="9w1J7VWL" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1785751484; 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: in-reply-to:in-reply-to:references:references; bh=iA1L8koirfsSOwpYSFrabj6XqsDC92pxOtrvhCX2Fxg=; b=FmXaqu2tMgaagEDn4RNspuC9k8qt27MrmrnemgqmVLu/Gow9jjOZ7SMrqSzF2X54kEp1hd EtJ93YzuB5XC0tqHj5QdKzzVjvRQldFjiz4Za3Xd8UrXh97RJCJ4B4LpJJso3g4oTqWF3D Fdun5I5/TQi2XUpbOYIJbOm1s8o1S7MV3Mb5iW8xox8unOLMYRTfvlBRlE+shHfce7dZRB 19/+6GVUVx+RAsJbOzfYKRp3gpxHL8cyDBD+Ff6RfZGj8ATh8akeJrlD0BIggCiRA26WBo 00ivq9zXxzjJVMKY6G7U2pBlEqX5Le6uPbJwU7AHO/FD2xcY1N1w/N0RmkJdUw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1785751484; 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: in-reply-to:in-reply-to:references:references; bh=iA1L8koirfsSOwpYSFrabj6XqsDC92pxOtrvhCX2Fxg=; b=9w1J7VWLEQ/vCAhCZy6USDixJ/HIByuuWkYrGLFDeBfzyGioCSxIW1KYnaH+3zSTlZHw2p CVi4IankstieLrAg== Date: Mon, 03 Aug 2026 12:04:35 +0200 Subject: [PATCH v2 04/17] timer_list: Use standard 'long long' format placeholders 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: <20260803-auxclock-nanosleep-prep-v2-4-910cbd485390@linutronix.de> References: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> In-Reply-To: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> To: John Stultz , Thomas Gleixner , Stephen Boyd , Miroslav Lichvar , Anna-Maria Behnsen , Frederic Weisbecker , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1785751481; l=3770; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=Xl1ObBJJ9doKi1YLNZSXz+OTP8phEgGASrTbmMr6rO0=; b=Pd8GZ+pkIgRrWOGtal98cJY/KMypJnr1IQMfVCFRYdhohj1luC/8QPrEl3vKWMr3kjGDdaAst kdCJfVkDyWmAB6wDegtKPPcHHN46QFpAUlF4BKxELe91r8b68uxnhf7 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= '%Ld' and '%Lu' are GNU extensions. While they do work for kernel code, checkpatch complains about them all the time. Replace them with the standard placeholders for 'long long' types, namely '%lld' and '%llu'. Signed-off-by: Thomas Wei=C3=9Fschuh (Schneider Electric) --- kernel/time/timer_list.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c index 8823e7dcfce6..ccbbb2ad1517 100644 --- a/kernel/time/timer_list.c +++ b/kernel/time/timer_list.c @@ -49,7 +49,7 @@ print_timer(struct seq_file *m, struct hrtimer *taddr, st= ruct hrtimer *timer, 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 %Lu-%Lu nsecs [in %Ld to %Ld nsecs]\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), @@ -101,7 +101,7 @@ print_base(struct seq_file *m, struct hrtimer_clock_bas= e *base, u64 now) =20 SEQ_printf(m, " .resolution: %u nsecs\n", hrtimer_resolution); #ifdef CONFIG_HIGH_RES_TIMERS - SEQ_printf(m, " .offset: %Ld nsecs\n", + SEQ_printf(m, " .offset: %lld nsecs\n", (long long) base->offset); #endif SEQ_printf(m, "active timers:\n"); @@ -122,10 +122,10 @@ static void print_cpu(struct seq_file *m, int cpu, u6= 4 now) #define DIAG_READ(x) data_race(READ_ONCE(x)) =20 #define P(x) \ - SEQ_printf(m, " .%-15s: %Lu\n", #x, \ + SEQ_printf(m, " .%-15s: %llu\n", #x, \ (unsigned long long)DIAG_READ(cpu_base->x)) #define P_ns(x) \ - SEQ_printf(m, " .%-15s: %Lu nsecs\n", #x, \ + SEQ_printf(m, " .%-15s: %llu nsecs\n", #x, \ (unsigned long long)ktime_to_ns(DIAG_READ(cpu_base->x))) =20 #ifdef CONFIG_HIGH_RES_TIMERS @@ -141,10 +141,10 @@ static void print_cpu(struct seq_file *m, int cpu, u6= 4 now) =20 #ifdef CONFIG_TICK_ONESHOT # define P(x) \ - SEQ_printf(m, " .%-15s: %Lu\n", #x, \ + SEQ_printf(m, " .%-15s: %llu\n", #x, \ (unsigned long long)DIAG_READ(ts->x)) # define P_ns(x) \ - SEQ_printf(m, " .%-15s: %Lu nsecs\n", #x, \ + SEQ_printf(m, " .%-15s: %llu nsecs\n", #x, \ (unsigned long long)ktime_to_ns(DIAG_READ(ts->x))) # define P_flag(x, f) \ SEQ_printf(m, " .%-15s: %d\n", #x, !!(DIAG_READ(ts->flags) & (f))) @@ -162,7 +162,7 @@ static void print_cpu(struct seq_file *m, int cpu, u64 = now) P(last_jiffies); P(next_timer); P_ns(idle_expires); - SEQ_printf(m, "jiffies: %Lu\n", + SEQ_printf(m, "jiffies: %llu\n", (unsigned long long)jiffies); } #endif @@ -201,7 +201,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: %Ld nsecs\n", + SEQ_printf(m, " next_event: %lld nsecs\n", (unsigned long long) ktime_to_ns(dev->next_event)); =20 SEQ_printf(m, " set_next_event: %ps\n", dev->set_next_event); @@ -259,7 +259,7 @@ static inline void timer_list_header(struct seq_file *m= , u64 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 %Ld nsecs\n", (unsigned long long)now); + SEQ_printf(m, "now at %lld nsecs\n", (unsigned long long)now); SEQ_printf(m, "\n"); } =20 --=20 2.55.0 From nobody Fri Oct 2 09:21:58 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 3F4F1377AAF; Mon, 3 Aug 2026 10:04:48 +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=1785751490; cv=none; b=c1bDTy8ko+9ZaN966V41/LuMlUH4UzMai0cJdhZ15RfRFnSC9FJPTcQohghn8uC5ouGMn0FIolB+mOABC2HgCJuIgcpNSiZBbdo8SxMc6A14i3fKE+zi/NIzIVSFZsZC9YQuefuXVgvsKwNw9JjcZM7Jlv8FTeGrbzg30Kt1jvk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785751490; c=relaxed/simple; bh=NipaXHPAq76M86EjLRyPE6b8t9xRLNeeTqhuOQMKWa0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gKnj19bFMScLPfmL8DSwEAB0vBK7SjMHFgt6jjYzElDH/OvOlYkuQlQZxwGrEDL9dhPZm20fBov46FhE5zHy3O4Dk2jEK27klOY0JE21FIxW1ZifuhmsLiWMtZORP5S6ap8D00D5lEb/b+yvHG8z7O7NbPk0PKrz4MDlNZP7EzI= 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=olNED2Ur; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=iSmPZLTn; 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="olNED2Ur"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="iSmPZLTn" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1785751485; 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: in-reply-to:in-reply-to:references:references; bh=KCS0g8a8OyZwzIP30riCL7VLYAsYU4rATP5iLUn/jy8=; b=olNED2UrwNBMoTMPyMznd3PlpIcrP0HHHQxUxquKOKINiDLckmSv2Z3/qY1mDq6pd2mr26 SInDs7fvQMuj6gTAg/lgyF1swJlgXwRxln5bzXyZKFrUZj1mPUhmeNN940DWm4Ko9l+OLt DwTStVueGA7b3Oe7uaKeKtOoNs7BKVv7AarODVgdyI1XU4laQg+KHp0COIqSpQrS/Jj1nj 7kOXvETYy7PkkYh4b7e1cUH7Xuj159350tZa/naKTcuBo/Bw7MdtyuyCJ1yjdOH1VveBir VrXyzqr8zOCHzeQKdlRJ3U0+Peq77z8TaDxuKzGl6xNHOQB0a4CRQUXgoq/oFg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1785751485; 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: in-reply-to:in-reply-to:references:references; bh=KCS0g8a8OyZwzIP30riCL7VLYAsYU4rATP5iLUn/jy8=; b=iSmPZLTndQJmDj0aJD3iKxCUyLzenE9bPliDJrxh/PAu08ic2oF3FkBBXcrTZjsVqbl4bz zVHq6944OrVUydCg== Date: Mon, 03 Aug 2026 12:04:36 +0200 Subject: [PATCH v2 05/17] timer_list: Use ktime_t over nanoseconds 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: <20260803-auxclock-nanosleep-prep-v2-5-910cbd485390@linutronix.de> References: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> In-Reply-To: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> To: John Stultz , Thomas Gleixner , Stephen Boyd , Miroslav Lichvar , Anna-Maria Behnsen , Frederic Weisbecker , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1785751481; l=6459; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=NipaXHPAq76M86EjLRyPE6b8t9xRLNeeTqhuOQMKWa0=; b=VT/LX1vmx2SZRiT/5NApnRkbmXADeWVTVyFjc6hU3o3wUMggZyxMgr8QhZvTPLhP+VAhH/Fnc MBHxOOQveLkARtJ8y3PGmjmGRvq3OJdWPzv0USxMWld+ZZUgsFHOOQq X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= 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) --- 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 ccbbb2ad1517..0406bf4488e9 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 @@ static void print_active_timers(struct seq_file *m, struc= t hrtimer_clock_base *b } =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); --=20 2.55.0 From nobody Fri Oct 2 09:21:58 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 3C8A3377AA9; Mon, 3 Aug 2026 10:04:48 +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=1785751490; cv=none; b=o7UuwO0r5Ez2FTibq3Xz4NAt/lnYcC5UnRYRBxC6Ybll3IF5xhU1cIOYEueLKKo8C2LQFYxGyHGgHg2iuO0k8RmIw9YBetehevfijxelcGVhx4CHDBVO4L8KDqiu41Gs73SqClP5mtz99FHTKuZE7FUQyYZpOdkP2P5PTk3t/ac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785751490; c=relaxed/simple; bh=2/uqxyH8nRrSI9Tp43KO4NjA4MFqIVh4Dk3AtGbUK2g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qpjMtTgqgX3pIMytkc1DYAqPzbtWHvlZ/3gcLdNXRUr+QnuKGWlsh3OwzZE4Wdzz0GM3mmVNm4Ug+48bnVzsB9gAHEoF5hiNUyFmFQSIUrTAejsKwFSsq9uUHe8ujjtgOQj89WSVA59U8tcGMiP1ENj5+Oim4TEbFjqw7nw68rE= 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=DZiMNZN4; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=45LkmzdF; 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="DZiMNZN4"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="45LkmzdF" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1785751486; 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: in-reply-to:in-reply-to:references:references; bh=Ld+PasTMK75cPP06BWvC5R5pk+Vn/AN5qLyJpKdtxr0=; b=DZiMNZN4zwqDY4wpz5jqX5qrefWmk9uP0jRurWoVZkc632eOe2uGlC+2EhWzEswJGwBumk lOIaCA7IyAFBshjSmNknQ6C4M3um+lGv+5KgM0bUIRVpmCgVihZ4YxOmccOvmp/R3CVA0Y Mlt10XpVSc+YsXzZP9KlUQc8wfSaQd8GbvBBOFDGSrFbswmzuUzlINEz9LxI1w8TiQPc5w 6KRUst49uWUF+K/3MaPVueNNSFpzQBlcPXY+89QZcCUfC52pKtENpo0CEKQkfEuLM7wxiw 7hNiabSqbSxz0cazOKuoG/OAyp8yflKbWTnu/xcqwUFP6JYX/KnXIehrPcsIFw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1785751486; 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: in-reply-to:in-reply-to:references:references; bh=Ld+PasTMK75cPP06BWvC5R5pk+Vn/AN5qLyJpKdtxr0=; b=45LkmzdF1Wm3Xuko7EEYrdiSBOvJL+skOLSw1/rR0ntffZCr/L40L9wwz1ymwPNhsegtlB oG4D7lZwdvHnizBQ== Date: Mon, 03 Aug 2026 12:04:37 +0200 Subject: [PATCH v2 06/17] selftests: add clock-helpers.h 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: <20260803-auxclock-nanosleep-prep-v2-6-910cbd485390@linutronix.de> References: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> In-Reply-To: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> To: John Stultz , Thomas Gleixner , Stephen Boyd , Miroslav Lichvar , Anna-Maria Behnsen , Frederic Weisbecker , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1785751481; l=2514; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=2/uqxyH8nRrSI9Tp43KO4NjA4MFqIVh4Dk3AtGbUK2g=; b=lN8pcQto4RwRBI+w6EUFRoA4s4cbhfR1MJRO4Ys5x5hWRtc5Ci74Wmkuy32mWpoC/2RKTwY9M lVYWFK3JqwKCT5002foE2mSrTt2Bb9c5xcz4EsYKKCK2n4e/s9Bhp1g X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Multiple selftests duplicate various clock-related functionality. Add a new header to collect and deduplicate those. Signed-off-by: Thomas Wei=C3=9Fschuh (Schneider Electric) Acked-by: John Stultz --- tools/testing/selftests/clock-helpers.h | 76 +++++++++++++++++++++++++++++= ++++ 1 file changed, 76 insertions(+) diff --git a/tools/testing/selftests/clock-helpers.h b/tools/testing/selfte= sts/clock-helpers.h new file mode 100644 index 000000000000..01451f538e71 --- /dev/null +++ b/tools/testing/selftests/clock-helpers.h @@ -0,0 +1,76 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __CLOCK_HELPERS_H +#define __CLOCK_HELPERS_H + +#include +#include + +#define MSEC_PER_SEC 1000LL +#define USEC_PER_MSEC 1000LL +#define NSEC_PER_USEC 1000LL +#define NSEC_PER_MSEC 1000000LL +#define USEC_PER_SEC 1000000LL +#define NSEC_PER_SEC 1000000000LL +#define PSEC_PER_SEC 1000000000000LL +#define FSEC_PER_SEC 1000000000000000LL + +#ifndef CLOCK_AUX +#define CLOCK_AUX 16 +#endif + +#ifndef MAX_AUX_CLOCKS +#define MAX_AUX_CLOCKS 8 +#endif + +#ifndef CLOCK_AUX_LAST +#define CLOCK_AUX_LAST (CLOCK_AUX + MAX_AUX_CLOCKS - 1) +#endif + +__attribute__((unused)) +static inline const char *clock_name(clockid_t clockid) +{ + switch (clockid) { + case CLOCK_REALTIME: + return "CLOCK_REALTIME"; + case CLOCK_MONOTONIC: + return "CLOCK_MONOTONIC"; + case CLOCK_PROCESS_CPUTIME_ID: + return "CLOCK_PROCESS_CPUTIME_ID"; + case CLOCK_THREAD_CPUTIME_ID: + return "CLOCK_THREAD_CPUTIME_ID"; + case CLOCK_MONOTONIC_RAW: + return "CLOCK_MONOTONIC_RAW"; + case CLOCK_REALTIME_COARSE: + return "CLOCK_REALTIME_COARSE"; + case CLOCK_MONOTONIC_COARSE: + return "CLOCK_MONOTONIC_COARSE"; + case CLOCK_BOOTTIME: + return "CLOCK_BOOTTIME"; + case CLOCK_REALTIME_ALARM: + return "CLOCK_REALTIME_ALARM"; + case CLOCK_BOOTTIME_ALARM: + return "CLOCK_BOOTTIME_ALARM"; + case CLOCK_TAI: + return "CLOCK_TAI"; + case CLOCK_AUX + 0: + return "CLOCK_AUX0"; + case CLOCK_AUX + 1: + return "CLOCK_AUX1"; + case CLOCK_AUX + 2: + return "CLOCK_AUX2"; + case CLOCK_AUX + 3: + return "CLOCK_AUX3"; + case CLOCK_AUX + 4: + return "CLOCK_AUX4"; + case CLOCK_AUX + 5: + return "CLOCK_AUX5"; + case CLOCK_AUX + 6: + return "CLOCK_AUX6"; + case CLOCK_AUX + 7: + return "CLOCK_AUX7"; + }; + return "UNKNOWN_CLOCKID"; +} + +#endif /* __CLOCK_HELPERS_H */ --=20 2.55.0 From nobody Fri Oct 2 09:21:58 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 3C7BB377AA1; Mon, 3 Aug 2026 10:04:48 +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=1785751491; cv=none; b=T1llI4c3Bvzx1zSi++mBJP7aaoDwVGiBM75pmSW197Gq/7EETfsQTcqcN9PqJM845yHI0W4A1Z7v2BnP9+uCd2qDkR2OE1aq8i0wORk7zxkuOVU9wQDCMDlbO7mvYQ/wl6+Fsutc8mLU8FIoWuluVgGVahouh9Kh/tlmjJ0kEsk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785751491; c=relaxed/simple; bh=tNVfgsNpR+KNFBAqIYjnpyArUQ01r7L5Sf9RSOFmQBY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MKjZipedN7l5qbLKU5b1BcEHBK4sTHGeR5SE9bG5rz8P17r6AoBOmL4tw2T2yww7olwlT34nAMwlSYjQrh3qKIJLswPE0/iKazSPFJsjarc70HwBbAQESfkiH82dQE5OnqzKGFtD33Z0Wk1eN0wZGM/nZdNDX89ZSqnXX1NvlUc= 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=cUrr4ZGX; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=lIGHHTXJ; 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="cUrr4ZGX"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="lIGHHTXJ" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1785751486; 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: in-reply-to:in-reply-to:references:references; bh=l2NfWMgxl5N9dLxtXi9s697396YGqT5oS60eaAe8AAA=; b=cUrr4ZGX1anhkMKqfiakDfX8Tdm77OMQzMvcg9L5Ik3VmFruO1SYkClanVmtmh5WB7hVbu pPKbEFU435E56nbGm7aAmqP6BouniBwNSAFpqkaGoFS843jwUWg0ZWQsPrvZc78AR8q7HX 5OVQYD2TldAPTaAmcpoWMsNU3l9Q5rE15P3mGpMjbpyeIukSZaCD1EwlQrcTTBYz3AEkpH 1X+zfNFaXll+eiIXNnZlyEYLBSDZjnkGwa4wu86xu7dKkUuhnl6eKZjDebNH7WmPoYkeMs clZsG8j6q4Rl7lTOXrtyWFPdmGpPramwzdtnwAdt8Tv8ce36IL6UHq0iSBIWAg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1785751486; 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: in-reply-to:in-reply-to:references:references; bh=l2NfWMgxl5N9dLxtXi9s697396YGqT5oS60eaAe8AAA=; b=lIGHHTXJzUkvMU/5s5cZs5nNrxf/dHqclCyyK3tSh5lN3h2g8zAu3N3m23fddq0d0VBhGh eapoCpItTUj6iQBQ== Date: Mon, 03 Aug 2026 12:04:38 +0200 Subject: [PATCH v2 07/17] selftests: timers: Use clock_name() and constants from clock-helpers.h 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: <20260803-auxclock-nanosleep-prep-v2-7-910cbd485390@linutronix.de> References: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> In-Reply-To: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> To: John Stultz , Thomas Gleixner , Stephen Boyd , Miroslav Lichvar , Anna-Maria Behnsen , Frederic Weisbecker , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1785751481; l=19740; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=tNVfgsNpR+KNFBAqIYjnpyArUQ01r7L5Sf9RSOFmQBY=; b=JSkOcyNSF8brhW0nEp+E4rPayfBsXpA1Kws8r9y0jUImyYlG3O15ElMJr6rUWZygzA8V2CpdO 8vtw3s1uDe+CCRFF3h3AA20oghpVHyunWLkOoWl0EkIuAa1692Kv95x X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Replace the many repetitions of custom clockid_t to string translation with the clock_name() helper from clock-helpers.h. Also drop the custom ?SEC_PER_?SEC definitions. Signed-off-by: Thomas Wei=C3=9Fschuh (Schneider Electric) Acked-by: John Stultz --- tools/testing/selftests/timers/adjtick.c | 5 ++- .../testing/selftests/timers/alarmtimer-suspend.c | 38 ++----------------= -- .../testing/selftests/timers/inconsistency-check.c | 38 +++---------------= -- tools/testing/selftests/timers/leap-a-day.c | 3 +- tools/testing/selftests/timers/mqueue-lat.c | 3 +- tools/testing/selftests/timers/nanosleep.c | 42 ++++--------------= ---- tools/testing/selftests/timers/nsleep-lat.c | 36 ++----------------- tools/testing/selftests/timers/posix_timers.c | 36 ++++++++++--------- tools/testing/selftests/timers/raw_skew.c | 3 +- tools/testing/selftests/timers/set-2038.c | 3 +- tools/testing/selftests/timers/set-timer-lat.c | 41 +++---------------= --- tools/testing/selftests/timers/valid-adjtimex.c | 4 +-- 12 files changed, 47 insertions(+), 205 deletions(-) diff --git a/tools/testing/selftests/timers/adjtick.c b/tools/testing/selft= ests/timers/adjtick.c index 22d274d5520f..68009a6d6de8 100644 --- a/tools/testing/selftests/timers/adjtick.c +++ b/tools/testing/selftests/timers/adjtick.c @@ -22,10 +22,9 @@ #include #include #include -#include "kselftest.h" =20 -#define NSEC_PER_SEC 1000000000LL -#define USEC_PER_SEC 1000000LL +#include "clock-helpers.h" +#include "kselftest.h" =20 #define MILLION 1000000 =20 diff --git a/tools/testing/selftests/timers/alarmtimer-suspend.c b/tools/te= sting/selftests/timers/alarmtimer-suspend.c index d55d5b0377c6..120b3ce8b39e 100644 --- a/tools/testing/selftests/timers/alarmtimer-suspend.c +++ b/tools/testing/selftests/timers/alarmtimer-suspend.c @@ -29,10 +29,9 @@ #include #include #include +#include "clock-helpers.h" #include "kselftest.h" =20 -#define NSEC_PER_SEC 1000000000LL - #define UNREASONABLE_LAT (NSEC_PER_SEC * 5) /* hopefully we resume in 5 se= cs */ =20 #define SUSPEND_SECS 15 @@ -40,37 +39,6 @@ int alarmcount; int alarm_clock_id; struct timespec start_time; =20 - -char *clockstring(int clockid) -{ - switch (clockid) { - case CLOCK_REALTIME: - return "CLOCK_REALTIME"; - case CLOCK_MONOTONIC: - return "CLOCK_MONOTONIC"; - case CLOCK_PROCESS_CPUTIME_ID: - return "CLOCK_PROCESS_CPUTIME_ID"; - case CLOCK_THREAD_CPUTIME_ID: - return "CLOCK_THREAD_CPUTIME_ID"; - case CLOCK_MONOTONIC_RAW: - return "CLOCK_MONOTONIC_RAW"; - case CLOCK_REALTIME_COARSE: - return "CLOCK_REALTIME_COARSE"; - case CLOCK_MONOTONIC_COARSE: - return "CLOCK_MONOTONIC_COARSE"; - case CLOCK_BOOTTIME: - return "CLOCK_BOOTTIME"; - case CLOCK_REALTIME_ALARM: - return "CLOCK_REALTIME_ALARM"; - case CLOCK_BOOTTIME_ALARM: - return "CLOCK_BOOTTIME_ALARM"; - case CLOCK_TAI: - return "CLOCK_TAI"; - } - return "UNKNOWN_CLOCKID"; -} - - long long timespec_sub(struct timespec a, struct timespec b) { long long ret =3D NSEC_PER_SEC * b.tv_sec + b.tv_nsec; @@ -130,12 +98,12 @@ int main(void) alarmcount =3D 0; if (timer_create(alarm_clock_id, &se, &tm1) =3D=3D -1) { printf("timer_create failed, %s unsupported?: %s\n", - clockstring(alarm_clock_id), strerror(errno)); + clock_name(alarm_clock_id), strerror(errno)); break; } =20 clock_gettime(alarm_clock_id, &start_time); - printf("Start time (%s): %ld:%ld\n", clockstring(alarm_clock_id), + printf("Start time (%s): %ld:%ld\n", clock_name(alarm_clock_id), start_time.tv_sec, start_time.tv_nsec); printf("Setting alarm for every %i seconds\n", SUSPEND_SECS); its1.it_value =3D start_time; diff --git a/tools/testing/selftests/timers/inconsistency-check.c b/tools/t= esting/selftests/timers/inconsistency-check.c index 9ab7066b4e32..d7982ac4bd18 100644 --- a/tools/testing/selftests/timers/inconsistency-check.c +++ b/tools/testing/selftests/timers/inconsistency-check.c @@ -28,44 +28,14 @@ #include #include #include +#include "clock-helpers.h" #include "kselftest.h" =20 -#define NSEC_PER_SEC 1000000000LL - /* CLOCK_HWSPECIFIC =3D=3D CLOCK_SGI_CYCLE (Deprecated) */ #define CLOCK_HWSPECIFIC 10 =20 #define CALLS_PER_LOOP 64 =20 -char *clockstring(int clockid) -{ - switch (clockid) { - case CLOCK_REALTIME: - return "CLOCK_REALTIME"; - case CLOCK_MONOTONIC: - return "CLOCK_MONOTONIC"; - case CLOCK_PROCESS_CPUTIME_ID: - return "CLOCK_PROCESS_CPUTIME_ID"; - case CLOCK_THREAD_CPUTIME_ID: - return "CLOCK_THREAD_CPUTIME_ID"; - case CLOCK_MONOTONIC_RAW: - return "CLOCK_MONOTONIC_RAW"; - case CLOCK_REALTIME_COARSE: - return "CLOCK_REALTIME_COARSE"; - case CLOCK_MONOTONIC_COARSE: - return "CLOCK_MONOTONIC_COARSE"; - case CLOCK_BOOTTIME: - return "CLOCK_BOOTTIME"; - case CLOCK_REALTIME_ALARM: - return "CLOCK_REALTIME_ALARM"; - case CLOCK_BOOTTIME_ALARM: - return "CLOCK_BOOTTIME_ALARM"; - case CLOCK_TAI: - return "CLOCK_TAI"; - } - return "UNKNOWN_CLOCKID"; -} - /* returns 1 if a <=3D b, 0 otherwise */ static inline int in_order(struct timespec a, struct timespec b) { @@ -172,15 +142,15 @@ int main(int argc, char *argv[]) for (clockid =3D userclock; clockid < maxclocks; clockid++) { =20 if (clockid =3D=3D CLOCK_HWSPECIFIC || clock_gettime(clockid, &ts)) { - ksft_test_result_skip("%-31s\n", clockstring(clockid)); + ksft_test_result_skip("%-31s\n", clock_name(clockid)); continue; } =20 if (consistency_test(clockid, runtime)) { - ksft_test_result_fail("%-31s\n", clockstring(clockid)); + ksft_test_result_fail("%-31s\n", clock_name(clockid)); ksft_exit_fail(); } else { - ksft_test_result_pass("%-31s\n", clockstring(clockid)); + ksft_test_result_pass("%-31s\n", clock_name(clockid)); } } ksft_exit_pass(); diff --git a/tools/testing/selftests/timers/leap-a-day.c b/tools/testing/se= lftests/timers/leap-a-day.c index 71b49734e08c..b93cb5714b37 100644 --- a/tools/testing/selftests/timers/leap-a-day.c +++ b/tools/testing/selftests/timers/leap-a-day.c @@ -51,10 +51,9 @@ #include #include #include +#include "clock-helpers.h" #include "kselftest.h" =20 -#define NSEC_PER_SEC 1000000000LL - #define CLOCK_TAI 11 =20 time_t next_leap; diff --git a/tools/testing/selftests/timers/mqueue-lat.c b/tools/testing/se= lftests/timers/mqueue-lat.c index ce8700c95cac..fa4c3e3f58fe 100644 --- a/tools/testing/selftests/timers/mqueue-lat.c +++ b/tools/testing/selftests/timers/mqueue-lat.c @@ -29,10 +29,9 @@ #include #include #include +#include "clock-helpers.h" #include "kselftest.h" =20 -#define NSEC_PER_SEC 1000000000LL - =20 #define TARGET_TIMEOUT 100000000 /* 100ms in nanoseconds */ #define UNRESONABLE_LATENCY 40000000 /* 40ms in nanosecs */ diff --git a/tools/testing/selftests/timers/nanosleep.c b/tools/testing/sel= ftests/timers/nanosleep.c index ceff18149a48..7df86dfc897f 100644 --- a/tools/testing/selftests/timers/nanosleep.c +++ b/tools/testing/selftests/timers/nanosleep.c @@ -27,44 +27,14 @@ #include #include #include +#include "clock-helpers.h" #include "kselftest.h" =20 -#define NSEC_PER_SEC 1000000000LL - /* CLOCK_HWSPECIFIC =3D=3D CLOCK_SGI_CYCLE (Deprecated) */ #define CLOCK_HWSPECIFIC 10 =20 #define UNSUPPORTED 0xf00f =20 -char *clockstring(int clockid) -{ - switch (clockid) { - case CLOCK_REALTIME: - return "CLOCK_REALTIME"; - case CLOCK_MONOTONIC: - return "CLOCK_MONOTONIC"; - case CLOCK_PROCESS_CPUTIME_ID: - return "CLOCK_PROCESS_CPUTIME_ID"; - case CLOCK_THREAD_CPUTIME_ID: - return "CLOCK_THREAD_CPUTIME_ID"; - case CLOCK_MONOTONIC_RAW: - return "CLOCK_MONOTONIC_RAW"; - case CLOCK_REALTIME_COARSE: - return "CLOCK_REALTIME_COARSE"; - case CLOCK_MONOTONIC_COARSE: - return "CLOCK_MONOTONIC_COARSE"; - case CLOCK_BOOTTIME: - return "CLOCK_BOOTTIME"; - case CLOCK_REALTIME_ALARM: - return "CLOCK_REALTIME_ALARM"; - case CLOCK_BOOTTIME_ALARM: - return "CLOCK_BOOTTIME_ALARM"; - case CLOCK_TAI: - return "CLOCK_TAI"; - }; - return "UNKNOWN_CLOCKID"; -} - /* returns 1 if a <=3D b, 0 otherwise */ static inline int in_order(struct timespec a, struct timespec b) { @@ -182,7 +152,7 @@ int main(int argc, char **argv) if (clockid =3D=3D CLOCK_PROCESS_CPUTIME_ID || clockid =3D=3D CLOCK_THREAD_CPUTIME_ID || clockid =3D=3D CLOCK_HWSPECIFIC) { - ksft_test_result_skip("%-31s\n", clockstring(clockid)); + ksft_test_result_skip("%-31s\n", clock_name(clockid)); continue; } =20 @@ -192,21 +162,21 @@ int main(int argc, char **argv) while (length <=3D (NSEC_PER_SEC * 10)) { ret =3D nanosleep_test(clockid, length); if (ret =3D=3D UNSUPPORTED) { - ksft_test_result_skip("%-31s\n", clockstring(clockid)); + ksft_test_result_skip("%-31s\n", clock_name(clockid)); goto next; } if (ret < 0) { - ksft_test_result_fail("%-31s\n", clockstring(clockid)); + ksft_test_result_fail("%-31s\n", clock_name(clockid)); ksft_exit_fail(); } length *=3D 100; } ret =3D nanosleep_test_remaining(clockid); if (ret < 0) { - ksft_test_result_fail("%-31s\n", clockstring(clockid)); + ksft_test_result_fail("%-31s\n", clock_name(clockid)); ksft_exit_fail(); } - ksft_test_result_pass("%-31s\n", clockstring(clockid)); + ksft_test_result_pass("%-31s\n", clock_name(clockid)); next: ret =3D 0; } diff --git a/tools/testing/selftests/timers/nsleep-lat.c b/tools/testing/se= lftests/timers/nsleep-lat.c index 15f6493ca7b5..d22973c87f21 100644 --- a/tools/testing/selftests/timers/nsleep-lat.c +++ b/tools/testing/selftests/timers/nsleep-lat.c @@ -24,10 +24,9 @@ #include #include #include +#include "clock-helpers.h" #include "kselftest.h" =20 -#define NSEC_PER_SEC 1000000000LL - #define UNRESONABLE_LATENCY 40000000 /* 40ms in nanosecs */ =20 /* CLOCK_HWSPECIFIC =3D=3D CLOCK_SGI_CYCLE (Deprecated) */ @@ -35,35 +34,6 @@ =20 #define UNSUPPORTED 0xf00f =20 -char *clockstring(int clockid) -{ - switch (clockid) { - case CLOCK_REALTIME: - return "CLOCK_REALTIME"; - case CLOCK_MONOTONIC: - return "CLOCK_MONOTONIC"; - case CLOCK_PROCESS_CPUTIME_ID: - return "CLOCK_PROCESS_CPUTIME_ID"; - case CLOCK_THREAD_CPUTIME_ID: - return "CLOCK_THREAD_CPUTIME_ID"; - case CLOCK_MONOTONIC_RAW: - return "CLOCK_MONOTONIC_RAW"; - case CLOCK_REALTIME_COARSE: - return "CLOCK_REALTIME_COARSE"; - case CLOCK_MONOTONIC_COARSE: - return "CLOCK_MONOTONIC_COARSE"; - case CLOCK_BOOTTIME: - return "CLOCK_BOOTTIME"; - case CLOCK_REALTIME_ALARM: - return "CLOCK_REALTIME_ALARM"; - case CLOCK_BOOTTIME_ALARM: - return "CLOCK_BOOTTIME_ALARM"; - case CLOCK_TAI: - return "CLOCK_TAI"; - }; - return "UNKNOWN_CLOCKID"; -} - struct timespec timespec_add(struct timespec ts, unsigned long long ns) { ts.tv_nsec +=3D ns; @@ -156,10 +126,10 @@ int main(int argc, char **argv) } =20 if (ret =3D=3D UNSUPPORTED) { - ksft_test_result_skip("%s\n", clockstring(clockid)); + ksft_test_result_skip("%s\n", clock_name(clockid)); } else { ksft_test_result(ret >=3D 0, "%s\n", - clockstring(clockid)); + clock_name(clockid)); } } =20 diff --git a/tools/testing/selftests/timers/posix_timers.c b/tools/testing/= selftests/timers/posix_timers.c index fa168d802f9e..a92d4b957747 100644 --- a/tools/testing/selftests/timers/posix_timers.c +++ b/tools/testing/selftests/timers/posix_timers.c @@ -19,11 +19,9 @@ #include #include =20 +#include "clock-helpers.h" #include "kselftest.h" =20 -#define NSEC_PER_SEC 1000000000LL -#define USEC_PER_SEC 1000000LL - #define DELAY 2 =20 static void __fatal_error(const char *test, const char *name, const char *= what) @@ -143,8 +141,9 @@ static void check_itimer(int which, const char *name) ksft_test_result(check_diff(start, end) =3D=3D 0, "%s\n", name); } =20 -static void check_timer_create(int which, const char *name) +static void check_timer_create(int which) { + const char *name =3D clock_name(which); struct timespec start, end; struct itimerspec val =3D { .it_value.tv_sec =3D DELAY, @@ -457,8 +456,9 @@ static void check_delete(void) ksft_test_result(!tsig.signals, "check_delete\n"); } =20 -static void check_sigev_none(int which, const char *name) +static void check_sigev_none(int which) { + const char *name =3D clock_name(which); struct timespec start, now; struct itimerspec its; struct sigevent sev; @@ -495,8 +495,9 @@ static void check_sigev_none(int which, const char *nam= e) "check_sigev_none %s\n", name); } =20 -static void check_gettime(int which, const char *name) +static void check_gettime(int which) { + const char *name =3D clock_name(which); struct itimerspec its, prev; struct timespec start, now; struct sigevent sev; @@ -548,8 +549,9 @@ static void check_gettime(int which, const char *name) ksft_test_result(wraps > 1, "check_gettime %s\n", name); } =20 -static void check_overrun(int which, const char *name) +static void check_overrun(int which) { + const char *name =3D clock_name(which); struct timespec start, now; struct tmrsig tsig =3D { }; struct itimerspec its; @@ -691,7 +693,7 @@ int main(int argc, char **argv) check_itimer(ITIMER_VIRTUAL, "ITIMER_VIRTUAL"); check_itimer(ITIMER_PROF, "ITIMER_PROF"); check_itimer(ITIMER_REAL, "ITIMER_REAL"); - check_timer_create(CLOCK_THREAD_CPUTIME_ID, "CLOCK_THREAD_CPUTIME_ID"); + check_timer_create(CLOCK_THREAD_CPUTIME_ID); =20 /* * It's unfortunately hard to reliably test a timer expiration @@ -702,7 +704,7 @@ int main(int argc, char **argv) * to ensure true parallelism. So test only one thread until we * find a better solution. */ - check_timer_create(CLOCK_PROCESS_CPUTIME_ID, "CLOCK_PROCESS_CPUTIME_ID"); + check_timer_create(CLOCK_PROCESS_CPUTIME_ID); check_timer_distribution(); =20 if (run_sig_ign_tests) { @@ -710,18 +712,18 @@ int main(int argc, char **argv) check_sig_ign(1); check_rearm(); check_delete(); - check_sigev_none(CLOCK_MONOTONIC, "CLOCK_MONOTONIC"); - check_sigev_none(CLOCK_PROCESS_CPUTIME_ID, "CLOCK_PROCESS_CPUTIME_ID"); - check_gettime(CLOCK_MONOTONIC, "CLOCK_MONOTONIC"); - check_gettime(CLOCK_PROCESS_CPUTIME_ID, "CLOCK_PROCESS_CPUTIME_ID"); - check_gettime(CLOCK_THREAD_CPUTIME_ID, "CLOCK_THREAD_CPUTIME_ID"); + check_sigev_none(CLOCK_MONOTONIC); + check_sigev_none(CLOCK_PROCESS_CPUTIME_ID); + check_gettime(CLOCK_MONOTONIC); + check_gettime(CLOCK_PROCESS_CPUTIME_ID); + check_gettime(CLOCK_THREAD_CPUTIME_ID); } else { ksft_print_msg("Skipping SIG_IGN tests on kernel < 6.13\n"); } =20 - check_overrun(CLOCK_MONOTONIC, "CLOCK_MONOTONIC"); - check_overrun(CLOCK_PROCESS_CPUTIME_ID, "CLOCK_PROCESS_CPUTIME_ID"); - check_overrun(CLOCK_THREAD_CPUTIME_ID, "CLOCK_THREAD_CPUTIME_ID"); + check_overrun(CLOCK_MONOTONIC); + check_overrun(CLOCK_PROCESS_CPUTIME_ID); + check_overrun(CLOCK_THREAD_CPUTIME_ID); =20 ksft_finished(); } diff --git a/tools/testing/selftests/timers/raw_skew.c b/tools/testing/self= tests/timers/raw_skew.c index 2dd16cb4cdd0..0c87a8fb0d7f 100644 --- a/tools/testing/selftests/timers/raw_skew.c +++ b/tools/testing/selftests/timers/raw_skew.c @@ -25,10 +25,9 @@ #include #include #include +#include "clock-helpers.h" #include "kselftest.h" =20 -#define NSEC_PER_SEC 1000000000LL - #define shift_right(x, s) ({ \ __typeof__(x) __x =3D (x); \ __typeof__(s) __s =3D (s); \ diff --git a/tools/testing/selftests/timers/set-2038.c b/tools/testing/self= tests/timers/set-2038.c index c1235638406d..f522a3035ec6 100644 --- a/tools/testing/selftests/timers/set-2038.c +++ b/tools/testing/selftests/timers/set-2038.c @@ -27,10 +27,9 @@ #include #include #include +#include "clock-helpers.h" #include "kselftest.h" =20 -#define NSEC_PER_SEC 1000000000LL - #define KTIME_MAX ((long long)~((unsigned long long)1 << 63)) #define KTIME_SEC_MAX (KTIME_MAX / NSEC_PER_SEC) =20 diff --git a/tools/testing/selftests/timers/set-timer-lat.c b/tools/testing= /selftests/timers/set-timer-lat.c index e092c18befff..79ddba25d314 100644 --- a/tools/testing/selftests/timers/set-timer-lat.c +++ b/tools/testing/selftests/timers/set-timer-lat.c @@ -28,10 +28,9 @@ #include #include #include +#include "clock-helpers.h" #include "kselftest.h" =20 -#define NSEC_PER_SEC 1000000000LL - /* CLOCK_HWSPECIFIC =3D=3D CLOCK_SGI_CYCLE (Deprecated) */ #define CLOCK_HWSPECIFIC 10 =20 @@ -44,36 +43,6 @@ struct timespec start_time; long long max_latency_ns; int timer_fired_early; =20 -char *clockstring(int clockid) -{ - switch (clockid) { - case CLOCK_REALTIME: - return "CLOCK_REALTIME"; - case CLOCK_MONOTONIC: - return "CLOCK_MONOTONIC"; - case CLOCK_PROCESS_CPUTIME_ID: - return "CLOCK_PROCESS_CPUTIME_ID"; - case CLOCK_THREAD_CPUTIME_ID: - return "CLOCK_THREAD_CPUTIME_ID"; - case CLOCK_MONOTONIC_RAW: - return "CLOCK_MONOTONIC_RAW"; - case CLOCK_REALTIME_COARSE: - return "CLOCK_REALTIME_COARSE"; - case CLOCK_MONOTONIC_COARSE: - return "CLOCK_MONOTONIC_COARSE"; - case CLOCK_BOOTTIME: - return "CLOCK_BOOTTIME"; - case CLOCK_REALTIME_ALARM: - return "CLOCK_REALTIME_ALARM"; - case CLOCK_BOOTTIME_ALARM: - return "CLOCK_BOOTTIME_ALARM"; - case CLOCK_TAI: - return "CLOCK_TAI"; - } - return "UNKNOWN_CLOCKID"; -} - - long long timespec_sub(struct timespec a, struct timespec b) { long long ret =3D NSEC_PER_SEC * b.tv_sec + b.tv_nsec; @@ -104,7 +73,7 @@ void sigalarm(int signo) void describe_timer(int flags, int interval) { printf("%-22s %s %s ", - clockstring(clock_id), + clock_name(clock_id), flags ? "ABSTIME":"RELTIME", interval ? "PERIODIC":"ONE-SHOT"); } @@ -130,12 +99,12 @@ int setup_timer(int clock_id, int flags, int interval,= timer_t *tm1) if ((clock_id =3D=3D CLOCK_REALTIME_ALARM) || (clock_id =3D=3D CLOCK_BOOTTIME_ALARM)) { printf("%-22s %s missing CAP_WAKE_ALARM? : [UNSUPPORTED]\n", - clockstring(clock_id), + clock_name(clock_id), flags ? "ABSTIME":"RELTIME"); /* Indicate timer isn't set, so caller doesn't wait */ return 1; } - printf("%s - timer_create() failed\n", clockstring(clock_id)); + printf("%s - timer_create() failed\n", clock_name(clock_id)); return -1; } =20 @@ -152,7 +121,7 @@ int setup_timer(int clock_id, int flags, int interval, = timer_t *tm1) =20 err =3D timer_settime(*tm1, flags, &its1, &its2); if (err) { - printf("%s - timer_settime() failed\n", clockstring(clock_id)); + printf("%s - timer_settime() failed\n", clock_name(clock_id)); return -1; } =20 diff --git a/tools/testing/selftests/timers/valid-adjtimex.c b/tools/testin= g/selftests/timers/valid-adjtimex.c index dc2559eb11a5..f641d5fb0902 100644 --- a/tools/testing/selftests/timers/valid-adjtimex.c +++ b/tools/testing/selftests/timers/valid-adjtimex.c @@ -29,11 +29,9 @@ #include #include #include +#include "clock-helpers.h" #include "kselftest.h" =20 -#define NSEC_PER_SEC 1000000000LL -#define USEC_PER_SEC 1000000LL - #define ADJ_SETOFFSET 0x0100 =20 #include --=20 2.55.0 From nobody Fri Oct 2 09:21:58 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 8214B377EBF; Mon, 3 Aug 2026 10:04:48 +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=1785751490; cv=none; b=NM4/ydqtNpUXQjN4az3008ILTfiv5zZY2smJ8SfzoatcjRUJORUJVPbZpNad8qwxnsArwUDEEcD0zz9NBnVuytTPJAzpKmgflm9XWR+YvelIMko5g6uJt43Yb7hylETmmXix9NNu+ZMQ5Xh8KSDW1JlOk+cpDardcxOIz8mKgpM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785751490; c=relaxed/simple; bh=JW7wm5Gnp8xFVFmYee+ahof9lgO/Vkd2KI6W/DXDmR4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hk7OnKdRJCOZkUYUdIWVVgJmMXwCCBFN0n5xRgx6TtSagquaszsvWBZl3F33Obj1Hc3bTnzfSqTkx08wn+iu3+r8EitURJkXHDP3Q16KQDMCUwn5hIBqSPtBFrwSa9Htv2MkZYbG+zCNZxd6T2956Og7vDpxkNSeML02VFS6wbU= 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=XaU5g/kr; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=RCRyTnKm; 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="XaU5g/kr"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="RCRyTnKm" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1785751487; 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: in-reply-to:in-reply-to:references:references; bh=EJXfOI9ACfmuS1BdwEmhxJUA4MF5NiefRYfYZpQNmVU=; b=XaU5g/kr8mc4FAqmMkJzrdyPO/WU6X/NBUyuixqlR/Q4YwhPDN1HBShTQQBYU4u6IWCraI NuQPd8ehT4Mo7NW6ZIxCsMbBYTUm7j3FG/8XvnuEVBQyBcQbLTOJSWPMWJcjO5Uycjtq6V DpgPlTV9OLqyz0aZouQB8KdX+CQ1MCQfvjkL9OL6G2wr+T4v36tegaRkB9ZKuT2yy4sw09 Jkgzn82rf9HwXfgxSC+CB/2E+YCMZ4ej9WXO9QR4k77CDMbIM/WAC/GuKzUa8Jsb0ERJp5 wMEUG2NUEZJnCVBM/P6d/Z2fuRIgYN4DwJuP/CX0vEDkfD3uDP4BwCy5dRJ0rA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1785751487; 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: in-reply-to:in-reply-to:references:references; bh=EJXfOI9ACfmuS1BdwEmhxJUA4MF5NiefRYfYZpQNmVU=; b=RCRyTnKmL5dq3dKIVhqfCPp8JWiN7Vr21/wc08A02mj30I8OyfOQKZV8whQ2xepQJglfH9 lHBZOWap/3v2YUCA== Date: Mon, 03 Aug 2026 12:04:39 +0200 Subject: [PATCH v2 08/17] selftests: timers: nanosleep: Drop output alignment 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: <20260803-auxclock-nanosleep-prep-v2-8-910cbd485390@linutronix.de> References: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> In-Reply-To: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> To: John Stultz , Thomas Gleixner , Stephen Boyd , Miroslav Lichvar , Anna-Maria Behnsen , Frederic Weisbecker , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1785751481; l=1725; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=JW7wm5Gnp8xFVFmYee+ahof9lgO/Vkd2KI6W/DXDmR4=; b=/FEgVTJmaaLh2mTMHM7W9oCqnbypDpZ0qHtQ7ZoL2a7yjIrVCx3Rj3Lynlzok8V1RRYIhlVka PIY/C2JwBSuAnrGLvy+UTqWB4Ldztj7DZCU3s7NkOYQWWzWqO6ZriGF X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The padding of the clock name is pointless as nothing else is printed. Signed-off-by: Thomas Wei=C3=9Fschuh (Schneider Electric) --- tools/testing/selftests/timers/nanosleep.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/timers/nanosleep.c b/tools/testing/sel= ftests/timers/nanosleep.c index 7df86dfc897f..629e800135ad 100644 --- a/tools/testing/selftests/timers/nanosleep.c +++ b/tools/testing/selftests/timers/nanosleep.c @@ -152,7 +152,7 @@ int main(int argc, char **argv) if (clockid =3D=3D CLOCK_PROCESS_CPUTIME_ID || clockid =3D=3D CLOCK_THREAD_CPUTIME_ID || clockid =3D=3D CLOCK_HWSPECIFIC) { - ksft_test_result_skip("%-31s\n", clock_name(clockid)); + ksft_test_result_skip("%s\n", clock_name(clockid)); continue; } =20 @@ -162,21 +162,21 @@ int main(int argc, char **argv) while (length <=3D (NSEC_PER_SEC * 10)) { ret =3D nanosleep_test(clockid, length); if (ret =3D=3D UNSUPPORTED) { - ksft_test_result_skip("%-31s\n", clock_name(clockid)); + ksft_test_result_skip("%s\n", clock_name(clockid)); goto next; } if (ret < 0) { - ksft_test_result_fail("%-31s\n", clock_name(clockid)); + ksft_test_result_fail("%s\n", clock_name(clockid)); ksft_exit_fail(); } length *=3D 100; } ret =3D nanosleep_test_remaining(clockid); if (ret < 0) { - ksft_test_result_fail("%-31s\n", clock_name(clockid)); + ksft_test_result_fail("%s\n", clock_name(clockid)); ksft_exit_fail(); } - ksft_test_result_pass("%-31s\n", clock_name(clockid)); + ksft_test_result_pass("%s\n", clock_name(clockid)); next: ret =3D 0; } --=20 2.55.0 From nobody Fri Oct 2 09:21:58 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 0639E3793B0; Mon, 3 Aug 2026 10:04:48 +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=1785751491; cv=none; b=JAuUJK8qJoZbxzBn/lHI/TaFa2uzknxC3FDmghfr3/Nc9RMPDGe5WsQjqrsdHpcdz68odRiqWZ03SWoZ7VhKLw2Ru2PQpSKtLSd3smdXsaHAtCbbJmcKUZYs915v6ReHRXfTP6meH/mkUDhq4dRIm72E6UewrrzZAb6szNiSc7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785751491; c=relaxed/simple; bh=b4Cuc09021hPuVXymmV95o2SqTAB5jJqnUVwvaXXmjU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qAAD4b8UFyhH4LdiWZ3LOjNlIVSPdpkcKKJs9x+B5OIdX3p6KwiB/ArI9fRJiOhDBUSsHxj46JUt8ZC2x10wKAhF0Q1Otu71rieba+SYYTJZ8FokD5SqhtLfxfQPnF8rCNwfQ6tNerLvkJ3n+Rbzb+6s/b9nnK+TLWAASNEbjp8= 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=osbE+b55; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=zZcthxHe; 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="osbE+b55"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="zZcthxHe" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1785751487; 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: in-reply-to:in-reply-to:references:references; bh=RjFqtAmubbq/fczYkMx5lmf68yK9hq9E3ME+XfsAD4c=; b=osbE+b55s27woqIV2P6R80qUPSmjcweZeGZtBNFKQjdMiyPWcakY7XTP+L6i3v1o7EeOP+ grhkerOpsuxrl3rW03dMPkddEyY1gWJaIldquXBO2g5A//i8ZVBmZkFY1FjK54nfe7Lhcp Eh00jU0f+aI0jEw0A8n+F2+EiInqwDIrYFTkNAy/EWN3JojJaaM+eeqpM1fPtkpm4mRT8R DOJMBeQvUriZxw2pd9dK1LFi48tsml+2U7LcQ2FvgT6kGL1etxTKKQ/Ujt5Do3aTotihAb rfwg4BJTxq5mGOrGHAU9nQohHCBEoPH8sJ7RK6RGVNBnZjtPoqoK52/crrq+xw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1785751487; 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: in-reply-to:in-reply-to:references:references; bh=RjFqtAmubbq/fczYkMx5lmf68yK9hq9E3ME+XfsAD4c=; b=zZcthxHeLok+JcddMgZ2np236glz2YHJtrVExuJ5//kdm3MoLx0Ei11LdfR6B9VMn27USv S1+0t/EtJXqsFwBg== Date: Mon, 03 Aug 2026 12:04:40 +0200 Subject: [PATCH v2 09/17] selftests: timers: nanosleep: Explicitly list the tested clocks 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: <20260803-auxclock-nanosleep-prep-v2-9-910cbd485390@linutronix.de> References: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> In-Reply-To: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> To: John Stultz , Thomas Gleixner , Stephen Boyd , Miroslav Lichvar , Anna-Maria Behnsen , Frederic Weisbecker , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1785751481; l=2226; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=b4Cuc09021hPuVXymmV95o2SqTAB5jJqnUVwvaXXmjU=; b=s775VFXFlHQybLXC/tpdrr8gAQXJLO9ohANRNpu4TP+gwifFL75hhwECLfv19KewtM3tcd7y8 Z13Q8oGSy6QB7amUkx2jmeQrD2n7pd6YGzT4r8DTHpH1PExQ9UwgcK1 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The test relies on the numeric values of the clockids. As not all clocks are meant to be tested, this requires skipping some clocks unconditionally, cluttering the result. Use an equivalent, explicit list instead. In addition to CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID and CLOCK_HWSPECIFIC which were unconditionally skipped before, this also unconditionally skips CLOCK_MONOTONIC_RAW, CLOCK_MONOTONIC_COARSE and CLOCK_REALTIME_COARSE. clock_nanosleep() is not supported for those. Signed-off-by: Thomas Wei=C3=9Fschuh (Schneider Electric) Acked-by: John Stultz --- tools/testing/selftests/timers/nanosleep.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/timers/nanosleep.c b/tools/testing/sel= ftests/timers/nanosleep.c index 629e800135ad..9dd662226261 100644 --- a/tools/testing/selftests/timers/nanosleep.c +++ b/tools/testing/selftests/timers/nanosleep.c @@ -30,9 +30,6 @@ #include "clock-helpers.h" #include "kselftest.h" =20 -/* CLOCK_HWSPECIFIC =3D=3D CLOCK_SGI_CYCLE (Deprecated) */ -#define CLOCK_HWSPECIFIC 10 - #define UNSUPPORTED 0xf00f =20 /* returns 1 if a <=3D b, 0 otherwise */ @@ -141,20 +138,21 @@ int main(int argc, char **argv) { long long length; int clockid, ret; - int max_clocks =3D CLOCK_TAI + 1; =20 - ksft_print_header(); - ksft_set_plan(max_clocks); + static const clockid_t tested_clocks[] =3D { + CLOCK_REALTIME, + CLOCK_MONOTONIC, + CLOCK_BOOTTIME, + CLOCK_BOOTTIME_ALARM, + CLOCK_REALTIME_ALARM, + CLOCK_TAI, + }; =20 - for (clockid =3D CLOCK_REALTIME; clockid < max_clocks; clockid++) { + ksft_print_header(); + ksft_set_plan(ARRAY_SIZE(tested_clocks)); =20 - /* Skip cputime clockids since nanosleep won't increment cputime */ - if (clockid =3D=3D CLOCK_PROCESS_CPUTIME_ID || - clockid =3D=3D CLOCK_THREAD_CPUTIME_ID || - clockid =3D=3D CLOCK_HWSPECIFIC) { - ksft_test_result_skip("%s\n", clock_name(clockid)); - continue; - } + for (size_t clock_index =3D 0; clock_index < ARRAY_SIZE(tested_clocks); c= lock_index++) { + clockid =3D tested_clocks[clock_index]; =20 fflush(stdout); =20 --=20 2.55.0 From nobody Fri Oct 2 09:21:58 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 A9D1037A4AB; Mon, 3 Aug 2026 10:04:49 +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=1785751491; cv=none; b=o6CxQKLtBmoQe2aB2y59CuS/O8sWNShWVVCWH71SA58r4ZyISWGeIyHVAyI7Lc9aZcIJrwd9GOmwPFbcVriz0Sm0oX2Z8F1Rd0YW7MGrCQVDNr1PEzHFfopJI3fTRQOXinlDJpqhf7A+otqyl/deb5vI6hXZ+NkMLTdXi9uZ5GE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785751491; c=relaxed/simple; bh=sIKAr4iZmHA7egKodlsSM+sqkyR+6mdVrZ95PgxfZIk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ELhflONBXgItpmjjGgazH2e+PQh/2bmZJqR2m92QOzFnxqZWMjMUb2wSWzxyX1Dkf+7HEF3r6uzD7tjIzV+rQ9y+2IWyZY3ohqZpoZOYH4Jz7B/Te35r7HSJ1h9BVQbDW0K1Sd57WE1m9RhWkqA9DCuHh7K3pUICyY0+Ai36b28= 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=X3yNUlan; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=mys2v/8f; 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="X3yNUlan"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="mys2v/8f" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1785751488; 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: in-reply-to:in-reply-to:references:references; bh=Z4KtPUsXHq5SCbQ18r2P4i6cQ7hpYeXzhBirlnr7E7A=; b=X3yNUlanw2GVvr6RX4M+2AVA7ARyZl0H+y7wzHL0B74TgFK/4useSSYhDJT/Yzl1pC+dmz iZGZzRat3y0PoxC/fy5OZUC8qPWqp3LzqcDvxpAKEiFlWSesg7bGkZFn1Bp4pc1J5jMlst IpSkGKegANCvbna0XtGsQDHt0w3RLr6SauCX8TLEnyInWGETYmQ4rjQlj+Vrx8RkByHjbV sSnOgw4cqpy3wmjy/d8gFwJmLFjiFGReRcQ3UxE8R4lT0DNWhCNY0zt8UAkmN32Gh/b7Sx /LGLrWxP4N+Nw177AdYDSDpzHwLet8Sph0hVQfjbKb7dHvIj9OPbkC4P1+BC9Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1785751488; 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: in-reply-to:in-reply-to:references:references; bh=Z4KtPUsXHq5SCbQ18r2P4i6cQ7hpYeXzhBirlnr7E7A=; b=mys2v/8f0z2jUvGmQcYSi2YJ64+ahdRxCCZ6ND+9DzsnjCnceDm87NABMfGjRP6B8UnxQ5 lqliaSwx318asHAQ== Date: Mon, 03 Aug 2026 12:04:41 +0200 Subject: [PATCH v2 10/17] selftests: timers: nanosleep: Reuse kselftest error numbers 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: <20260803-auxclock-nanosleep-prep-v2-10-910cbd485390@linutronix.de> References: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> In-Reply-To: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> To: John Stultz , Thomas Gleixner , Stephen Boyd , Miroslav Lichvar , Anna-Maria Behnsen , Frederic Weisbecker , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1785751481; l=3374; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=sIKAr4iZmHA7egKodlsSM+sqkyR+6mdVrZ95PgxfZIk=; b=J7iWJEVbSfQb9RyzR7MoIn4LbOTj7raMgaRQyLlJt9tHGRSqWfz+yD+KB6LSGUK/mCEU4YASM No0DGQ/IZyoAHilBsHAd0vNGax8vNiyt/fPWgJS7IGpI+YTbxT5qHVv X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The test currently defines its own custom error numbers. These mirror the semantics from the standard KFST_* constants. To make the code easier to read, use the standard result constants. Signed-off-by: Thomas Wei=C3=9Fschuh (Schneider Electric) Acked-by: John Stultz --- tools/testing/selftests/timers/nanosleep.c | 36 ++++++++++++++------------= ---- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/tools/testing/selftests/timers/nanosleep.c b/tools/testing/sel= ftests/timers/nanosleep.c index 9dd662226261..0a2ca1791f27 100644 --- a/tools/testing/selftests/timers/nanosleep.c +++ b/tools/testing/selftests/timers/nanosleep.c @@ -30,8 +30,6 @@ #include "clock-helpers.h" #include "kselftest.h" =20 -#define UNSUPPORTED 0xf00f - /* returns 1 if a <=3D b, 0 otherwise */ static inline int in_order(struct timespec a, struct timespec b) { @@ -60,15 +58,15 @@ int nanosleep_test(int clockid, long long ns) =20 /* First check abs time */ if (clock_gettime(clockid, &now)) - return UNSUPPORTED; + return KSFT_SKIP; target =3D timespec_add(now, ns); =20 if (clock_nanosleep(clockid, TIMER_ABSTIME, &target, NULL)) - return UNSUPPORTED; + return KSFT_SKIP; clock_gettime(clockid, &now); =20 if (!in_order(target, now)) - return -1; + return KSFT_FAIL; =20 /* Second check reltime */ clock_gettime(clockid, &now); @@ -80,8 +78,8 @@ int nanosleep_test(int clockid, long long ns) clock_gettime(clockid, &now); =20 if (!in_order(target, now)) - return -1; - return 0; + return KSFT_FAIL; + return KSFT_PASS; } =20 static void dummy_event_handler(int val) @@ -100,38 +98,38 @@ static int nanosleep_test_remaining(int clockid) sa.sa_handler =3D dummy_event_handler; ret =3D sigaction(SIGALRM, &sa, NULL); if (ret) - return -1; + return KSFT_FAIL; =20 ret =3D timer_create(clockid, NULL, &timer); if (ret) - return -1; + return KSFT_FAIL; =20 itimer.it_value.tv_nsec =3D NSEC_PER_SEC / 4; ret =3D timer_settime(timer, 0, &itimer, NULL); if (ret) - return -1; + return KSFT_FAIL; =20 rqtp.tv_nsec =3D NSEC_PER_SEC / 2; ret =3D clock_nanosleep(clockid, 0, &rqtp, &rmtp); if (ret !=3D EINTR) - return -1; + return KSFT_FAIL; =20 ret =3D timer_delete(timer); if (ret) - return -1; + return KSFT_FAIL; =20 sa.sa_handler =3D SIG_DFL; ret =3D sigaction(SIGALRM, &sa, NULL); if (ret) - return -1; + return KSFT_FAIL; =20 if (!in_order((struct timespec) {}, rmtp)) - return -1; + return KSFT_FAIL; =20 if (!in_order(rmtp, rqtp)) - return -1; + return KSFT_FAIL; =20 - return 0; + return KSFT_PASS; } =20 int main(int argc, char **argv) @@ -159,18 +157,18 @@ int main(int argc, char **argv) length =3D 10; while (length <=3D (NSEC_PER_SEC * 10)) { ret =3D nanosleep_test(clockid, length); - if (ret =3D=3D UNSUPPORTED) { + if (ret =3D=3D KSFT_SKIP) { ksft_test_result_skip("%s\n", clock_name(clockid)); goto next; } - if (ret < 0) { + if (ret =3D=3D KSFT_FAIL) { ksft_test_result_fail("%s\n", clock_name(clockid)); ksft_exit_fail(); } length *=3D 100; } ret =3D nanosleep_test_remaining(clockid); - if (ret < 0) { + if (ret =3D=3D KSFT_FAIL) { ksft_test_result_fail("%s\n", clock_name(clockid)); ksft_exit_fail(); } --=20 2.55.0 From nobody Fri Oct 2 09:21:58 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 74DBD37BE9E; Mon, 3 Aug 2026 10:04:50 +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=1785751492; cv=none; b=ubbiqKRUhvH20wp3FsFpGa6iQBnxy9e/1f/1zXARDcFzv86/TKe5s4yyeRUykBYonkYhyAwJedssYmx05D/kJvN6ZCeIIT1ed5DxCi4te6j1htFvVsOjv/uc1w2JHUkl7kOHEj14dGiTgav3zxFmumjHdspO7hEhHtAj0xHRVUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785751492; c=relaxed/simple; bh=JGtDg2PzLVWZ8cqSK/cuU7S2V+MlHg+yhTHqysxcxsA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ayo/azoigBeKZygw1an2kn1knGmwIKiujlSB8pIcLqUG3vWRgrLYittRGy/pYTK0XcmatTD8MYuprC/rpvjX6x2no5Pbc702aa1/3sfi++RyskO6Y6or/DhasqnimVbb1eAP7VYAzAKJV4eyHZYX56olJxdaYo8fERVcb2Xma6c= 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=dBvhwPLU; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=c/7jhd7x; 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="dBvhwPLU"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="c/7jhd7x" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1785751488; 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: in-reply-to:in-reply-to:references:references; bh=cYH09veRA0Aw/Jroe4r+pOSS+OXP0wrgXBET9VeRh+4=; b=dBvhwPLUKU3Kssq/8jdzjP5qVPQagIE0eMA+2rxa7sYd0R3GCAE8pLnXl1si0BLCtsw+rb zEQd0ogyyagUYYxYJZk0oBeHNEAepjiMebnAsTo4fB6VPq2gxxVwP0ajm7W4N78L2BYU+A u5CK7IcumozBtvlztJ1bw7WKsAa+tdSRdWgZNzXfU5ivk/4n7x5pipjli7qLJ6a2G05s67 42O2XfuXcHSbfIaRB3v8aOVFlEjuQlvTgnk1G7bqETL+FU0TrohosQnefFZgB97u3Ucvyo VplkT4jTNym+er36vE/TzUyp+sJLiqBO07bS78PTYqLiJxaZ1dlGu93TFPwUCw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1785751488; 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: in-reply-to:in-reply-to:references:references; bh=cYH09veRA0Aw/Jroe4r+pOSS+OXP0wrgXBET9VeRh+4=; b=c/7jhd7xj7KOxujmgI35dDc6JZ9Xx+TIq+jRKCzzosvP32UPDTo0+Q7QbvS1dyJ5MQDR8w FAbB934E2JIIE9Cw== Date: Mon, 03 Aug 2026 12:04:42 +0200 Subject: [PATCH v2 11/17] selftests: timers: nanosleep: Move all single clock tests out of the loop in main() 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: <20260803-auxclock-nanosleep-prep-v2-11-910cbd485390@linutronix.de> References: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> In-Reply-To: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> To: John Stultz , Thomas Gleixner , Stephen Boyd , Miroslav Lichvar , Anna-Maria Behnsen , Frederic Weisbecker , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1785751481; l=2235; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=JGtDg2PzLVWZ8cqSK/cuU7S2V+MlHg+yhTHqysxcxsA=; b=JGJlwOch6xadLBHRJkBnFd5NrcaCqNg0spCa/3WiSWlPJAOg8ue3ubUdUIFCeu5Ae4T1O0Z3m zd+rlFz6Yh9CM2LhI5KrTc5YeU63lD9zh656hYT5Sie6sA33dWMMxRM X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Make the code easier to read by avoiding a goto. Signed-off-by: Thomas Wei=C3=9Fschuh (Schneider Electric) Acked-by: John Stultz --- tools/testing/selftests/timers/nanosleep.c | 51 ++++++++++++++++----------= ---- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/tools/testing/selftests/timers/nanosleep.c b/tools/testing/sel= ftests/timers/nanosleep.c index 0a2ca1791f27..5037481516df 100644 --- a/tools/testing/selftests/timers/nanosleep.c +++ b/tools/testing/selftests/timers/nanosleep.c @@ -132,10 +132,35 @@ static int nanosleep_test_remaining(int clockid) return KSFT_PASS; } =20 +static void nanosleep_test_clock(clockid_t clockid) +{ + long long length =3D 10; + int ret; + + while (length <=3D (NSEC_PER_SEC * 10)) { + ret =3D nanosleep_test(clockid, length); + if (ret =3D=3D KSFT_SKIP) { + ksft_test_result_skip("%s\n", clock_name(clockid)); + return; + } + if (ret =3D=3D KSFT_FAIL) { + ksft_test_result_fail("%s\n", clock_name(clockid)); + ksft_exit_fail(); + } + length *=3D 100; + } + + ret =3D nanosleep_test_remaining(clockid); + if (ret =3D=3D KSFT_FAIL) { + ksft_test_result_fail("%s\n", clock_name(clockid)); + ksft_exit_fail(); + } + ksft_test_result_pass("%s\n", clock_name(clockid)); +} + int main(int argc, char **argv) { - long long length; - int clockid, ret; + int clockid; =20 static const clockid_t tested_clocks[] =3D { CLOCK_REALTIME, @@ -154,27 +179,7 @@ int main(int argc, char **argv) =20 fflush(stdout); =20 - length =3D 10; - while (length <=3D (NSEC_PER_SEC * 10)) { - ret =3D nanosleep_test(clockid, length); - if (ret =3D=3D KSFT_SKIP) { - ksft_test_result_skip("%s\n", clock_name(clockid)); - goto next; - } - if (ret =3D=3D KSFT_FAIL) { - ksft_test_result_fail("%s\n", clock_name(clockid)); - ksft_exit_fail(); - } - length *=3D 100; - } - ret =3D nanosleep_test_remaining(clockid); - if (ret =3D=3D KSFT_FAIL) { - ksft_test_result_fail("%s\n", clock_name(clockid)); - ksft_exit_fail(); - } - ksft_test_result_pass("%s\n", clock_name(clockid)); -next: - ret =3D 0; + nanosleep_test_clock(clockid); } ksft_exit_pass(); } --=20 2.55.0 From nobody Fri Oct 2 09:21:58 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 6A06933FE2F; Mon, 3 Aug 2026 10:04:51 +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=1785751494; cv=none; b=c6EQvDU2tWFi9WKWq0BFcAEym2h4L90cXPc2VPzJaDIgPCCPUGHdbCKdr7yB6SJBkLLObrHCtvKk5kw2QineeQHOj3j1b2w/2RDDD5R+bJ3jwkRYnavhv/brlvva/u8UIxvyJe2XSwz6YrsrpY/0gKLgMFqH4a0VtbMUpBUIRaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785751494; c=relaxed/simple; bh=8f0cZ9Z81JEy5Nb5GMW8Jvm2yJSqxh8ZEWYwvfBFEuc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=K9bcJF56QHpXBSuozUHn2xKYDLXcLDhzBUkRKfxgYVrlGxUq8lm/xtjiN/NYOesQrDwyy7p0jiH5icsdSAMrhtAFCuI9GClEwZB+4G+m57IzGUQj1Xmcg44wYJJpO0jP1U+oyJ1LuSUBmqEcq1yEplhtcRXXbJ6RDgDeUfp3bB8= 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=E05+8ZAS; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=hwSOGtvf; 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="E05+8ZAS"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="hwSOGtvf" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1785751489; 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: in-reply-to:in-reply-to:references:references; bh=Rmy8O6Q1rL0QWJQTqilfs0RBAsmI3zNX8zv3Fz4GAfo=; b=E05+8ZASTKl4RP04szB5tGPtFTBl37IwoICLMevXXkVEokQkFE6JdTouv8iksvrZGnjd9g wX4TRS9jiKyvpQeq8tOnISTo9lIl6XLVD7684xum1xFS+fcpcKMC1MftAVJugHViZmohvI OwCRcRyTExZIzvTdxupFccxIknLV/WNOQcdO7/mH4TXoUB6QIOw0pYtqfsPRLXsOW+wOTE DVGmnCgNjbtC1fCfH5RdP//EiDuWTsUQA/1X142dVbhwJbpVZQN3A8ZjxMO+Dan8ajZewb XwjQ4q43g8XTQI1HwDBJa7sms+VQJXuf9rGofRlGf6bEBkHdYf40Sx70ua+12w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1785751489; 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: in-reply-to:in-reply-to:references:references; bh=Rmy8O6Q1rL0QWJQTqilfs0RBAsmI3zNX8zv3Fz4GAfo=; b=hwSOGtvfsMlJY5TUkxxVH6GjzMSugNfhLKm5576dkq6TRt/Bfp/fdatuKm7lZbEMZshPys phspecCeXOBMeWCw== Date: Mon, 03 Aug 2026 12:04:43 +0200 Subject: [PATCH v2 12/17] selftests: timers: nanosleep: Explicitly handle timer_delete() failure 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: <20260803-auxclock-nanosleep-prep-v2-12-910cbd485390@linutronix.de> References: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> In-Reply-To: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> To: John Stultz , Thomas Gleixner , Stephen Boyd , Miroslav Lichvar , Anna-Maria Behnsen , Frederic Weisbecker , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1785751481; l=1475; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=8f0cZ9Z81JEy5Nb5GMW8Jvm2yJSqxh8ZEWYwvfBFEuc=; b=KOtMmrDukMJx+I69FFumKIg0u61u22eQi8T8QYe7wWMIlZ87e68lsM7RfR2tFyaMvV6W+lwpW HgV4/jalOaKDDJGGHDn0urPsz4zg7EJKVeySIs/TwFllSTdXYaloAFk X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= An upcoming patch will remove the early exit on failure of a single testcase. If a test fails because a timeout timer could not be deleted, then that timeout timer might interfere with the following tettcases. Exit the whole test case with a clear error message in this case. Other failures are not problematic: * If timer_settime() fails, a harmless unarmed timer is left around. * The SIGALRM handler reconfigured for each call to nanosleep_test_remaining() anyways. Signed-off-by: Thomas Wei=C3=9Fschuh (Schneider Electric) --- tools/testing/selftests/timers/nanosleep.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/timers/nanosleep.c b/tools/testing/sel= ftests/timers/nanosleep.c index 5037481516df..dd899dcfb2cb 100644 --- a/tools/testing/selftests/timers/nanosleep.c +++ b/tools/testing/selftests/timers/nanosleep.c @@ -111,11 +111,14 @@ static int nanosleep_test_remaining(int clockid) =20 rqtp.tv_nsec =3D NSEC_PER_SEC / 2; ret =3D clock_nanosleep(clockid, 0, &rqtp, &rmtp); - if (ret !=3D EINTR) - return KSFT_FAIL; =20 - ret =3D timer_delete(timer); - if (ret) + if (timer_delete(timer)) { + ksft_exit_fail_msg("Unable to delete the timeout timer for %s. " + "This might interfere with following testcases.\n", + clock_name(clockid)); + } + + if (ret !=3D EINTR) return KSFT_FAIL; =20 sa.sa_handler =3D SIG_DFL; --=20 2.55.0 From nobody Fri Oct 2 09:21:58 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 85CF2372ED5; Mon, 3 Aug 2026 10:04:51 +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=1785751494; cv=none; b=ktGWL59yUGNuG6KLXQXVgCVbsxSfR5rVfsDzVXcr87fbjBTQzMBzOZVN7r9vF07csEh0bwnQD/VbhoIaWwaJd2ks/zZHlpWHNCzGeXwaeahoCKJgP1cEzhtG8L5GnWHMnXKzc3PMlFOvNX1v3DD1Fqccc+afsJsWvu1D59isbRc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785751494; c=relaxed/simple; bh=mHUW1pQQuH1WhZUbEwvFYiq4Z3Yezbz0gHQ6QiGH/9Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ReFA9vmPIlF9wcv6KZUk967HJtDtES2J6IvVk1MN/8zUEwjFp4G6nBO5g6SabPVZdYqvvrA7RZmQ1RvpCZWG9E/LFDFhy3dhTkHRI0HqJYcjYvYG3dABAQzVmJEY5qMcckSSLoxcvPKe3uT18dHqM1I4zCGs9wTNSr6McWRKIQY= 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=3cftf9aZ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=bZD2P/xJ; 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="3cftf9aZ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="bZD2P/xJ" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1785751489; 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: in-reply-to:in-reply-to:references:references; bh=1s3IbOUHyW0Oo7Tx26hOyZeC0qSi7z+B2dI3YWVmfkQ=; b=3cftf9aZKWfBiSgBKG0DceYJnlh2/uF4o8Q2IYR1ozQivHiK8W6i4c0YCPYSu4NrQD04uS ZAcxyTSVW4JMv0KR0jptWHqHr+wN0mZQ6C1x/OrVjN/ko9OEsYBDC+039U9CErUQdKFM65 klJn2yUsjG4tgHZB3aCoCoZEF0ZEfsthlhG0yIc4Zm2pUo/KQp061OtOvE46WoZE3aUvh5 p/Y+tSsK93x2aJf8OEHV2Kf8NJgTMkNvaTbqAs/28Yi5EPG3nz7EVHuLQZqpbpzOFrodh0 FBxhGrO/hOfGh1BkEW8A4x3j4idKZXhoAhSdrs2rlAP5vMhI1F2/eh9+KuPczw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1785751489; 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: in-reply-to:in-reply-to:references:references; bh=1s3IbOUHyW0Oo7Tx26hOyZeC0qSi7z+B2dI3YWVmfkQ=; b=bZD2P/xJ5y9YfsidO0QMI1fcjsBmWvTpyJZamHcqTmf1QLVIUk3FHFG+LdkwrPUN/j5r0n YwMx2/w39idq08Cw== Date: Mon, 03 Aug 2026 12:04:44 +0200 Subject: [PATCH v2 13/17] selftests: timers: nanosleep: Report each test separately 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: <20260803-auxclock-nanosleep-prep-v2-13-910cbd485390@linutronix.de> References: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> In-Reply-To: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> To: John Stultz , Thomas Gleixner , Stephen Boyd , Miroslav Lichvar , Anna-Maria Behnsen , Frederic Weisbecker , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1785751481; l=2273; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=mHUW1pQQuH1WhZUbEwvFYiq4Z3Yezbz0gHQ6QiGH/9Q=; b=VTcygLFjAPEoADwn/7VhRK4fCuQ0bIhhuKv5KIM0bj8TUY4X5NtAvV9DTfl6q8tqOlAjdDoYP 5nmXItZTivMBS6bWpaE2eDpxP43p7WOQCY/+62DVz9Lolr67QnvIdEo X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Currently the test for the sleep functionality itself and the one for the remaining time are reported together. This makes the test output a bit confusing, especially as the upcoming tests for auxiliary clocks will have different results between the two parts. Report each test part on its own. This also allows continuing testing other clocks after a single one has failed. Signed-off-by: Thomas Wei=C3=9Fschuh (Schneider Electric) --- tools/testing/selftests/timers/nanosleep.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/timers/nanosleep.c b/tools/testing/sel= ftests/timers/nanosleep.c index dd899dcfb2cb..b45e4c855259 100644 --- a/tools/testing/selftests/timers/nanosleep.c +++ b/tools/testing/selftests/timers/nanosleep.c @@ -142,23 +142,18 @@ static void nanosleep_test_clock(clockid_t clockid) =20 while (length <=3D (NSEC_PER_SEC * 10)) { ret =3D nanosleep_test(clockid, length); - if (ret =3D=3D KSFT_SKIP) { - ksft_test_result_skip("%s\n", clock_name(clockid)); + if (ret !=3D KSFT_PASS) { + ksft_test_result_report(ret, "%s\n", clock_name(clockid)); + ksft_test_result_skip("%s (remaining)\n", clock_name(clockid)); return; } - if (ret =3D=3D KSFT_FAIL) { - ksft_test_result_fail("%s\n", clock_name(clockid)); - ksft_exit_fail(); - } + length *=3D 100; } + ksft_test_result_pass("%s\n", clock_name(clockid)); =20 ret =3D nanosleep_test_remaining(clockid); - if (ret =3D=3D KSFT_FAIL) { - ksft_test_result_fail("%s\n", clock_name(clockid)); - ksft_exit_fail(); - } - ksft_test_result_pass("%s\n", clock_name(clockid)); + ksft_test_result_report(ret, "%s (remaining)\n", clock_name(clockid)); } =20 int main(int argc, char **argv) @@ -175,7 +170,7 @@ int main(int argc, char **argv) }; =20 ksft_print_header(); - ksft_set_plan(ARRAY_SIZE(tested_clocks)); + ksft_set_plan(ARRAY_SIZE(tested_clocks) * 2); =20 for (size_t clock_index =3D 0; clock_index < ARRAY_SIZE(tested_clocks); c= lock_index++) { clockid =3D tested_clocks[clock_index]; @@ -184,5 +179,5 @@ int main(int argc, char **argv) =20 nanosleep_test_clock(clockid); } - ksft_exit_pass(); + ksft_finished(); } --=20 2.55.0 From nobody Fri Oct 2 09:21:58 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 DA65537D135; Mon, 3 Aug 2026 10:04:51 +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=1785751493; cv=none; b=aW7gIPDFbb3xENDfHpmRhnk86emE/lPdV6a48XplHKpYP/X0wboahSphySWIY7FS/p6sgI8jQeDCI7a0PMoUnrRAOPy8RtAA5vwiZyFOx7ciPaFbGQHMdXCpgHRdxhyFPl+OfU06gdsHgZJX8aPpI0uIg+jjfzQ4fpieqqi0YSY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785751493; c=relaxed/simple; bh=cSPG97HHdQvSt5MuP1g2wCe3dTsy8tM+XrKyRFvfFJ4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hwZhsBY6yLjQgXoGd+oBwpCh+j4xM47wpn2zhO17qgDUhgxMb1KY8UGQnvCMqy/KTdWkApupkIP1Gxse4tyQsSvwXnAYH1qZbXL+2GqKeDjmlFeWO/tGc8wat5iZMcvGpLq1L855L2uxGgmNVommRPGVMw00JQDwJFT50AZCcsQ= 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=B+lLkNbM; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Y62eUp29; 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="B+lLkNbM"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Y62eUp29" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1785751490; 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: in-reply-to:in-reply-to:references:references; bh=7cOgkEiUY5Nek/Yxobxpk/lyOOSwHnWvKhtxAwfhtdk=; b=B+lLkNbMFh8RHWFD5HbPWFMG2dWRHA2kaYcEEgPj+bkbCPvofL2XHi6lkOh4aBZfZEk1j8 8nTTSjDlu0K91ryDjYUWh7iO+Mco5/9d8KrEMdAxhErwFAS4Q+Gc3J9DLWTI9sY1CwdOkO 8eIkiSaY/hOJwXrHzb/EwMzC81PbbtjDmw7+D/FFkDyCrfK49zeKNH/r2Cw33llE/PwlOh ys1MDw6LKTwczuwm8jYqFHTk8pDV5Qomi4HdaHjVNh9lw3eNE9RzJtKIVyAOYG5nY7YubL N6HuItQNklGjsgthykf/D25FGty45d/95hdEeXeNH92muwgvdj0sBim0fWhqfg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1785751490; 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: in-reply-to:in-reply-to:references:references; bh=7cOgkEiUY5Nek/Yxobxpk/lyOOSwHnWvKhtxAwfhtdk=; b=Y62eUp29V6Su1cepUMDV0FvKsVUfBMZAdBNg4PkgeSt3PJCssOEwp178gVZbVbubjw+NXJ /ZyZXctJzsQfO/Cw== Date: Mon, 03 Aug 2026 12:04:45 +0200 Subject: [PATCH v2 14/17] selftests: timers: nsleep-lat: Use NSEC_PER_MSEC define for unreasonable latency 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: <20260803-auxclock-nanosleep-prep-v2-14-910cbd485390@linutronix.de> References: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> In-Reply-To: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> To: John Stultz , Thomas Gleixner , Stephen Boyd , Miroslav Lichvar , Anna-Maria Behnsen , Frederic Weisbecker , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1785751481; l=851; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=cSPG97HHdQvSt5MuP1g2wCe3dTsy8tM+XrKyRFvfFJ4=; b=AlwzdgDYDoNJQfS/dUkhOW+SUhP8181xbLwcfkasVqyUuxQUFKeD/7/jPgh5nxZEuc93JnLM0 AWKMRNKkjbuBvA9XBUHz5tChSxyEeYPj6OLveQSv5N42aEMRJDGsEaA X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Use the predefined symbol to make the code easier to understand. Signed-off-by: Thomas Wei=C3=9Fschuh (Schneider Electric) Acked-by: John Stultz --- tools/testing/selftests/timers/nsleep-lat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/timers/nsleep-lat.c b/tools/testing/se= lftests/timers/nsleep-lat.c index d22973c87f21..d46f17404439 100644 --- a/tools/testing/selftests/timers/nsleep-lat.c +++ b/tools/testing/selftests/timers/nsleep-lat.c @@ -27,7 +27,7 @@ #include "clock-helpers.h" #include "kselftest.h" =20 -#define UNRESONABLE_LATENCY 40000000 /* 40ms in nanosecs */ +#define UNRESONABLE_LATENCY (40 * NSEC_PER_MSEC) =20 /* CLOCK_HWSPECIFIC =3D=3D CLOCK_SGI_CYCLE (Deprecated) */ #define CLOCK_HWSPECIFIC 10 --=20 2.55.0 From nobody Fri Oct 2 09:21:58 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 68922382381; Mon, 3 Aug 2026 10:04:52 +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=1785751494; cv=none; b=YowILsr1aX0iizCyLZYoR64uz19TSkJdRiMh3+adixAXsWSGXXR/O/GrsOtFOlnMXnj+hkdtuSWUc6vB70JT4VEdnAtnEBQS/VrODT/85MQ3IFRZ/1ESbLtZSR9by7MCsetu2jwCMMog24R/vkyIKkYJQQ7kgxtDp47wtHFOIak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785751494; c=relaxed/simple; bh=/uZikIFgs6G+Ur7FXAj0rbE4zBonV1d+zbh5dxz+nuo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kPN7q0Mkz4dPXC0XoPFrsIO0v/UcyyH/l+9csWBN11SlBufqNEGEPh0XpKxERQGRXW8wgl2ItdhpNko92JiSHLyfKKLPc9kG6klOeepvkpm9GmqaRHCtmfY4ZYWp1C4i41iCCt086WujTTgND2Zfh/VGv7PW0oCsyJqOQOxdAdM= 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=trsDQHKK; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Ry4Sd9Rd; 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="trsDQHKK"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Ry4Sd9Rd" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1785751490; 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: in-reply-to:in-reply-to:references:references; bh=HK5JqakUosO54E2iwBY4d5EW3C/jO9SYvzU7WpNRO8g=; b=trsDQHKK7fKdeEMfgn8vxPWVi2MW3a3AbDu56sPeEppsz0phkwhpo2vjgzfA2yKyniSUmC Jt4za/FeUIZlf46Fy+roYQ7awDjz7NIJpZOVY0LLqP8xxn81dDidx/+ptmJZQyZHHiCzFp sE6hqvWQHJiwwPBkpR6Nt+aehgRdZueChdYQGfKWtWtVw1kpzsfg/gypY+5TcUxMTLE/30 1FCF5MZdXjklctwcGZz69aUNELLviktwNcbhKBDqlnl9eN0r5g6jo8g7llOgEf92aH32bE R8Ox9WcwcKeNBST6MS06sYIk/+FTxG+7EaM6W0SjZYDBjw70zGcsx2QrJrLYHg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1785751490; 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: in-reply-to:in-reply-to:references:references; bh=HK5JqakUosO54E2iwBY4d5EW3C/jO9SYvzU7WpNRO8g=; b=Ry4Sd9RdLKWWcG1NUUTU/HEjHLm4MjJ9OqqySC8pF2dHDHPcHQW5EYbU/0xLx6gyv5A43Z E39evQOtUAsPTwCQ== Date: Mon, 03 Aug 2026 12:04:46 +0200 Subject: [PATCH v2 15/17] selftests: timers: nsleep-lat: Explicitly list the tested clocks 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: <20260803-auxclock-nanosleep-prep-v2-15-910cbd485390@linutronix.de> References: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> In-Reply-To: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> To: John Stultz , Thomas Gleixner , Stephen Boyd , Miroslav Lichvar , Anna-Maria Behnsen , Frederic Weisbecker , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1785751481; l=2381; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=/uZikIFgs6G+Ur7FXAj0rbE4zBonV1d+zbh5dxz+nuo=; b=R32mbYPcltTBB8IYrNareiDSUcFFrOxEDqsXJ73tR0n+gmTAkxzok+eb9x0YI+KbRbgQiSljA 6zCUOxHuoy3DsUzg59omxGlDp3tGf76kq26Snsew/iVM21QQzTPDOaa X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The test relies on the numeric values of the clockids. As not all clocks are meant to be tested, this requires skipping some clocks unconditionally, cluttering the result. Use an equivalent, explicit list instead. In addition to CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID and CLOCK_HWSPECIFIC which were unconditionally skipped before, this also unconditionally skips CLOCK_MONOTONIC_RAW, CLOCK_MONOTONIC_COARSE and CLOCK_REALTIME_COARSE. clock_nanosleep() is not supported for those. Signed-off-by: Thomas Wei=C3=9Fschuh (Schneider Electric) Acked-by: John Stultz --- tools/testing/selftests/timers/nsleep-lat.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/timers/nsleep-lat.c b/tools/testing/se= lftests/timers/nsleep-lat.c index d46f17404439..af47c28f086b 100644 --- a/tools/testing/selftests/timers/nsleep-lat.c +++ b/tools/testing/selftests/timers/nsleep-lat.c @@ -29,9 +29,6 @@ =20 #define UNRESONABLE_LATENCY (40 * NSEC_PER_MSEC) =20 -/* CLOCK_HWSPECIFIC =3D=3D CLOCK_SGI_CYCLE (Deprecated) */ -#define CLOCK_HWSPECIFIC 10 - #define UNSUPPORTED 0xf00f =20 struct timespec timespec_add(struct timespec ts, unsigned long long ns) @@ -97,24 +94,25 @@ int nanosleep_lat_test(int clockid, long long ns) return 0; } =20 -#define SKIPPED_CLOCK_COUNT 3 - int main(int argc, char **argv) { long long length; int clockid, ret; - int max_clocks =3D CLOCK_TAI + 1; =20 - ksft_print_header(); - ksft_set_plan(max_clocks - CLOCK_REALTIME - SKIPPED_CLOCK_COUNT); + static const clockid_t tested_clocks[] =3D { + CLOCK_REALTIME, + CLOCK_MONOTONIC, + CLOCK_BOOTTIME, + CLOCK_BOOTTIME_ALARM, + CLOCK_REALTIME_ALARM, + CLOCK_TAI, + }; =20 - for (clockid =3D CLOCK_REALTIME; clockid < max_clocks; clockid++) { + ksft_print_header(); + ksft_set_plan(ARRAY_SIZE(tested_clocks)); =20 - /* Skip cputime clockids since nanosleep won't increment cputime */ - if (clockid =3D=3D CLOCK_PROCESS_CPUTIME_ID || - clockid =3D=3D CLOCK_THREAD_CPUTIME_ID || - clockid =3D=3D CLOCK_HWSPECIFIC) - continue; + for (size_t clock_index =3D 0; clock_index < ARRAY_SIZE(tested_clocks); c= lock_index++) { + clockid =3D tested_clocks[clock_index]; =20 length =3D 10; while (length <=3D (NSEC_PER_SEC * 10)) { --=20 2.55.0 From nobody Fri Oct 2 09:21:58 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 40E1E3859F0; Mon, 3 Aug 2026 10:04:52 +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=1785751495; cv=none; b=qZY3NhIEu5TKwe0kQA8JIcVe6kpdxg5YTXhR0bitFzzv7US8ETlvQHbjIOGARnxtnFwAH6QLEkE7fMIn1QDZ23LTaNOO2/KsFHwSSM6qOFaL0sY5lKKMGOhAkEFWh0sS6XMxrdgtBXfalPlxgyNF6z2jf11vmiD9hgP9+FHeRE4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785751495; c=relaxed/simple; bh=KBuR27FmiAit9MkMPsuSedgOvHjxdUwveXX1XWHfNTM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=p7glw0uSa6Xi+MKuTPJCPxr/7tr3cj8L+fBxiKoau386By6+2cNw5xLpSmhNSLipMKd9w+dTPo0iZDK5IBvOQYb0DO2YCrRCdjtBFC0QAXblC2g6eAI1hWsg/X9IdtPrVZHLp6h7WwnZV2Os4HkYwK8dsC5CyX4f5EBkHHgW42Y= 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=m9AZr0Kv; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=FmM8r1Sp; 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="m9AZr0Kv"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="FmM8r1Sp" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1785751491; 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: in-reply-to:in-reply-to:references:references; bh=22eg8S4Bhv40LKAFTgzCrRXIhahwNXX/6FUVy3/T6aI=; b=m9AZr0KvGqlTOhj2vXDoBJbyWwXdWzO+O0EBTPpJBnhUQtruzLnxo2aA2wgcjwbAkBlSYu 72EZpwAEzuqZHjGI0H5vGAby6JwDK4wgiynWRRcd7y2XMM/4lyoSBttGtBKY0PuynSXNOz C2FkIxq2RoQAjLoQDP2ucCb2UkYTnU0OYQ15G1vDK1/a+EkMAUxGSmHlV3zHUGUzf0dNmj MSV1kmurgArnTS3tv/prijnpZLoO+n6q76avAKiM78/6K/B089D4hySt2hOnkvgNuuXXao JR+b5XbEO7+eVomj6BDTSL6tMATRlXn+4EEwnlRvjhim/OY+WPqZ/Ge25vwxBA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1785751491; 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: in-reply-to:in-reply-to:references:references; bh=22eg8S4Bhv40LKAFTgzCrRXIhahwNXX/6FUVy3/T6aI=; b=FmM8r1SpE16jvH1bESZt3W8vtywruJHa5v9Kdr5QxAzON7ww3vSyZ1vhtjLJR/A7vnoCom 9pruIpdlNFq5V7Cg== Date: Mon, 03 Aug 2026 12:04:47 +0200 Subject: [PATCH v2 16/17] selftests: timers: nsleep-lat: Reuse kselftest error numbers 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: <20260803-auxclock-nanosleep-prep-v2-16-910cbd485390@linutronix.de> References: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> In-Reply-To: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> To: John Stultz , Thomas Gleixner , Stephen Boyd , Miroslav Lichvar , Anna-Maria Behnsen , Frederic Weisbecker , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1785751481; l=2191; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=KBuR27FmiAit9MkMPsuSedgOvHjxdUwveXX1XWHfNTM=; b=Xt8+nQHWLDeygz4NxKsbbKajXABW+zLtIBjoGbMRH5lQ15S08w/xbDZvyeFk+Qh+VTmULsAWD n/35aKMq3BZAbhuGBQE1t80qSCplI5zWTl4CexKPgwKYfgrNfJAPM+J X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The test currently defines its own custom error numbers. These mirror the semantics from the standard KFST_* constants. To make the code easier to read, use the standard result constants. Signed-off-by: Thomas Wei=C3=9Fschuh (Schneider Electric) Acked-by: John Stultz --- tools/testing/selftests/timers/nsleep-lat.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/timers/nsleep-lat.c b/tools/testing/se= lftests/timers/nsleep-lat.c index af47c28f086b..266ca0cc37ec 100644 --- a/tools/testing/selftests/timers/nsleep-lat.c +++ b/tools/testing/selftests/timers/nsleep-lat.c @@ -29,8 +29,6 @@ =20 #define UNRESONABLE_LATENCY (40 * NSEC_PER_MSEC) =20 -#define UNSUPPORTED 0xf00f - struct timespec timespec_add(struct timespec ts, unsigned long long ns) { ts.tv_nsec +=3D ns; @@ -60,9 +58,9 @@ int nanosleep_lat_test(int clockid, long long ns) target.tv_nsec =3D ns%NSEC_PER_SEC; =20 if (clock_gettime(clockid, &start)) - return UNSUPPORTED; + return KSFT_SKIP; if (clock_nanosleep(clockid, 0, &target, NULL)) - return UNSUPPORTED; + return KSFT_SKIP; =20 count =3D 10; =20 @@ -74,7 +72,7 @@ int nanosleep_lat_test(int clockid, long long ns) =20 if (((timespec_sub(start, end)/count)-ns) > UNRESONABLE_LATENCY) { ksft_print_msg("Large rel latency: %lld ns :", (timespec_sub(start, end)= /count)-ns); - return -1; + return KSFT_FAIL; } =20 /* Next check absolute latency */ @@ -88,10 +86,10 @@ int nanosleep_lat_test(int clockid, long long ns) =20 if (latency/count > UNRESONABLE_LATENCY) { ksft_print_msg("Large abs latency: %lld ns :", latency/count); - return -1; + return KSFT_FAIL; } =20 - return 0; + return KSFT_PASS; } =20 int main(int argc, char **argv) @@ -123,12 +121,7 @@ int main(int argc, char **argv) =20 } =20 - if (ret =3D=3D UNSUPPORTED) { - ksft_test_result_skip("%s\n", clock_name(clockid)); - } else { - ksft_test_result(ret >=3D 0, "%s\n", - clock_name(clockid)); - } + ksft_test_result_report(ret, "%s\n", clock_name(clockid)); } =20 ksft_finished(); --=20 2.55.0 From nobody Fri Oct 2 09:21:59 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 50674385D67; Mon, 3 Aug 2026 10:04:53 +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=1785751495; cv=none; b=ECV54gdoZ62mRaae1U7ldhMbJImND6ifet5h7HWWLhC3hxLgCZsYfJHA809pfB5VgD1I7cxrRic7x2mD2Ibhl8ILQpuQnDCGQPMvtX+b2oiBk3zxPahkGHxrIPga+T7UY2Qy/EH4a3FJcbjfzlKcDMaWXxfA7oBrxQDdyDFxOH0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785751495; c=relaxed/simple; bh=h+2lQiqO/NRAxL8WSKif4LkJFiy7JSahqsxhWLQVyPk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CcJgZsECE1YkxbT1BzrYygqGFCMigA/l/wzZQagmWxyUH2jgCRtui1MjM3u8XBVx3W0MMSeGotzTNUk9PtkfygocbMTuJRxCxpk0CwKB0s9a7ruVdnHe2A9ACV+jERmciX6gmh9mRNZ6wfnotyDF7YBtNqiCMG2JKrH3VS3caiY= 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=ISHDrN9v; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=BzPxfC+e; 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="ISHDrN9v"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="BzPxfC+e" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1785751491; 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: in-reply-to:in-reply-to:references:references; bh=LBlp3AZJMcGpKgu/Bpbq6rKg4no43YHiR5Qw5u7fpKE=; b=ISHDrN9vso9kBotGVgNcSDqc8MgPg68KtRlmhPRnN8zSRku+PRuqDQ9W/XEfvyxzf4NYXM rV2pJ7WhteIRdLZHy/QfkCxPR7Jdnetsmsy/vSyd/6Q38qJoi9cc3cRNd6sPfGVi3YkSz/ lWB1ZXfetsmpQAxtcox+i3ynQQvIvRKmh3hJLqn6NEUrLc+11dGqvxTwOPGL3Y+dm68FJn GxHH4ip69YFja3sPzO8WGFFRbqm+2ItJVvj8rVe/OWUt4fxvniI7Y5xDktK2PCzfvwiyx9 0KoQ3bn7J8hGriHFadCfCg5vzgHBDTJLVJLveAxyNNkTEqae0MabRS35PxBjZg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1785751491; 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: in-reply-to:in-reply-to:references:references; bh=LBlp3AZJMcGpKgu/Bpbq6rKg4no43YHiR5Qw5u7fpKE=; b=BzPxfC+eLRjPOAlt38Vvpt6uZB2tIHP93CB9W7Ph6mMHAyW6tji8pUgbn8RNKVS6p3M/16 82YI40/qhj0E/OBA== Date: Mon, 03 Aug 2026 12:04:48 +0200 Subject: [PATCH v2 17/17] selftests: timers: nsleep-lat: Check all calls to clock_nanosleep() and clock_gettime() 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: <20260803-auxclock-nanosleep-prep-v2-17-910cbd485390@linutronix.de> References: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> In-Reply-To: <20260803-auxclock-nanosleep-prep-v2-0-910cbd485390@linutronix.de> To: John Stultz , Thomas Gleixner , Stephen Boyd , Miroslav Lichvar , Anna-Maria Behnsen , Frederic Weisbecker , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh_=28Schneider_Electric=29?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1785751481; l=1965; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=h+2lQiqO/NRAxL8WSKif4LkJFiy7JSahqsxhWLQVyPk=; b=7CBEpuH84JdVE5JnBPaKcbpxYE9ROm6YbaTYvtlEdNiLmVfDFvLkyCVrCewnvchKyA/yYrbnO b5EtLviINUSDB38PNJdaKTqAV8juga99NbAcjvLTxgT/wej7l5FQWra X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Both these functions can fail. The first calls to those functions are already checked and result in KSFT_SKIP. If they start failing afterwards unexpectedly, report a hard error. Signed-off-by: Thomas Wei=C3=9Fschuh (Schneider Electric) Acked-by: John Stultz --- tools/testing/selftests/timers/nsleep-lat.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/timers/nsleep-lat.c b/tools/testing/se= lftests/timers/nsleep-lat.c index 266ca0cc37ec..5de0051ac8e3 100644 --- a/tools/testing/selftests/timers/nsleep-lat.c +++ b/tools/testing/selftests/timers/nsleep-lat.c @@ -65,10 +65,16 @@ int nanosleep_lat_test(int clockid, long long ns) count =3D 10; =20 /* First check relative latency */ - clock_gettime(clockid, &start); - for (i =3D 0; i < count; i++) - clock_nanosleep(clockid, 0, &target, NULL); - clock_gettime(clockid, &end); + if (clock_gettime(clockid, &start)) + return KSFT_FAIL; + + for (i =3D 0; i < count; i++) { + if (clock_nanosleep(clockid, 0, &target, NULL)) + return KSFT_FAIL; + } + + if (clock_gettime(clockid, &end)) + return KSFT_FAIL; =20 if (((timespec_sub(start, end)/count)-ns) > UNRESONABLE_LATENCY) { ksft_print_msg("Large rel latency: %lld ns :", (timespec_sub(start, end)= /count)-ns); @@ -77,10 +83,13 @@ int nanosleep_lat_test(int clockid, long long ns) =20 /* Next check absolute latency */ for (i =3D 0; i < count; i++) { - clock_gettime(clockid, &start); + if (clock_gettime(clockid, &start)) + return KSFT_FAIL; target =3D timespec_add(start, ns); - clock_nanosleep(clockid, TIMER_ABSTIME, &target, NULL); - clock_gettime(clockid, &end); + if (clock_nanosleep(clockid, TIMER_ABSTIME, &target, NULL)) + return KSFT_FAIL; + if (clock_gettime(clockid, &end)) + return KSFT_FAIL; latency +=3D timespec_sub(target, end); } =20 --=20 2.55.0