From nobody Sun Jun 14 07:40:50 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 0D240426D1D; Fri, 1 May 2026 19:40:35 +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=1777664439; cv=none; b=a++qkwBwQr7Kn7AsS3+kmOG2z3nwKexgimzAtBPw/eHiiTC4uDmYoknapSZHltSQu03C0fe1s8JjtgSTr2KwKL0tSWPkX3ng64mWs1GK8QIbh5afO4oUaaklu2cLoNt6Or174F4Cax/qjIfQWfbRchrXWeS9J947c1l0UBUaVMs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777664439; c=relaxed/simple; bh=DPolmtzobKV6wlwrPxralxH4WkcatPJE8E5qBPboGGA=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=RPCsBQWi+rTeNdPlPz43xGT/buyPCKAva4BcFt1l/wP6ulIFdXcTsqU/7vh7i/Li5jgTRdorEZe5h+GL1bN4FrDPn61zAeXaJtbGlLVKBvgtr+dW91m/Z9JbMxI3ckc7XHZMtDEoRoddCLdCdsA0Qnj0C67+4NG4AZHyHQDo9WY= 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=P3/PKTVx; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=bYOqpDw4; 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="P3/PKTVx"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="bYOqpDw4" Date: Fri, 01 May 2026 19:40:32 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777664434; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eqPHCB75tll3tXHcvxHLlmoxOVuYxkKx2Tnm7nk9lbE=; b=P3/PKTVxdiRgTQZ1CJu5CoCgxa1gHWsADZi04jt9ERYx4duZqHMYgvEAam4+yVoEB7/vQU 2PmL6TGEhUpleQuoqomuQusqfA5JWKQhSBCGYqcMGKoOGYIP9TThACNcLZI8XB6sJQllZg 3ggy3JMxzYbx1I2JipgfDm/MhuXTJSpPUlKhN+dc9LBPt3xgn7fN4rTZWJP4ZL7Yeao4BS Kb+Fk9zBFhrvr/JzXfISkpNNH1EIhw0jju3MkQ0GjRLiOlQCw7ENHreOhObY/hI+lRkqVD ewPq77OFORwNG3ot0RfG5dUvGCLYeh0Kc9qnK6WBmxKP7QOJKAyq+umq8Vu0OA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777664434; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eqPHCB75tll3tXHcvxHLlmoxOVuYxkKx2Tnm7nk9lbE=; b=bYOqpDw4bEGEI5Xha2b9BGiC2BQBGXSjnsf2iVzay4Gr+KyoS6BnpiXTi8yWRYFuiQGm+x L61e/WAsgWcXKgDw== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] posix-timers: Expand timer_[re]arm() callbacks with a boolean return value Cc: Thomas Gleixner , Frederic Weisbecker , "Peter Zijlstra (Intel)" , John Stultz , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260408114952.130222296@kernel.org> References: <20260408114952.130222296@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177766443272.3521451.14436820224967205467.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the timers/core branch of tip: Commit-ID: 6fdb2677a594ab38eade927919bbd4d9688bfa1c Gitweb: https://git.kernel.org/tip/6fdb2677a594ab38eade927919bbd4d96= 88bfa1c Author: Thomas Gleixner AuthorDate: Wed, 08 Apr 2026 13:53:56 +02:00 Committer: Thomas Gleixner CommitterDate: Fri, 01 May 2026 21:36:11 +02:00 posix-timers: Expand timer_[re]arm() callbacks with a boolean return value In order to catch expiry times which are already in the past the timer_arm() and timer_rearm() callbacks need to be able to report back to the caller whether the timer has been queued or not. Change the function signature and let all implementations return true for now. While at it simplify posix_cpu_timer_rearm(). No functional change intended. Signed-off-by: Thomas Gleixner Reviewed-by: Frederic Weisbecker Acked-by: Peter Zijlstra (Intel) Acked-by: John Stultz Link: https://patch.msgid.link/20260408114952.130222296@kernel.org --- kernel/time/alarmtimer.c | 6 ++++-- kernel/time/posix-cpu-timers.c | 18 ++++++++++-------- kernel/time/posix-timers.c | 6 ++++-- kernel/time/posix-timers.h | 4 ++-- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 6e173d7..e10021b 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -527,12 +527,13 @@ static void alarm_handle_timer(struct alarm *alarm, k= time_t now) * alarm_timer_rearm - Posix timer callback for rearming timer * @timr: Pointer to the posixtimer data struct */ -static void alarm_timer_rearm(struct k_itimer *timr) +static bool alarm_timer_rearm(struct k_itimer *timr) { struct alarm *alarm =3D &timr->it.alarm.alarmtimer; =20 timr->it_overrun +=3D alarm_forward_now(alarm, timr->it_interval); alarm_start(alarm, alarm->node.expires); + return true; } =20 /** @@ -588,7 +589,7 @@ static void alarm_timer_wait_running(struct k_itimer *t= imr) * @absolute: Expiry value is absolute time * @sigev_none: Posix timer does not deliver signals */ -static void alarm_timer_arm(struct k_itimer *timr, ktime_t expires, +static bool alarm_timer_arm(struct k_itimer *timr, ktime_t expires, bool absolute, bool sigev_none) { struct alarm *alarm =3D &timr->it.alarm.alarmtimer; @@ -600,6 +601,7 @@ static void alarm_timer_arm(struct k_itimer *timr, ktim= e_t expires, alarm->node.expires =3D expires; else alarm_start(&timr->it.alarm.alarmtimer, expires); + return true; } =20 /** diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c index 0de2bb7..395e297 100644 --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -19,7 +19,7 @@ =20 #include "posix-timers.h" =20 -static void posix_cpu_timer_rearm(struct k_itimer *timer); +static bool posix_cpu_timer_rearm(struct k_itimer *timer); =20 void posix_cputimers_group_init(struct posix_cputimers *pct, u64 cpu_limit) { @@ -1011,24 +1011,27 @@ static void check_process_timers(struct task_struct= *tsk, /* * This is called from the signal code (via posixtimer_rearm) * when the last timer signal was delivered and we have to reload the time= r. + * + * Return true unconditionally so the core code assumes the timer to be + * armed. Otherwise it would requeue the signal. */ -static void posix_cpu_timer_rearm(struct k_itimer *timer) +static bool posix_cpu_timer_rearm(struct k_itimer *timer) { clockid_t clkid =3D CPUCLOCK_WHICH(timer->it_clock); - struct task_struct *p; struct sighand_struct *sighand; + struct task_struct *p; unsigned long flags; u64 now; =20 - rcu_read_lock(); + guard(rcu)(); p =3D cpu_timer_task_rcu(timer); if (!p) - goto out; + return true; =20 /* Protect timer list r/w in arm_timer() */ sighand =3D lock_task_sighand(p, &flags); if (unlikely(sighand =3D=3D NULL)) - goto out; + return true; =20 /* * Fetch the current sample and update the timer's expiry time. @@ -1045,8 +1048,7 @@ static void posix_cpu_timer_rearm(struct k_itimer *ti= mer) */ arm_timer(timer, p); unlock_task_sighand(p, &flags); -out: - rcu_read_unlock(); + return true; } =20 /** diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 9331e16..da04ed4 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -288,12 +288,13 @@ static inline int timer_overrun_to_int(struct k_itime= r *timr) return (int)timr->it_overrun_last; } =20 -static void common_hrtimer_rearm(struct k_itimer *timr) +static bool common_hrtimer_rearm(struct k_itimer *timr) { struct hrtimer *timer =3D &timr->it.real.timer; =20 timr->it_overrun +=3D hrtimer_forward_now(timer, timr->it_interval); hrtimer_restart(timer); + return true; } =20 static bool __posixtimer_deliver_signal(struct kernel_siginfo *info, struc= t k_itimer *timr) @@ -795,7 +796,7 @@ SYSCALL_DEFINE1(timer_getoverrun, timer_t, timer_id) return timer_overrun_to_int(scoped_timer); } =20 -static void common_hrtimer_arm(struct k_itimer *timr, ktime_t expires, +static bool common_hrtimer_arm(struct k_itimer *timr, ktime_t expires, bool absolute, bool sigev_none) { struct hrtimer *timer =3D &timr->it.real.timer; @@ -822,6 +823,7 @@ static void common_hrtimer_arm(struct k_itimer *timr, k= time_t expires, =20 if (!sigev_none) hrtimer_start_expires(timer, HRTIMER_MODE_ABS); + return true; } =20 static int common_hrtimer_try_to_cancel(struct k_itimer *timr) diff --git a/kernel/time/posix-timers.h b/kernel/time/posix-timers.h index 7f259e8..4ea9611 100644 --- a/kernel/time/posix-timers.h +++ b/kernel/time/posix-timers.h @@ -27,11 +27,11 @@ struct k_clock { int (*timer_del)(struct k_itimer *timr); void (*timer_get)(struct k_itimer *timr, struct itimerspec64 *cur_setting); - void (*timer_rearm)(struct k_itimer *timr); + bool (*timer_rearm)(struct k_itimer *timr); s64 (*timer_forward)(struct k_itimer *timr, ktime_t now); ktime_t (*timer_remaining)(struct k_itimer *timr, ktime_t now); int (*timer_try_to_cancel)(struct k_itimer *timr); - void (*timer_arm)(struct k_itimer *timr, ktime_t expires, + bool (*timer_arm)(struct k_itimer *timr, ktime_t expires, bool absolute, bool sigev_none); void (*timer_wait_running)(struct k_itimer *timr); };