Re: [patch 09/12] fs/timerfd: Use the new alarm/hrtimer functions
From: Thomas Gleixner
Date: Tue Apr 07 2026 - 07:42:13 EST
On Tue, Apr 07 2026 at 12:09, Peter Zijlstra wrote:
>> - ctx->ticks +=
>> - hrtimer_forward_now(&ctx->t.tmr, ctx->tintv)
>> - - 1;
>
> (argh!)
>
>> - hrtimer_restart(&ctx->t.tmr);
>> - }
>> + ctx->ticks += timerfd_restart(ctx);
>> }
>> t->it_value = ktime_to_timespec64(timerfd_get_remaining(ctx));
>> t->it_interval = ktime_to_timespec64(ctx->tintv);
>
> What's with the -1 thing?
Magic :)
Reading the timerfd returns the number of expired ticks since the last
read or since the timer was armed.
The expiry callback increments ticks by one, hrtimer_forward_now()
returns the number of expired ticks relative to the previous expiry
time. So it would double account that.
Not pretty, but we need to increment ticks in the callback because of
non-interval timers as for those we don't invoke the forwarding.
Thanks,
tglx