Re: [patch 02/12] hrtimer: Provide hrtimer_start_range_ns_user()

Peter Zijlstra
2026-04-07T09:54:34Z

On Tue, Apr 07, 2026 at 10:54:22AM +0200, Thomas Gleixner wrote:

> +enum {
> + HRTIMER_REPROGRAM_NONE,
> + HRTIMER_REPROGRAM,
> + HRTIMER_REPROGRAM_FORCE,
> +};

> +static int hrtimer_start_range_ns_common(struct hrtimer *timer, ktime_t tim,
> + u64 delta_ns, const enum hrtimer_mode mode,
> + struct hrtimer_clock_base *base)

> @@ -1315,25 +1337,110 @@ void hrtimer_start_range_ns(struct hrtim
> struct hrtimer_clock_base *base;
> unsigned long flags;
>
> - /*
> - * Check whether the HRTIMER_MODE_SOFT bit and hrtimer.is_soft
> - * match on CONFIG_PREEMPT_RT = 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 = lock_hrtimer_base(timer, &flags);
>
> - 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;
> + }
>
> unlock_hrtimer_base(timer, &flags);
> }

Something is going to figure out that hrtimer_start_range_ns_common() is
really returning that enum and then complain you don't handle NONE :-)

Anyway, to me it would make sense to instead pass that value to
hrtimer_reprogram() as the second argument. But this works I suppose.