From nobody Mon Jun 15 00:09:28 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3B7B338C2B5; Tue, 7 Apr 2026 08:54:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552061; cv=none; b=YWvNSgnfzumMH6xF/ShiFugPmXW0xjML4ng8l/EilGXY5LlISWgzIIPYLxQkBerCLPT3XYrYN/ySFMeJ7mV6fxG6Ven8ISk1HkLo8pDj0yJ1fL4GNnEUk28wPdbI1jC5hO+r6T8Po6PFle6fvMi35dAz3uM0evJyul/HXSvdo7Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552061; c=relaxed/simple; bh=/xYs3O0kL0sYfj4X83LKJJkUOaxeLjU6FZ9MnfIN9Dc=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=Jxh4wDHm3/s2DkWqy7oSJrSXMzeUtVvPvarNLuE+s5WwwgLEN6X2ZDOl+V8Lbg7zGJQ0IKhaBuR/ZsN3WIVIxKr2pt6vtEQzTSV8bbqI5ATe72JK8vnzwBd333VgC06XJPsafFJ+OgT03e7S3GXJ9qUuh46EwFyJHRn25Ine1SM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eexOg75U; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eexOg75U" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58966C116C6; Tue, 7 Apr 2026 08:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775552060; bh=/xYs3O0kL0sYfj4X83LKJJkUOaxeLjU6FZ9MnfIN9Dc=; h=Date:From:To:Cc:Subject:References:From; b=eexOg75UKzbZNb3GzltnQtK9klmrNpQkDWWUEByY54h7u0xNb/ev5e5LtUKXPRgfB Me1olXlOEEahjOtRCXiK9JcGOnEx/asFDIl5YcflKbJ5dGWGtNCpAK4wPI25vjnv1W eftegC0fHHElzJcLwlnFbGwyHkG0u7yipY5s64/tCMGtnBbyaL+e7V120l/Sxld9x8 z4GeZCc8f4llZv7kDVmCqk7hmzK+XxZ4UNcw88vStrFc2HCtyyR/3+rsOvNH7yXy3K i1345GBKs2uaUWn3DdImYl8CnvsoAaWmMOfxbVZyV9nPwXsouXnh0TRak+Us4k5D/M acST9SMUSQU+Q== Date: Tue, 07 Apr 2026 10:54:17 +0200 Message-ID: <20260407083247.562657657@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Calvin Owens , Peter Zijlstra , Anna-Maria Behnsen , Frederic Weisbecker , Ingo Molnar , John Stultz , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , linux-fsdevel@vger.kernel.org, Sebastian Reichel , linux-pm@vger.kernel.org, Pablo Neira Ayuso , Florian Westphal , Phil Sutter , netfilter-devel@vger.kernel.org, coreteam@netfilter.org Subject: [patch 01/12] clockevents: Prevent timer interrupt starvation References: <20260407083219.478203185@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Thomas Gleixner Calvin reported an odd NMI watchdog lockup which claims that the CPU locked up in user space. He provided a reproducer, which sets up a timerfd based timer and then rearms it in a loop with an absolute expiry time of 1ns. As the expiry time is in the past, the timer ends up as the first expiring timer in the per CPU hrtimer base and the clockevent device is programmed with the minimum delta value. If the machine is fast enough, this ends up in a endless loop of programming the delta value to the minimum value defined by the clock event device, before the timer interrupt can fire, which starves the interrupt and consequently triggers the lockup detector because the hrtimer callback of the lockup mechanism is never invoked. As a first step to prevent this, avoid reprogramming the clock event device when: - a forced minimum delta event is pending - the new expiry delta is less then or equal to the minimum delta Thanks to Calvin for providing the reproducer and to Borislav for testing and providing data from his Zen5 machine. The problem is not limited to Zen5, but depending on the underlying clock event device (e.g. TSC deadline timer on Intel) and the CPU speed not necessarily observable. This change serves only as the last resort and further changes will be made to prevent this scenario earlier in the call chain as far as possible. Fixes: d316c57ff6bf ("[PATCH] clockevents: add core functionality") Reported-by: Calvin Owens Signed-off-by: Thomas Gleixner Cc: Peter Zijlstra Cc: Anna-Maria Behnsen Cc: Frederic Weisbecker Cc: Ingo Molnar Link: https://lore.kernel.org/lkml/acMe-QZUel-bBYUh@mozart.vkv.me/ Reviewed-by: Frederic Weisbecker Tested-by: Calvin Owens Tested-by: Eric Naim --- V2: Simplified the clockevents code - Peter --- include/linux/clockchips.h | 2 ++ kernel/time/clockevents.c | 23 +++++++++++++++-------- kernel/time/hrtimer.c | 1 + kernel/time/tick-common.c | 1 + kernel/time/tick-sched.c | 1 + 5 files changed, 20 insertions(+), 8 deletions(-) --- a/include/linux/clockchips.h +++ b/include/linux/clockchips.h @@ -80,6 +80,7 @@ enum clock_event_state { * @shift: nanoseconds to cycles divisor (power of two) * @state_use_accessors:current state of the device, assigned by the core = code * @features: features + * @next_event_forced: True if the last programming was a forced event * @retries: number of forced programming retries * @set_state_periodic: switch state to periodic * @set_state_oneshot: switch state to oneshot @@ -108,6 +109,7 @@ struct clock_event_device { u32 shift; enum clock_event_state state_use_accessors; unsigned int features; + unsigned int next_event_forced; unsigned long retries; =20 int (*set_state_periodic)(struct clock_event_device *); --- a/kernel/time/clockevents.c +++ b/kernel/time/clockevents.c @@ -172,6 +172,7 @@ void clockevents_shutdown(struct clock_e { clockevents_switch_state(dev, CLOCK_EVT_STATE_SHUTDOWN); dev->next_event =3D KTIME_MAX; + dev->next_event_forced =3D 0; } =20 /** @@ -305,7 +306,6 @@ int clockevents_program_event(struct clo { unsigned long long clc; int64_t delta; - int rc; =20 if (WARN_ON_ONCE(expires < 0)) return -ETIME; @@ -324,16 +324,23 @@ int clockevents_program_event(struct clo return dev->set_next_ktime(expires, dev); =20 delta =3D ktime_to_ns(ktime_sub(expires, ktime_get())); - if (delta <=3D 0) - return force ? clockevents_program_min_delta(dev) : -ETIME; =20 - delta =3D min(delta, (int64_t) dev->max_delta_ns); - delta =3D max(delta, (int64_t) dev->min_delta_ns); + if (delta > (int64_t)dev->min_delta_ns) { + delta =3D min(delta, (int64_t) dev->max_delta_ns); + clc =3D ((unsigned long long) delta * dev->mult) >> dev->shift; + if (!dev->set_next_event((unsigned long) clc, dev)) + return 0; + } =20 - clc =3D ((unsigned long long) delta * dev->mult) >> dev->shift; - rc =3D dev->set_next_event((unsigned long) clc, dev); + if (dev->next_event_forced) + return 0; =20 - return (rc && force) ? clockevents_program_min_delta(dev) : rc; + if (dev->set_next_event(dev->min_delta_ticks, dev)) { + if (!force || clockevents_program_min_delta(dev)) + return -ETIME; + } + dev->next_event_forced =3D 1; + return 0; } =20 /* --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1888,6 +1888,7 @@ void hrtimer_interrupt(struct clock_even BUG_ON(!cpu_base->hres_active); cpu_base->nr_events++; dev->next_event =3D KTIME_MAX; + dev->next_event_forced =3D 0; =20 raw_spin_lock_irqsave(&cpu_base->lock, flags); entry_time =3D now =3D hrtimer_update_base(cpu_base); --- a/kernel/time/tick-common.c +++ b/kernel/time/tick-common.c @@ -110,6 +110,7 @@ void tick_handle_periodic(struct clock_e int cpu =3D smp_processor_id(); ktime_t next =3D dev->next_event; =20 + dev->next_event_forced =3D 0; tick_periodic(cpu); =20 /* --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1513,6 +1513,7 @@ static void tick_nohz_lowres_handler(str struct tick_sched *ts =3D this_cpu_ptr(&tick_cpu_sched); =20 dev->next_event =3D KTIME_MAX; + dev->next_event_forced =3D 0; =20 if (likely(tick_nohz_handler(&ts->sched_timer) =3D=3D HRTIMER_RESTART)) tick_program_event(hrtimer_get_expires(&ts->sched_timer), 1); From nobody Mon Jun 15 00:09:28 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3720339A7E5; Tue, 7 Apr 2026 08:54:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552066; cv=none; b=eag682FHmTBfJ+9fjNGj9ZJfnAL5gFa0lJ6DJuZRJw1+SoeGCObmLgrMVRRIhG7ZzivjTz2tbqC/REWlPbIJ8rGnpmtceFiCRFGUrY19V3sjgvckK6cL74H4i62jpryhqiPxsx2oJihWlilLls08VFDgmcgmb4IvMo11ErZ5l9c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552066; c=relaxed/simple; bh=1moD5YRre+7PFAa0cZ6BeO4IeU3BIQxcY31TfBcyn8o=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=X9/5jmv+cUK2i6rH1WZtfQqyvTabUD9sV0vtQPO5Gy9ILzOCMYUpLLdRnIE9uIfDJ3GkUhH5OpiCHKzCA0Dk6vQGE8KzqnQIoxuuUCd0HC5dSrk/vUKFsYKzFqU8T+xlPqwhtPKsULr9b3JYh6QMiWsqWANkmuuCwrxCsGEgSuc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YwSajaqU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YwSajaqU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44464C116C6; Tue, 7 Apr 2026 08:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775552065; bh=1moD5YRre+7PFAa0cZ6BeO4IeU3BIQxcY31TfBcyn8o=; h=Date:From:To:Cc:Subject:References:From; b=YwSajaqUJG6X1oGQYuQhF19EW9GJXLFGJgVgFOwd38THJA1YukJTodCEUCrtI3ike K1tqccGIUYChfXwIiSZPLId2qP9/PvCRk/QIxGz1MZSYvnxBaAfdU/r4FHv/FMrUUh tfeAnkh1wkF6FkkTn3GMvlkqGjXkOYGt4iGBo5x2c+yWlaVaHKm7X0V9y0FJlvkV5B sSAdLo7+eeEaT789qLZCAkcYN5zdCDUqf2+kyeg6GelLjg9dW9QrymMYqT1KWJe+Cx jE8uvH30NP8oLuzPu9v9+kchbniNFQ8VA3HUy+mrq5+yRG/z+fpYolZqR1e1ZW1eNy ekyM/il3SDSCg== Date: Tue, 07 Apr 2026 10:54:22 +0200 Message-ID: <20260407083247.630389532@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Calvin Owens , Anna-Maria Behnsen , Frederic Weisbecker , Peter Zijlstra , Ingo Molnar , John Stultz , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , linux-fsdevel@vger.kernel.org, Sebastian Reichel , linux-pm@vger.kernel.org, Pablo Neira Ayuso , Florian Westphal , Phil Sutter , netfilter-devel@vger.kernel.org, coreteam@netfilter.org Subject: [patch 02/12] hrtimer: Provide hrtimer_start_range_ns_user() References: <20260407083219.478203185@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Calvin reported an odd NMI watchdog lockup which claims that the CPU locked up in user space. He provided a reproducer, which set's up a timerfd based timer and then rearms it in a loop with an absolute expiry time of 1ns. As the expiry time is in the past, the timer ends up as the first expiring timer in the per CPU hrtimer base and the clockevent device is programmed with the minimum delta value. If the machine is fast enough, this ends up in a endless loop of programming the delta value to the minimum value defined by the clock event device, before the timer interrupt can fire, which starves the interrupt and consequently triggers the lockup detector because the hrtimer callback of the lockup mechanism is never invoked. The clockevents code already has a last resort mechanism to prevent that, but it's sensible to catch such issues before trying to reprogram the clock event device. Provide a variant of hrtimer_start_range_ns(), which sanity checks the timer after queueing it. It does not so before because the timer might be armed and therefore needs to be dequeued. also we optimize for the latest possible point to check, so that the clock event prevention is avoided as much as possible. If the timer is already expired _before_ the clock event is reprogrammed, remove the timer from the queue and signal to the caller that the operation failed by returning false. That allows the caller to take immediate action without going through the loops and hoops of the hrtimer interrupt. The queueing code can't invoke the timer callback as the caller might hold a lock which is taken in the callback. Add a tracepoint which allows to analyze the expired at start situation. Reported-by: Calvin Owens Signed-off-by: Thomas Gleixner Cc: Anna-Maria Behnsen Cc: Frederic Weisbecker Tested-by: Calvin Owens --- include/linux/hrtimer.h | 20 +++++- include/trace/events/timer.h | 13 ++++ kernel/time/hrtimer.c | 135 ++++++++++++++++++++++++++++++++++++++= ----- 3 files changed, 151 insertions(+), 17 deletions(-) --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -230,6 +230,9 @@ static inline void destroy_hrtimer_on_st extern void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, u64 range_ns, const enum hrtimer_mode mode); =20 +extern bool hrtimer_start_range_ns_user(struct hrtimer *timer, ktime_t tim, + u64 range_ns, const enum hrtimer_mode mode); + /** * hrtimer_start - (re)start an hrtimer * @timer: the timer to be added @@ -247,17 +250,28 @@ static inline void hrtimer_start(struct extern int hrtimer_cancel(struct hrtimer *timer); extern int hrtimer_try_to_cancel(struct hrtimer *timer); =20 -static inline void hrtimer_start_expires(struct hrtimer *timer, - enum hrtimer_mode mode) +static inline void hrtimer_start_expires(struct hrtimer *timer, enum hrtim= er_mode mode) { - u64 delta; ktime_t soft, hard; + u64 delta; + soft =3D hrtimer_get_softexpires(timer); hard =3D hrtimer_get_expires(timer); delta =3D ktime_to_ns(ktime_sub(hard, soft)); hrtimer_start_range_ns(timer, soft, delta, mode); } =20 +static inline bool hrtimer_start_expires_user(struct hrtimer *timer, enum = hrtimer_mode mode) +{ + ktime_t soft, hard; + u64 delta; + + soft =3D hrtimer_get_softexpires(timer); + hard =3D hrtimer_get_expires(timer); + delta =3D ktime_to_ns(ktime_sub(hard, soft)); + return hrtimer_start_range_ns_user(timer, soft, delta, mode); +} + void hrtimer_sleeper_start_expires(struct hrtimer_sleeper *sl, enum hrtimer_mode mode); =20 --- a/include/trace/events/timer.h +++ b/include/trace/events/timer.h @@ -297,6 +297,19 @@ DECLARE_EVENT_CLASS(hrtimer_class, ); =20 /** + * hrtimer_start_expired - Invoked when a expired timer was started + * @hrtimer: pointer to struct hrtimer + * + * Preceeded by a hrtimer_start tracepoint. + */ +DEFINE_EVENT(hrtimer_class, hrtimer_start_expired, + + TP_PROTO(struct hrtimer *hrtimer), + + TP_ARGS(hrtimer) +); + +/** * hrtimer_expire_exit - called immediately after the hrtimer callback ret= urns * @hrtimer: pointer to struct hrtimer * --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1215,6 +1215,12 @@ hrtimer_update_softirq_timer(struct hrti hrtimer_reprogram(cpu_base->softirq_next_timer, reprogram); } =20 +enum { + HRTIMER_REPROGRAM_NONE, + HRTIMER_REPROGRAM, + HRTIMER_REPROGRAM_FORCE, +}; + static int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, u64 delta_ns, const enum hrtimer_mode mode, struct hrtimer_clock_base *base) @@ -1276,7 +1282,7 @@ static int __hrtimer_start_range_ns(stru * expiring timer there. */ if (hrtimer_base_is_online(this_cpu_base)) - return first; + return first ? HRTIMER_REPROGRAM : HRTIMER_REPROGRAM_NONE; =20 /* * Timer was enqueued remote because the current base is @@ -1296,8 +1302,24 @@ static int __hrtimer_start_range_ns(stru * reprogramming on removal and enqueue. Force reprogram the * hardware by evaluating the new first expiring timer. */ - hrtimer_force_reprogram(new_base->cpu_base, 1); - return 0; + return HRTIMER_REPROGRAM_FORCE; +} + +static int hrtimer_start_range_ns_common(struct hrtimer *timer, ktime_t ti= m, + u64 delta_ns, const enum hrtimer_mode mode, + struct hrtimer_clock_base *base) +{ + /* + * Check whether the HRTIMER_MODE_SOFT bit and hrtimer.is_soft + * match on CONFIG_PREEMPT_RT =3D n. With PREEMPT_RT check the hard + * expiry mode because unmarked timers are moved to softirq expiry. + */ + if (!IS_ENABLED(CONFIG_PREEMPT_RT)) + WARN_ON_ONCE(!(mode & HRTIMER_MODE_SOFT) ^ !timer->is_soft); + else + WARN_ON_ONCE(!(mode & HRTIMER_MODE_HARD) ^ !timer->is_hard); + + return __hrtimer_start_range_ns(timer, tim, delta_ns, mode, base); } =20 /** @@ -1315,25 +1337,110 @@ void hrtimer_start_range_ns(struct hrtim struct hrtimer_clock_base *base; unsigned long flags; =20 - /* - * Check whether the HRTIMER_MODE_SOFT bit and hrtimer.is_soft - * match on CONFIG_PREEMPT_RT =3D n. With PREEMPT_RT check the hard - * expiry mode because unmarked timers are moved to softirq expiry. - */ - if (!IS_ENABLED(CONFIG_PREEMPT_RT)) - WARN_ON_ONCE(!(mode & HRTIMER_MODE_SOFT) ^ !timer->is_soft); - else - WARN_ON_ONCE(!(mode & HRTIMER_MODE_HARD) ^ !timer->is_hard); - base =3D lock_hrtimer_base(timer, &flags); =20 - if (__hrtimer_start_range_ns(timer, tim, delta_ns, mode, base)) + switch (hrtimer_start_range_ns_common(timer, tim, delta_ns, mode, base)) { + case HRTIMER_REPROGRAM: hrtimer_reprogram(timer, true); + break; + case HRTIMER_REPROGRAM_FORCE: + hrtimer_force_reprogram(timer->base->cpu_base, 1); + break; + } =20 unlock_hrtimer_base(timer, &flags); } EXPORT_SYMBOL_GPL(hrtimer_start_range_ns); =20 +static inline bool hrtimer_check_user_timer(struct hrtimer *timer) +{ + struct hrtimer_cpu_base *cpu_base =3D timer->base->cpu_base; + ktime_t expires; + + /* + * This uses soft expires because that's the user provided + * expiry time, while expires can be further in the past + * due to a slack value added to the user expiry time. + */ + expires =3D hrtimer_get_softexpires(timer); + + /* Convert to monotonic */ + expires =3D ktime_sub(expires, timer->base->offset); + + /* + * Check whether this timer will end up as the first expiring timer in + * the CPU base. If not, no further checks required as it's then + * guaranteed to expire in the future. + */ + if (expires >=3D cpu_base->expires_next) + return true; + + /* Validate that the expiry time is in the future. */ + if (expires > ktime_get()) + return true; + + debug_deactivate(timer); + __remove_hrtimer(timer, timer->base, HRTIMER_STATE_INACTIVE, false); + trace_hrtimer_start_expired(timer); + return false; +} + +static bool hrtimer_reprogram_user(struct hrtimer *timer) +{ + if (!hrtimer_check_user_timer(timer)) + return false; + hrtimer_reprogram(timer, true); + return true; +} + +static bool hrtimer_force_reprogram_user(struct hrtimer *timer) +{ + bool ret =3D hrtimer_check_user_timer(timer); + + /* + * The base must always be reevaluated, independent of the result + * above because the timer was the first pending timer. + */ + hrtimer_force_reprogram(timer->base->cpu_base, 1); + return ret; +} + +/** + * hrtimer_start_range_ns_user - (re)start an user controlled hrtimer + * @timer: the timer to be added + * @tim: expiry time + * @delta_ns: "slack" range for the timer + * @mode: timer mode: absolute (HRTIMER_MODE_ABS) or + * relative (HRTIMER_MODE_REL), and pinned (HRTIMER_MODE_PINNED); + * softirq based mode is considered for debug purpose only! + * + * Returns: True when the timer was queued, false if it was already expired + * + * This function cannot invoke the timer callback for expired timers as it= might + * be called under a lock which the timer callback needs to acquire. So the + * caller has to handle that case. + */ +bool hrtimer_start_range_ns_user(struct hrtimer *timer, ktime_t tim, + u64 delta_ns, const enum hrtimer_mode mode) +{ + struct hrtimer_clock_base *base; + unsigned long flags; + bool ret =3D true; + + base =3D lock_hrtimer_base(timer, &flags); + switch (hrtimer_start_range_ns_common(timer, tim, delta_ns, mode, base)) { + case HRTIMER_REPROGRAM: + ret =3D hrtimer_reprogram_user(timer); + break; + case HRTIMER_REPROGRAM_FORCE: + ret =3D hrtimer_force_reprogram_user(timer); + break; + } + unlock_hrtimer_base(timer, &flags); + return ret; +} +EXPORT_SYMBOL_GPL(hrtimer_start_range_ns_user); + /** * hrtimer_try_to_cancel - try to deactivate a timer * @timer: hrtimer to stop From nobody Mon Jun 15 00:09:28 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9B40513959D; Tue, 7 Apr 2026 08:54:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552071; cv=none; b=mc173cvBNuq5u7Ddk4andjoajGIAHYTslm+ji+gBeoZfRialL/CCwFpd6omWM5z907pgjpoofMv7nkSLRuzfz1lNnFHsKpq6D+0bFbPbY7IHa0+/TthsG0mr6waWYj4BxQcxzeGR9iM+xaVmyV1CPcIBX30qAsyy23B7x74rgsA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552071; c=relaxed/simple; bh=rPiPz7V/oa6BVLR04d4w2xpckltBEql69hps4FtNBgw=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=dFya22lCoHdZSxa5o8sYcSnvSmeBQ2zdPoJ3fPH2smUNHiKgnis9oGAvQ5PDEsfusGb8/9FPduYD0LmdUysG9g/v8HH30Xgw4b9FZ+Ck1oGtNwHo9eBpeadwXm4CXdZPxQE6o7G4HeJfzpIDFXC6xRDDF00shbNnGktR/5Vt1dU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tEozzz2D; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tEozzz2D" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7AB3EC2BCB0; Tue, 7 Apr 2026 08:54:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775552071; bh=rPiPz7V/oa6BVLR04d4w2xpckltBEql69hps4FtNBgw=; h=Date:From:To:Cc:Subject:References:From; b=tEozzz2DUvKuprkn0KlMRnl92+kN8kWSiP9lI9cpjAf8QvQlTKNuRgXAs6g+cejd6 B9bDz79b4vdywpFarLLlN8i9f2mqJbg1wpcje0zqKqX4ntwTobEDRxHRSAhjowbWTY UJt9UvNfYi6kmZr6U1GnIsJZI8wKFCGSqAXb+D+R8KBwJRfGHbes4CFWvj36XQ2mc2 mC9fMbgouXbGZxwS2g58RckGdMdZKI75F2X5Yg/+n3lqVSmnTAyocqZbf69slkS7He QfC7n2b72THhiwWYq/tRt2Kd0lPXkvfXwTlk/niFoODO1KQN+DEjJ6Tm4aBEW1Xq/2 SU0x5J/BIinXw== Date: Tue, 07 Apr 2026 10:54:27 +0200 Message-ID: <20260407083247.696142908@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Anna-Maria Behnsen , Frederic Weisbecker , Calvin Owens , Peter Zijlstra , Ingo Molnar , John Stultz , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , linux-fsdevel@vger.kernel.org, Sebastian Reichel , linux-pm@vger.kernel.org, Pablo Neira Ayuso , Florian Westphal , Phil Sutter , netfilter-devel@vger.kernel.org, coreteam@netfilter.org Subject: [patch 03/12] hrtimer: Use hrtimer_start_expires_user() for hrtimer sleepers References: <20260407083219.478203185@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Most hrtimer sleepers are user controlled and user space can hand arbitrary expiry values in as long as they are valid timespecs. If the expiry value is in the past then this requires a full loop through reprogramming the clock event device, taking the hrtimer interrupt, waking the task and reprogram again. Use hrtimer_start_expires_user() which avoids the full round trip by checking the timer for expiry on enqueue. Signed-off-by: Thomas Gleixner Cc: Anna-Maria Behnsen Cc: Frederic Weisbecker Acked-by: Peter Zijlstra (Intel) Tested-by: Calvin Owens --- kernel/time/hrtimer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -2152,7 +2152,11 @@ void hrtimer_sleeper_start_expires(struc if (IS_ENABLED(CONFIG_PREEMPT_RT) && sl->timer.is_hard) mode |=3D HRTIMER_MODE_HARD; =20 - hrtimer_start_expires(&sl->timer, mode); + /* If already expired, clear the task pointer and set current state to ru= nning */ + if (!hrtimer_start_expires_user(&sl->timer, mode)) { + sl->task =3D NULL; + __set_current_state(TASK_RUNNING); + } } EXPORT_SYMBOL_GPL(hrtimer_sleeper_start_expires); From nobody Mon Jun 15 00:09:28 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 ECDC5399373; Tue, 7 Apr 2026 08:54:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552077; cv=none; b=HTs5eB+QsppEBKwGl9WPKn1sZZp7wQNbczAUaj7pGHDgniMtMzpLtr9GnWxOdkt4liw566vkp+4CBHTvsQjeCgPTIAMru/lOMm0rDlDatu0OKR6GCXV8qbVcbglcxViBFWab19puLu5C5PeI96/EGQmS5aW7/LBF3IdjgUnGnvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552077; c=relaxed/simple; bh=fg5QkEhmDz/cgOtfzkM/5WwK/iSkv+EmITv2kHMzaOY=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=gnx+XWee6OKtTWaXhupP6T3r8r/9jlMlDmulCkpII6Se8qFustNeRspyIc7GMVapkqkwQt3Hr4V2w05HCGVVOvdOy5uij6jasdTNc/m3lI7waDa5NMwftZHIeF/UT5SLIoJHAxWD7mUDut6x8l7KvdU1HvvNlqlxXHnHCzwigbU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=n1Bw8dCu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="n1Bw8dCu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB8DAC116C6; Tue, 7 Apr 2026 08:54:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775552076; bh=fg5QkEhmDz/cgOtfzkM/5WwK/iSkv+EmITv2kHMzaOY=; h=Date:From:To:Cc:Subject:References:From; b=n1Bw8dCuEoUDyisTz3XSnH43hxiIt6uQzDP4A0CTwL3gjv/OjP42U5Nn1/lEbHnhV VAwYW71QUOM+CC+jXwtmtjaCbIHEq/EDPl9p1guC/lje5aUDLLVg8gPMLiCxOqIgk8 Ghv8o06eH15s57o4hH6/+3QnwoD9dwphGCNM868VNLoTyZB+QuJ9sZ+OzG4alPnk4E HcUjY8qyWmFFMZutdVKN2PGfnhoLxD60GCjTnKguB4CkTf6PjN0cZCKlSY8wRA1ao+ TXcvoZosP3BoQGHZhnXfeDylVhrXDH7IAOviVEUXFcB/wbkGhKBfQ9+kU8iO3M6YEn XfXA8XZaxNLGw== Date: Tue, 07 Apr 2026 10:54:33 +0200 Message-ID: <20260407083247.763539663@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: John Stultz , Stephen Boyd , Anna-Maria Behnsen , Frederic Weisbecker , Calvin Owens , Peter Zijlstra , Ingo Molnar , Alexander Viro , Christian Brauner , Jan Kara , linux-fsdevel@vger.kernel.org, Sebastian Reichel , linux-pm@vger.kernel.org, Pablo Neira Ayuso , Florian Westphal , Phil Sutter , netfilter-devel@vger.kernel.org, coreteam@netfilter.org Subject: [patch 04/12] posix-timers: Expand timer_[re]arm() callbacks with a boolean return value References: <20260407083219.478203185@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Cc: John Stultz Cc: Stephen Boyd Cc: Anna-Maria Behnsen Cc: Frederic Weisbecker Acked-by: John Stultz Acked-by: Peter Zijlstra (Intel) Tested-by: Calvin Owens --- 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(-) --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -523,12 +523,13 @@ static void alarm_handle_timer(struct al * 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 /** @@ -584,7 +585,7 @@ static void alarm_timer_wait_running(str * @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; @@ -596,6 +597,7 @@ static void alarm_timer_arm(struct k_iti alarm->node.expires =3D expires; else alarm_start(&timr->it.alarm.alarmtimer, expires); + return true; } =20 /** --- 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 /* * 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 */ arm_timer(timer, p); unlock_task_sighand(p, &flags); -out: - rcu_read_unlock(); + return true; } =20 /** --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -288,12 +288,13 @@ static inline int timer_overrun_to_int(s 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_ 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_ =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) --- 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); }; From nobody Mon Jun 15 00:09:28 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6C1B039A800; Tue, 7 Apr 2026 08:54:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552081; cv=none; b=pnSfIM0qHDT+gmIXKOekO1B7V2wsG9INdCW27+5QXskyUez5ctP0QZ7vDWaJ5tl72QZHXXZ1uiEs0pFmRqJK+O91IN3fT4pt16fjkSsfCv37ccKOQbXsvMuMbMLAzQet+UkyH0y4jt986rfO4gaV0XMUw6w2nbdNveM2uRyyCuE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552081; c=relaxed/simple; bh=UL+6LCFKPk7yFRK5fJynV3ISPtCdF2Q7VprzdKpG5nY=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=XJinogf5mieRT8HeTB34aYb9g8qBj31p4O9yWrLowDKfBSpYOgu9N5lndr3OmOSLB3nkeAmng/drdZToeEtnlbnMOoHd7yoGIaO+h3SeoKolcxq80BoryjZJc2FBGPttnmUoBYRL09klh1CQMclZ9EdXTwhgbsmaPYz2iSnpq/M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Dc+oyp3H; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Dc+oyp3H" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3577C116C6; Tue, 7 Apr 2026 08:54:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775552081; bh=UL+6LCFKPk7yFRK5fJynV3ISPtCdF2Q7VprzdKpG5nY=; h=Date:From:To:Cc:Subject:References:From; b=Dc+oyp3HDzq2W0AHQxB+zsNiplHE4y7RN7NfWpV/DCznDKnLMSQoWq+MVs9GN00i2 opR4INWui9lEgMqTXmR1Wy0Hyq75xHwCuQHQzImwLD9EcSWfw0VAWXreqxOmXgh/dV rdyQnC9PpKDAoPf5P7f1IX0/LKeswUNawNvRa4bdrMDdCRZQ05MjKxtSBRYoICXPl4 ysgI13NMqf2MFyEk1AUXbxA1MN9Bjci2QkTtBnfZgWK28EKi+F8zBNbdYSfQ8CG0b4 e/VoJ3R6R/945cQUaZjaqyPOWQRkgM6U19oZNIi3+sO2cJH1nvIV49ex/x1XNiTTmA VkVtbr80y39TQ== Date: Tue, 07 Apr 2026 10:54:38 +0200 Message-ID: <20260407083247.831143104@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Anna-Maria Behnsen , Frederic Weisbecker , Calvin Owens , Peter Zijlstra , Ingo Molnar , John Stultz , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , linux-fsdevel@vger.kernel.org, Sebastian Reichel , linux-pm@vger.kernel.org, Pablo Neira Ayuso , Florian Westphal , Phil Sutter , netfilter-devel@vger.kernel.org, coreteam@netfilter.org Subject: [patch 05/12] posix-timers: Handle the timer_[re]arm() return value References: <20260407083219.478203185@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The [re]arm callbacks will return true when the timer was queued and false if it was already expired at enqueue time. In both cases the call sites can trivially queue the signal right there, when the timer was already expired. Signed-off-by: Thomas Gleixner Cc: Anna-Maria Behnsen Cc: Frederic Weisbecker Acked-by: Peter Zijlstra (Intel) Tested-by: Calvin Owens --- kernel/time/posix-timers.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -299,6 +299,8 @@ static bool common_hrtimer_rearm(struct =20 static bool __posixtimer_deliver_signal(struct kernel_siginfo *info, struc= t k_itimer *timr) { + bool queued; + guard(spinlock)(&timr->it_lock); =20 /* @@ -312,12 +314,18 @@ static bool __posixtimer_deliver_signal( if (!timr->it_interval || WARN_ON_ONCE(timr->it_status !=3D POSIX_TIMER_R= EQUEUE_PENDING)) return true; =20 - timr->kclock->timer_rearm(timr); - timr->it_status =3D POSIX_TIMER_ARMED; + /* timer_rearm() updates timr::it_overrun */ + queued =3D timr->kclock->timer_rearm(timr); + timr->it_overrun_last =3D timr->it_overrun; timr->it_overrun =3D -1LL; ++timr->it_signal_seq; info->si_overrun =3D timer_overrun_to_int(timr); + + if (queued) + timr->it_status =3D POSIX_TIMER_ARMED; + else + posix_timer_queue_signal(timr); return true; } =20 @@ -905,9 +913,13 @@ int common_timer_set(struct k_itimer *ti expires =3D timens_ktime_to_host(timr->it_clock, expires); sigev_none =3D timr->it_sigev_notify =3D=3D SIGEV_NONE; =20 - kc->timer_arm(timr, expires, flags & TIMER_ABSTIME, sigev_none); - if (!sigev_none) - timr->it_status =3D POSIX_TIMER_ARMED; + if (kc->timer_arm(timr, expires, flags & TIMER_ABSTIME, sigev_none)) { + if (!sigev_none) + timr->it_status =3D POSIX_TIMER_ARMED; + } else { + /* Timer was already expired, queue the signal */ + posix_timer_queue_signal(timr); + } return 0; } From nobody Mon Jun 15 00:09:28 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 899FD39A7F8; Tue, 7 Apr 2026 08:54:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552086; cv=none; b=HHPlYP+eHvGoVdqgYf0gE6pQk1FQhAQN1EKYBnMXeCNt/j8GWrEO+TTGyugmYBbCaqqOye1nYpfo3nShgeZ/upr1yhz0rdQ6GMfVcmeab0yrEcuIciU5WB+TMVPDng5OcxVkD3cLBes4D29WzXS5vFls4xz5jf82Vqsy9tZt6uQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552086; c=relaxed/simple; bh=SjBcneGtGEBBNpNj//JNTkqgCJxRCk2wahLRcyQu83M=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=IfoR/nuX+re4LJatjJiAaFKOCRl4KFmS2fkNRNVTwHb1PEbSt/gcfafy3OQgNMgvT85vhP83lXyJwvFsNVdVaDXi8PeknpbxM5Z8AlRfQVd2jTnpDqLSkmxddP322BTPHKVb9EX637ArAbU5teb9c859ibHKoICKhikOnsbJDNE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ndIuyLJn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ndIuyLJn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F3B3C2BC9E; Tue, 7 Apr 2026 08:54:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775552086; bh=SjBcneGtGEBBNpNj//JNTkqgCJxRCk2wahLRcyQu83M=; h=Date:From:To:Cc:Subject:References:From; b=ndIuyLJnqI4xTXK8fAk0gJhLGYSqS9IVQnjgQr9yi/hh/j8Z3mUC0glA8C2s4E3AM KL3ziHhdsMj7VZm01vEc18AMd3vMBigSAblgHUV/0NbRGR9GOdHTuJNRZieV0eZ8lx JTco+fCBHhjilmukPJ1hf+QQMGiACiN1fdB6VX4XwN30paB5ZjbHw7nXrCs5CxfqcF vDdStCbbkezwEPf4VASCsLggWtcRWidwcVbiNg49LmV8olNqALIMg1kCv2MIezjUea hWgvdl0UcVAZEUt4UImTRaj5IUSaxPZ+f/E/OF3KljHfDAOlrZ/8oz5pBMHDtdDA1P lfJHo8jlIpypg== Date: Tue, 07 Apr 2026 10:54:43 +0200 Message-ID: <20260407083247.898494239@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Anna-Maria Behnsen , Frederic Weisbecker , Calvin Owens , Peter Zijlstra , Ingo Molnar , John Stultz , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , linux-fsdevel@vger.kernel.org, Sebastian Reichel , linux-pm@vger.kernel.org, Pablo Neira Ayuso , Florian Westphal , Phil Sutter , netfilter-devel@vger.kernel.org, coreteam@netfilter.org Subject: [patch 06/12] posix-timers: Switch to hrtimer_start_expires_user() References: <20260407083219.478203185@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Switch the arm and rearm callbacks for hrtimer based posix timers over to hrtimer_start_expires_user() so that already expired timers are not queued. Hand the result back to the caller, which then queues the signal. Signed-off-by: Thomas Gleixner Cc: Anna-Maria Behnsen Cc: Frederic Weisbecker Acked-by: Peter Zijlstra (Intel) Tested-by: Calvin Owens --- kernel/time/posix-timers.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -293,8 +293,7 @@ static bool common_hrtimer_rearm(struct 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; + return hrtimer_start_expires_user(timer, HRTIMER_MODE_ABS); } =20 static bool __posixtimer_deliver_signal(struct kernel_siginfo *info, struc= t k_itimer *timr) @@ -829,9 +828,11 @@ static bool common_hrtimer_arm(struct k_ expires =3D ktime_add_safe(expires, hrtimer_cb_get_time(timer)); hrtimer_set_expires(timer, expires); =20 - if (!sigev_none) - hrtimer_start_expires(timer, HRTIMER_MODE_ABS); - return true; + /* For sigev_none pretend that the timer is queued */ + if (sigev_none) + return true; + + return hrtimer_start_expires_user(timer, HRTIMER_MODE_ABS); } =20 static int common_hrtimer_try_to_cancel(struct k_itimer *timr) From nobody Mon Jun 15 00:09:28 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B9E7F39A7E5; Tue, 7 Apr 2026 08:54:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552091; cv=none; b=n4fA6ubmxN5AwIPxILYTBy84FmnMJRierInFvV0AQwPeE99BfwpbGJlOA/fTtcXIPV2RExXScnincRtQXD16iE7G4seUjNWtERxFcol3QaGTqfEEbUzR9mkfg5c0pKCDUW8ft72M0UWNvxx8PKR6AjGSr8kpsJyg/R75B3atqs0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552091; c=relaxed/simple; bh=HVbYIByFSN+TWQMQtOO5s/XrlbdzeKGowXqhoZ1SPWU=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=hZQXmiFDS0AfbGm8fH5gl1kdtmN8/RT3TyvGs8vjyjJuCBoREb/9RH2GFP6GPctVTHLhcg4U9CSLzmW1Y/l0fHDU1Sko8DkYSUmwtExZ/w3y0eYantiQIQoRELVa7M1pdQP3x5oUmE4VqpNKAyBpyO33ZFREY5WkM3VfX1CjYWw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=B0+sjaJI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="B0+sjaJI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D49B7C116C6; Tue, 7 Apr 2026 08:54:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775552091; bh=HVbYIByFSN+TWQMQtOO5s/XrlbdzeKGowXqhoZ1SPWU=; h=Date:From:To:Cc:Subject:References:From; b=B0+sjaJIuGE4mFMigwRoPUvZUWwbO5cH8Gdbg09DMFOnVTG0FQYDSTQHLNVCXdK3V X7O+NDyKp+SaDBp730XnWN+59hG8wavraM+vUSg8bnAmLjFJjd0KnrE+R8aZ7SOSh3 +FPJKIEsg7lQehOafwPnpQvypqLZw4RelwCUHOcXB2U7YtKIxEgKcPeVVgJxOw7nRd dHrwRPHNxLOXTuvAmvm4le081QJSzMJ54bfotCe/hQBkehWK4cyFt1iqt4sW3DNoFN B2+lYl5z30N9T5m8C991EZPdLx1BrYZ+f8vLdcVmk4YAPdhSNX+OTxM3wvSow9vxeH 8yBNvJKIew7eQ== Date: Tue, 07 Apr 2026 10:54:48 +0200 Message-ID: <20260407083247.965539525@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: John Stultz , Stephen Boyd , Calvin Owens , Peter Zijlstra , Anna-Maria Behnsen , Frederic Weisbecker , Ingo Molnar , Alexander Viro , Christian Brauner , Jan Kara , linux-fsdevel@vger.kernel.org, Sebastian Reichel , linux-pm@vger.kernel.org, Pablo Neira Ayuso , Florian Westphal , Phil Sutter , netfilter-devel@vger.kernel.org, coreteam@netfilter.org Subject: [patch 07/12] alarmtimer: Provide alarmtimer_start() References: <20260407083219.478203185@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Alarm timers utilize hrtimers for normal operation and only switch to the RTC on suspend. In order to catch already expired timers early and without going through a timer interrupt cycle, provide a new start function which internally uses hrtimer_start_range_ns_user(). If hrtimer_start_range_ns_user() detects an already expired timer, it does not queue it. In that case remove the timer from the alarm base as well. Return the status queued or not back to the caller to handle the early expiry. Signed-off-by: Thomas Gleixner Cc: John Stultz Cc: Stephen Boyd Acked-by: John Stultz (also with Peter's Tested-by: Calvin Owens --- include/linux/alarmtimer.h | 6 ++++++ kernel/time/alarmtimer.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) --- a/include/linux/alarmtimer.h +++ b/include/linux/alarmtimer.h @@ -42,8 +42,14 @@ struct alarm { void *data; }; =20 +static __always_inline ktime_t alarm_get_expires(struct alarm *alarm) +{ + return alarm->node.expires; +} + void alarm_init(struct alarm *alarm, enum alarmtimer_type type, void (*function)(struct alarm *, ktime_t)); +bool alarmtimer_start(struct alarm *alarm, ktime_t expires, bool relative); void alarm_start(struct alarm *alarm, ktime_t start); void alarm_start_relative(struct alarm *alarm, ktime_t start); void alarm_restart(struct alarm *alarm); --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -365,6 +365,34 @@ void alarm_start_relative(struct alarm * } EXPORT_SYMBOL_GPL(alarm_start_relative); =20 +/** + * alarmtimer_start - Sets an alarm to fire + * @alarm: Pointer to alarm to set + * @expires: Expiry time + * @relative: True if @expires is relative + * + * Returns: True if the alarm was queued. False if it already expired + */ +bool alarmtimer_start(struct alarm *alarm, ktime_t expires, bool relative) +{ + struct alarm_base *base =3D &alarm_bases[alarm->type]; + + if (relative) + expires =3D ktime_add_safe(expires, base->get_ktime()); + + trace_alarmtimer_start(alarm, base->get_ktime()); + + guard(spinlock_irqsave)(&base->lock); + alarm->node.expires =3D expires; + alarmtimer_enqueue(base, alarm); + if (!hrtimer_start_range_ns_user(&alarm->timer, expires, 0, HRTIMER_MODE_= ABS)) { + alarmtimer_dequeue(base, alarm); + return false; + } + return true; +} +EXPORT_SYMBOL_GPL(alarmtimer_start); + void alarm_restart(struct alarm *alarm) { struct alarm_base *base =3D &alarm_bases[alarm->type]; From nobody Mon Jun 15 00:09:28 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CCF8739A7E5; Tue, 7 Apr 2026 08:54:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552096; cv=none; b=PbSKRZtuU1oTUQx8s71NRqLueEc+13VnHwgIglxoF3FZeDk0ekNMSgnnXJxxlAk2E1zayKURrLP3M1dbrZCPWk0Q0Y4+gTFTCPHObWTxyK/MdIzDcbbD9vJPIgL44OV5dS3sPXKrrrfp0Sq3SzeeYhfHfwCqzin+IL5L0LbNEkI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552096; c=relaxed/simple; bh=SGqb2Nn/k7ufjxJEqlr54Yc4uqryYsKlaFtjHcAKMnA=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=gA3b/DZGfSqtSo+kudHxZdPJlMnIaq1S/TlQuQXeNpUTyLRg8h9ADreqKG9MbqdgiAH0ZPKzNHciIGnQmjoNDw8Hrbs0N73E20ihuXF3IsQOlwhhan9o64mVvLjnFk2ZJlpRHbzOUBOs9pnmsioYF89yU4TcoF8Nt3PYC4K0kEs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uXYP2mPt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uXYP2mPt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93E21C2BCB1; Tue, 7 Apr 2026 08:54:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775552096; bh=SGqb2Nn/k7ufjxJEqlr54Yc4uqryYsKlaFtjHcAKMnA=; h=Date:From:To:Cc:Subject:References:From; b=uXYP2mPtISsacH9fy9EJuFy4Trw0qj4yNykTHl4pjDjZfkkniz6W2Dzi+hEQJahkJ uWOGIWvrO1JzKx15louDi4it6yg1tzfakFRXyb+QrDw8w6o+nPHNXtux4Kp+3I1tw7 wJ4XkBnKJh76eUNHSKCDKV0Q4Eg0BvZcUkp6JSKh3DZp2YUSnWW1JGaA/vqrMkjHPp EDJcIaN8r0dYv4YQgqq8Qnt7l3a3o+Ldw1IVYvoMb02z9cKM0yOIweaF7LrfYR7QSW qBnkERgrjTO45WN+HI4XrB8Rh44jcY1s9O9VdRLTC2smXp5yXgKB1p7j+f4MEFsT90 0KIcOFpN6L1DA== Date: Tue, 07 Apr 2026 10:54:53 +0200 Message-ID: <20260407083248.035227538@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: John Stultz , Stephen Boyd , Calvin Owens , Peter Zijlstra , Anna-Maria Behnsen , Frederic Weisbecker , Ingo Molnar , Alexander Viro , Christian Brauner , Jan Kara , linux-fsdevel@vger.kernel.org, Sebastian Reichel , linux-pm@vger.kernel.org, Pablo Neira Ayuso , Florian Westphal , Phil Sutter , netfilter-devel@vger.kernel.org, coreteam@netfilter.org Subject: [patch 08/12] alarmtimer: Convert posix timer functions to alarmtimer_start() References: <20260407083219.478203185@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new alarmtimer_start() for arming and rearming posix interval timers and for clock_nanosleep() so that already expired timers do not go through the full timer interrupt cycle. Signed-off-by: Thomas Gleixner Cc: John Stultz Cc: Stephen Boyd Acked-by: John Stultz Tested-by: Calvin Owens --- kernel/time/alarmtimer.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -556,8 +556,7 @@ static bool alarm_timer_rearm(struct k_i 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; + return alarmtimer_start(alarm, alarm->node.expires, false); } =20 /** @@ -621,11 +620,16 @@ static bool alarm_timer_arm(struct k_iti =20 if (!absolute) expires =3D ktime_add_safe(expires, base->get_ktime()); - if (sigev_none) + + /* + * sigev_none needs to update the expires value and pretend + * that the timer is queued + */ + if (sigev_none) { alarm->node.expires =3D expires; - else - alarm_start(&timr->it.alarm.alarmtimer, expires); - return true; + return true; + } + return alarmtimer_start(&timr->it.alarm.alarmtimer, expires, false); } =20 /** @@ -732,7 +736,9 @@ static int alarmtimer_do_nsleep(struct a alarm->data =3D (void *)current; do { set_current_state(TASK_INTERRUPTIBLE); - alarm_start(alarm, absexp); + if (!alarmtimer_start(alarm, absexp, false)) + alarm->data =3D NULL; + if (likely(alarm->data)) schedule(); From nobody Mon Jun 15 00:09:28 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B62F039B49D; Tue, 7 Apr 2026 08:55:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552101; cv=none; b=Ev8lGfpFK+EkHPgWV7Bd6Ux0QEF29b7pem5ZqatwcH/ZeZHoFiPh6cl/JXBG6XZoXEwsFcDT2eB0kfM1AHyID6GXhNgRzItuU/7IVaHgyWjBoUPqn7lAE+YLoi8ywi5mTITw3tYGK56mVV+9dBJH8TnpbYum9+ub9LtJLop25rI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552101; c=relaxed/simple; bh=u8AI8RDvRZGzX0Utt+A54oYb3DpD5J4mYOgVVmHoy9M=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=Oqqryc4YLJkRpqoqJ6hqdUx5GN8FeqAaVn9xh1BMcq85PJ26E/7anEZ3P7m2CvvE4oW0cAeKHS0GdmxVNb+wdFuOukvgdePWLgKNh7y5zc09u2NbxS89AP5vfLoW3UUwxvin1bCpdvlE6paRqvTc3jHwEaEQ4ggdHYYGksYj8Ss= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rExZgWkb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rExZgWkb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C79D6C2BC9E; Tue, 7 Apr 2026 08:55:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775552101; bh=u8AI8RDvRZGzX0Utt+A54oYb3DpD5J4mYOgVVmHoy9M=; h=Date:From:To:Cc:Subject:References:From; b=rExZgWkbXR9kwaADPjSXATWJ03G725leNaOke/D/1liXugoBCuhBR7WJMwgUgTBj6 PgWILOByVuqvSS81yZjMVolMM2Q47l2SbQIcC9HMKtTst9co/63RhTsHoqV215xnr7 ZGmQQ/qEhtTdkY9AZYNGEqKsDwiEbmqAop2htdmPIWZTIJZa1myM1Eg51kCjLOSeZ4 OT2VzHlzS93usQN2/rpc4q2gGgXJpTKcb+aMSUtgUFSV1LE/W3tFAXu5TK9RgGCjvS lUESNI9jmO5HhlmPtFQBuEY+8B/hn++K+o/IhXr4bJ0O0f0yE3JZSBFeYmqj2wPAHT BXBugYBQPJ4kQ== Date: Tue, 07 Apr 2026 10:54:58 +0200 Message-ID: <20260407083248.102440187@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Alexander Viro , Christian Brauner , Jan Kara , Anna-Maria Behnsen , Frederic Weisbecker , linux-fsdevel@vger.kernel.org, Calvin Owens , Peter Zijlstra , Ingo Molnar , John Stultz , Stephen Boyd , Sebastian Reichel , linux-pm@vger.kernel.org, Pablo Neira Ayuso , Florian Westphal , Phil Sutter , netfilter-devel@vger.kernel.org, coreteam@netfilter.org Subject: [patch 09/12] fs/timerfd: Use the new alarm/hrtimer functions References: <20260407083219.478203185@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Like any other user controlled interface, timerfd based timers can be programmed with expiry times in the past or vary small intervals. Both hrtimer and alarmtimer provide new interfaces which return the queued state of the timer. If the timer was already expired, then let the callsite handle the timerfd context update so that the full round trip through the hrtimer interrupt is avoided. Signed-off-by: Thomas Gleixner Cc: Alexander Viro Cc: Christian Brauner Cc: Jan Kara Cc: Anna-Maria Behnsen Cc: Frederic Weisbecker Cc: Thomas Gleixner Cc: linux-fsdevel@vger.kernel.org Tested-by: Calvin Owens --- fs/timerfd.c | 115 +++++++++++++++++++++++++++++++++---------------------= ----- 1 file changed, 66 insertions(+), 49 deletions(-) --- a/fs/timerfd.c +++ b/fs/timerfd.c @@ -55,6 +55,15 @@ static inline bool isalarm(struct timerf ctx->clockid =3D=3D CLOCK_BOOTTIME_ALARM; } =20 +static void __timerfd_triggered(struct timerfd_ctx *ctx) +{ + lockdep_assert_held(&ctx->wqh.lock); + + ctx->expired =3D 1; + ctx->ticks++; + wake_up_locked_poll(&ctx->wqh, EPOLLIN); +} + /* * This gets called when the timer event triggers. We set the "expired" * flag, but we do not re-arm the timer (in case it's necessary, @@ -62,13 +71,8 @@ static inline bool isalarm(struct timerf */ static void timerfd_triggered(struct timerfd_ctx *ctx) { - unsigned long flags; - - spin_lock_irqsave(&ctx->wqh.lock, flags); - ctx->expired =3D 1; - ctx->ticks++; - wake_up_locked_poll(&ctx->wqh, EPOLLIN); - spin_unlock_irqrestore(&ctx->wqh.lock, flags); + guard(spinlock_irqsave)(&ctx->wqh.lock); + __timerfd_triggered(ctx); } =20 static enum hrtimer_restart timerfd_tmrproc(struct hrtimer *htmr) @@ -184,15 +188,52 @@ static ktime_t timerfd_get_remaining(str return remaining < 0 ? 0: remaining; } =20 +static void timerfd_alarm_start(struct timerfd_ctx *ctx, ktime_t exp, bool= relative) +{ + /* Start the timer. If it's expired already, handle the callback. */ + if (!alarmtimer_start(&ctx->t.alarm, exp, relative)) + __timerfd_triggered(ctx); +} + +static u64 timerfd_alarm_restart(struct timerfd_ctx *ctx) +{ + u64 ticks =3D alarm_forward_now(&ctx->t.alarm, ctx->tintv) - 1; + + timerfd_alarm_start(ctx, alarm_get_expires(&ctx->t.alarm), false); + return ticks; +} + +static void timerfd_hrtimer_start(struct timerfd_ctx *ctx, ktime_t exp, + const enum hrtimer_mode mode) +{ + /* Start the timer. If it's expired already, handle the callback. */ + if (!hrtimer_start_range_ns_user(&ctx->t.tmr, exp, 0, mode)) + __timerfd_triggered(ctx); +} + +static u64 timerfd_hrtimer_restart(struct timerfd_ctx *ctx) +{ + u64 ticks =3D hrtimer_forward_now(&ctx->t.tmr, ctx->tintv) - 1; + + timerfd_hrtimer_start(ctx, hrtimer_get_expires(&ctx->t.tmr), HRTIMER_MODE= _ABS); + return ticks; +} + +static u64 timerfd_restart(struct timerfd_ctx *ctx) +{ + if (isalarm(ctx)) + return timerfd_alarm_restart(ctx); + return timerfd_hrtimer_restart(ctx); +} + static int timerfd_setup(struct timerfd_ctx *ctx, int flags, const struct itimerspec64 *ktmr) { + int clockid =3D ctx->clockid; enum hrtimer_mode htmode; ktime_t texp; - int clockid =3D ctx->clockid; =20 - htmode =3D (flags & TFD_TIMER_ABSTIME) ? - HRTIMER_MODE_ABS: HRTIMER_MODE_REL; + htmode =3D (flags & TFD_TIMER_ABSTIME) ? HRTIMER_MODE_ABS: HRTIMER_MODE_R= EL; =20 texp =3D timespec64_to_ktime(ktmr->it_value); ctx->expired =3D 0; @@ -206,20 +247,15 @@ static int timerfd_setup(struct timerfd_ timerfd_alarmproc); } else { hrtimer_setup(&ctx->t.tmr, timerfd_tmrproc, clockid, htmode); - hrtimer_set_expires(&ctx->t.tmr, texp); } =20 if (texp !=3D 0) { if (flags & TFD_TIMER_ABSTIME) texp =3D timens_ktime_to_host(clockid, texp); - if (isalarm(ctx)) { - if (flags & TFD_TIMER_ABSTIME) - alarm_start(&ctx->t.alarm, texp); - else - alarm_start_relative(&ctx->t.alarm, texp); - } else { - hrtimer_start(&ctx->t.tmr, texp, htmode); - } + if (isalarm(ctx)) + timerfd_alarm_start(ctx, texp, !(flags & TFD_TIMER_ABSTIME)); + else + timerfd_hrtimer_start(ctx, texp, htmode); =20 if (timerfd_canceled(ctx)) return -ECANCELED; @@ -287,27 +323,19 @@ static ssize_t timerfd_read_iter(struct } =20 if (ctx->ticks) { - ticks =3D ctx->ticks; + unsigned int expired =3D ctx->expired; =20 - if (ctx->expired && ctx->tintv) { - /* - * If tintv !=3D 0, this is a periodic timer that - * needs to be re-armed. We avoid doing it in the timer - * callback to avoid DoS attacks specifying a very - * short timer period. - */ - if (isalarm(ctx)) { - ticks +=3D alarm_forward_now( - &ctx->t.alarm, ctx->tintv) - 1; - alarm_restart(&ctx->t.alarm); - } else { - ticks +=3D hrtimer_forward_now(&ctx->t.tmr, - ctx->tintv) - 1; - hrtimer_restart(&ctx->t.tmr); - } - } + ticks =3D ctx->ticks; ctx->expired =3D 0; ctx->ticks =3D 0; + + /* + * If tintv !=3D 0, this is a periodic timer that needs to be + * re-armed. We avoid doing it in the timer callback to avoid + * DoS attacks specifying a very short timer period. + */ + if (expired && ctx->tintv) + ticks +=3D timerfd_restart(ctx); } spin_unlock_irq(&ctx->wqh.lock); if (ticks) { @@ -526,18 +554,7 @@ static int do_timerfd_gettime(int ufd, s spin_lock_irq(&ctx->wqh.lock); if (ctx->expired && ctx->tintv) { ctx->expired =3D 0; - - if (isalarm(ctx)) { - ctx->ticks +=3D - alarm_forward_now( - &ctx->t.alarm, ctx->tintv) - 1; - alarm_restart(&ctx->t.alarm); - } else { - ctx->ticks +=3D - hrtimer_forward_now(&ctx->t.tmr, ctx->tintv) - - 1; - hrtimer_restart(&ctx->t.tmr); - } + ctx->ticks +=3D timerfd_restart(ctx); } t->it_value =3D ktime_to_timespec64(timerfd_get_remaining(ctx)); t->it_interval =3D ktime_to_timespec64(ctx->tintv); From nobody Mon Jun 15 00:09:28 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9E19739B947; Tue, 7 Apr 2026 08:55:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552106; cv=none; b=F6qMZBMMRw5ErCuaIFu4l24VieIFL25GhJQh4pWyygNEqIdI4KvnG30Wk9x9Cs/MkfjMXKdhMxlZVpep0Ta4+sht6vF+q2hQnte40KdbCQd00sXwlsbpYVJjl+sBmpb/Xpl5m/vMSBPYX+sjnNokh3K6SgLSuxCt8/Tg08FGpSU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552106; c=relaxed/simple; bh=a2rb0C/2jOI+xBjqnRW7gBLUVgARQvjzSs1wbr8yRxc=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=IvowmgOnxzOLrSvL7bDBzxzn1DP2waSndZfxFV+e+S/JCKgIbTV3QNsLVpgDEMuZrPEs/ng/0N3QZQ3c2F1xsyozYZ6Ppgzu4nP1c5iuWneMkrBgAOU4oGYMzrnTZ9t8FA62L0rd/xPQrF355V9qzxsvxRpFgyHnrWajatyPJds= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iUOBigyQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iUOBigyQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1A69C116C6; Tue, 7 Apr 2026 08:55:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775552106; bh=a2rb0C/2jOI+xBjqnRW7gBLUVgARQvjzSs1wbr8yRxc=; h=Date:From:To:Cc:Subject:References:From; b=iUOBigyQ2l3/0OaDrCtcIYXwmAlP2XLebtvC1T3dDB6DEGoSMg0Bgrnx4rqezikPu G0jASXSRQUzQ0raUZ3Q6KnOvm3ehxa4HfZtrubpKaT9sQrPexkRjUiGEzV2JzklPR1 EhNxBFLpY+9mq9TJbT6RZCeklBaUI3TroyVx4kH45jXAvAbm1T2enveCiMR/2+loVG GLtiYinuisRJFw5G/1io8hs13r5l7POWsXfDTCdecK5+HjmZsWG+wcy2wzJbv5xbhe OmxHfPwBzR9q6KJS0wuZrMicXJTbwfN5qXypB9yq9c4hNcYisfFX9uCGyIyLU30XZp W11OVgCB13J2A== Date: Tue, 07 Apr 2026 10:55:03 +0200 Message-ID: <20260407083248.169005310@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Sebastian Reichel , linux-pm@vger.kernel.org, Calvin Owens , Peter Zijlstra , Anna-Maria Behnsen , Frederic Weisbecker , Ingo Molnar , John Stultz , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , linux-fsdevel@vger.kernel.org, Pablo Neira Ayuso , Florian Westphal , Phil Sutter , netfilter-devel@vger.kernel.org, coreteam@netfilter.org Subject: [patch 10/12] power: supply: charger-manager: Switch to alarmtimer_start() References: <20260407083219.478203185@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The existing alarm_start() interface is replaced with the new alarmtimer_start() mechanism, which does not longer queue an already expired timer and returns the state. Adjust the code to utilize this. No functional change intended. Signed-off-by: Thomas Gleixner Cc: Sebastian Reichel Cc: linux-pm@vger.kernel.org Tested-by: Calvin Owens --- drivers/power/supply/charger-manager.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) --- a/drivers/power/supply/charger-manager.c +++ b/drivers/power/supply/charger-manager.c @@ -881,7 +881,7 @@ static bool cm_setup_timer(void) mutex_unlock(&cm_list_mtx); =20 if (timer_req && cm_timer) { - ktime_t now, add; + ktime_t exp; =20 /* * Set alarm with the polling interval (wakeup_ms) @@ -893,14 +893,16 @@ static bool cm_setup_timer(void) =20 pr_info("Charger Manager wakeup timer: %u ms\n", wakeup_ms); =20 - now =3D ktime_get_boottime(); - add =3D ktime_set(wakeup_ms / MSEC_PER_SEC, + exp =3D ktime_set(wakeup_ms / MSEC_PER_SEC, (wakeup_ms % MSEC_PER_SEC) * NSEC_PER_MSEC); - alarm_start(cm_timer, ktime_add(now, add)); =20 cm_suspend_duration_ms =3D wakeup_ms; =20 - return true; + /* + * The timer should always be queued as the timeout is at least + * two seconds out. Handle it correctly nevertheless. + */ + return alarmtimer_start(cm_timer, exp, true); } return false; } From nobody Mon Jun 15 00:09:28 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A4F553A1D1C; Tue, 7 Apr 2026 08:55:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552111; cv=none; b=Gdadrk4JjBmLDAefq0kdHIjxddzn2glBjnL5jPmp1PTQLAKs0DCFpF0KIanMWVM8hVkZ+gsUKWaq0NpGDKKKhk/uL4jc7IeceEjAjf5B4fdFT2yY4OcvOtMrQpXOOWOMSHJKSjrsFCU2qY7sbpf3smqIh+zc901+EJFHWU1NpAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552111; c=relaxed/simple; bh=UWMCyKMLfyWDIafgwUqZJttuFVA66S79Y0i2Q6zCV8M=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=touDF2OcvCJmhg6zbEjVuDBHiv6TC22vNQ/YUZ6kCTdEWWGErS+JDNkQHANfEdxSMiRnZdhwfRmckwoA40RcTk5jHhgg/zq6SpfLN0BekH+L6BQdE8w73xcB9exE2S+ajTdYM8NwMdoF0+xFUkKARHJFLwSplNYFardKqc+GetU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MnRZgvEh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MnRZgvEh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CD27C116C6; Tue, 7 Apr 2026 08:55:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775552111; bh=UWMCyKMLfyWDIafgwUqZJttuFVA66S79Y0i2Q6zCV8M=; h=Date:From:To:Cc:Subject:References:From; b=MnRZgvEh1K64MnDUiej8C6cmHlWfJkZ1Eu1rQlC7tXO1zvRibsLF+aem+XObc8Xmd Tl5p7LFvyPPgk6KKR0zXEGtHrS7lutk0yPYwc89EHFt34lW4piFp/RpDRANLJC7q4d N0d9V7eR0ao4ZvNmSWplIzPU9xlojU+cB1o0io4uSKL69mnndeOllpApjvNfuzmNhc uXa93Fc1kXL4Myf0iTPzoCcuRJi2L0wu/laCvqcgVPoideK9mmH+ogTanmz+ovP1mA /JZqsFNoKIarAT939bBbE9Z5CpDtAVfej49qGk3KjjO8DQh8poDxKkChXe6KjeFTuT 84RuxSWAE2LIA== Date: Tue, 07 Apr 2026 10:55:08 +0200 Message-ID: <20260407083248.236423400@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Pablo Neira Ayuso , Florian Westphal , Phil Sutter , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, Calvin Owens , Peter Zijlstra , Anna-Maria Behnsen , Frederic Weisbecker , Ingo Molnar , John Stultz , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , linux-fsdevel@vger.kernel.org, Sebastian Reichel , linux-pm@vger.kernel.org Subject: [patch 11/12] netfilter: xt_IDLETIMER: Switch to alarmtimer_start() References: <20260407083219.478203185@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The existing alarm-start() interface is replaced with the new alarmtimer_start() mechanism, which does not longer queue an already expired timer and returns the state. Adjust the code to utilize this so it schedules the work in the case that the timer was already expired. Unlikely to happen as the timeout is at least a second, but not impossible especially with virtualization. No functional change intended Signed-off-by: Thomas Gleixner Cc: Pablo Neira Ayuso Cc: Florian Westphal Cc: Phil Sutter Cc: netfilter-devel@vger.kernel.org Cc: coreteam@netfilter.org Tested-by: Calvin Owens --- net/netfilter/xt_IDLETIMER.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) --- a/net/netfilter/xt_IDLETIMER.c +++ b/net/netfilter/xt_IDLETIMER.c @@ -115,6 +115,21 @@ static void idletimer_tg_alarmproc(struc schedule_work(&timer->work); } =20 +static void idletimer_start_alarm_ktime(struct idletimer_tg *timer, ktime_= t timeout) +{ + /* + * The timer should always be queued as @tout it should be least one + * second, but handle it correctly in any case. Virt will manage! + */ + if (!alarmtimer_start(&timer->alarm, timeout, true)) + schedule_work(&timer->work); +} + +static void idletimer_start_alarm_sec(struct idletimer_tg *timer, unsigned= int seconds) +{ + idletimer_start_alarm_ktime(timer, ktime_set(seconds, 0)); +} + static int idletimer_check_sysfs_name(const char *name, unsigned int size) { int ret; @@ -220,12 +235,10 @@ static int idletimer_tg_create_v1(struct INIT_WORK(&info->timer->work, idletimer_tg_work); =20 if (info->timer->timer_type & XT_IDLETIMER_ALARM) { - ktime_t tout; alarm_init(&info->timer->alarm, ALARM_BOOTTIME, idletimer_tg_alarmproc); info->timer->alarm.data =3D info->timer; - tout =3D ktime_set(info->timeout, 0); - alarm_start_relative(&info->timer->alarm, tout); + idletimer_start_alarm_sec(info->timer, info->timeout); } else { timer_setup(&info->timer->timer, idletimer_tg_expired, 0); mod_timer(&info->timer->timer, @@ -271,8 +284,7 @@ static unsigned int idletimer_tg_target_ info->label, info->timeout); =20 if (info->timer->timer_type & XT_IDLETIMER_ALARM) { - ktime_t tout =3D ktime_set(info->timeout, 0); - alarm_start_relative(&info->timer->alarm, tout); + idletimer_start_alarm_sec(info->timer, info->timeout); } else { mod_timer(&info->timer->timer, secs_to_jiffies(info->timeout) + jiffies); @@ -384,7 +396,7 @@ static int idletimer_tg_checkentry_v1(co if (ktimespec.tv_sec > 0) { pr_debug("time_expiry_remaining %lld\n", ktimespec.tv_sec); - alarm_start_relative(&info->timer->alarm, tout); + idletimer_start_alarm_ktime(info->timer, tout); } } else { mod_timer(&info->timer->timer, From nobody Mon Jun 15 00:09:28 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 559C713959D; Tue, 7 Apr 2026 08:55:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552116; cv=none; b=RHGqdxxtSeyrH6Wt7jYtbl1I7TBqUQR2YT9c+f6qkG8Vr73w/G9LRTDWQx1wtjOORMtiXqott0RpqKkBbsBWBYfZGyssb9iOElpdoXN/mUVz/Dk8a54w39fJ1HGrtIu713ndFQMl8YvTYOtfLjqmoNrdXIVAodx5D/3ZAtokgpE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775552116; c=relaxed/simple; bh=9FM/2kY5c9jnURSRNKlLV3ziUYO+2vbuP2OQgTOa3p4=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=mHxc+WOjDo3ySJMF8HwBK4+zcosqKTjl6jTA5PdfsKYyZ1E2D20yNC3QNYMVEOeuh5OTxNnV5cARuclQR7fkp9ed7ao/d8JBZUBRsK7LHbW+0BLNxzfy+vxfHFo9Qp5zzRMuxyQ8dmJHZKpURHKu0nlRz1iHkLdgXnRvhafZ2Pw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bM76w13/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bM76w13/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 716C0C2BCAF; Tue, 7 Apr 2026 08:55:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775552116; bh=9FM/2kY5c9jnURSRNKlLV3ziUYO+2vbuP2OQgTOa3p4=; h=Date:From:To:Cc:Subject:References:From; b=bM76w13/WCTo4sBXQSs0QFxAyU9HZUW0hjydi5Lvptkm1KE+Sei6sq1QJ6jOhIsQo Z7m0RpHmMZQIl2ERxgtgfoOlyHHbY1zjeIkk1fn3hsmfnOXk0b1p/DW0TenYIL00ge uCVH3/1CvL7SemR+jKutq6EMZ1COpw31d6niE/EvkrfkAjLnOYc2rkBGzxSzLtoVG8 O4D9vg7xMTrubrBNAbcqbEzfugmUf2Taf5iUYfZeX+5qsmBfQpVK1ppByqDuGATUGO G3c9XKSXA5jWcLCPqWRlO+5Fjm/yXmB6MD3P92c07CiG3w4m+HT/T30EDEeaDhsD83 SvmtIPVDrLH1Q== Date: Tue, 07 Apr 2026 10:55:13 +0200 Message-ID: <20260407083248.303293327@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: John Stultz , Stephen Boyd , Calvin Owens , Peter Zijlstra , Anna-Maria Behnsen , Frederic Weisbecker , Ingo Molnar , Alexander Viro , Christian Brauner , Jan Kara , linux-fsdevel@vger.kernel.org, Sebastian Reichel , linux-pm@vger.kernel.org, Pablo Neira Ayuso , Florian Westphal , Phil Sutter , netfilter-devel@vger.kernel.org, coreteam@netfilter.org Subject: [patch 12/12] alarmtimer: Remove unused interfaces References: <20260407083219.478203185@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" All alarmtimer users are converted to alarmtimer_start(). Remove the now unused interfaces. Signed-off-by: Thomas Gleixner Cc: John Stultz Cc: Stephen Boyd Acked-by: John Stultz Tested-by: Calvin Owens --- include/linux/alarmtimer.h | 3 --- kernel/time/alarmtimer.c | 44 ----------------------------------------= ---- 2 files changed, 47 deletions(-) --- a/include/linux/alarmtimer.h +++ b/include/linux/alarmtimer.h @@ -50,9 +50,6 @@ static __always_inline ktime_t alarm_get void alarm_init(struct alarm *alarm, enum alarmtimer_type type, void (*function)(struct alarm *, ktime_t)); bool alarmtimer_start(struct alarm *alarm, ktime_t expires, bool relative); -void alarm_start(struct alarm *alarm, ktime_t start); -void alarm_start_relative(struct alarm *alarm, ktime_t start); -void alarm_restart(struct alarm *alarm); int alarm_try_to_cancel(struct alarm *alarm); int alarm_cancel(struct alarm *alarm); =20 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -333,39 +333,6 @@ void alarm_init(struct alarm *alarm, enu EXPORT_SYMBOL_GPL(alarm_init); =20 /** - * alarm_start - Sets an absolute alarm to fire - * @alarm: ptr to alarm to set - * @start: time to run the alarm - */ -void alarm_start(struct alarm *alarm, ktime_t start) -{ - struct alarm_base *base =3D &alarm_bases[alarm->type]; - - scoped_guard(spinlock_irqsave, &base->lock) { - alarm->node.expires =3D start; - alarmtimer_enqueue(base, alarm); - hrtimer_start(&alarm->timer, alarm->node.expires, HRTIMER_MODE_ABS); - } - - trace_alarmtimer_start(alarm, base->get_ktime()); -} -EXPORT_SYMBOL_GPL(alarm_start); - -/** - * alarm_start_relative - Sets a relative alarm to fire - * @alarm: ptr to alarm to set - * @start: time relative to now to run the alarm - */ -void alarm_start_relative(struct alarm *alarm, ktime_t start) -{ - struct alarm_base *base =3D &alarm_bases[alarm->type]; - - start =3D ktime_add_safe(start, base->get_ktime()); - alarm_start(alarm, start); -} -EXPORT_SYMBOL_GPL(alarm_start_relative); - -/** * alarmtimer_start - Sets an alarm to fire * @alarm: Pointer to alarm to set * @expires: Expiry time @@ -393,17 +360,6 @@ bool alarmtimer_start(struct alarm *alar } EXPORT_SYMBOL_GPL(alarmtimer_start); =20 -void alarm_restart(struct alarm *alarm) -{ - struct alarm_base *base =3D &alarm_bases[alarm->type]; - - guard(spinlock_irqsave)(&base->lock); - hrtimer_set_expires(&alarm->timer, alarm->node.expires); - hrtimer_restart(&alarm->timer); - alarmtimer_enqueue(base, alarm); -} -EXPORT_SYMBOL_GPL(alarm_restart); - /** * alarm_try_to_cancel - Tries to cancel an alarm timer * @alarm: ptr to alarm to be canceled