Re: [patch 16/45] posix-timers: Consolidate timer setup

From: Frederic Weisbecker
Date: Mon Jul 03 2023 - 17:12:43 EST


Le Tue, Jun 06, 2023 at 04:37:44PM +0200, Thomas Gleixner a écrit :
> hrtimer based and CPU timers have their own way to install the new interval
> and to reset overrun and signal handling related data.
>
> Create a helper function and do the same operation for all variants.
>
> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> ---
> kernel/time/posix-cpu-timers.c | 15 +--------------
> kernel/time/posix-timers.c | 23 +++++++++++++++++------
> kernel/time/posix-timers.h | 1 +
> 3 files changed, 19 insertions(+), 20 deletions(-)
>
> --- a/kernel/time/posix-cpu-timers.c
> +++ b/kernel/time/posix-cpu-timers.c
> @@ -709,21 +709,8 @@ static int posix_cpu_timer_set(struct k_
> trigger_base_recalc_expires(timer, p);
>
> unlock_task_sighand(p, &flags);
> - /*
> - * Install the new reload setting, and
> - * set up the signal and overrun bookkeeping.
> - */
> - timer->it_interval = timespec64_to_ktime(new->it_interval);
>
> - /*
> - * This acts as a modification timestamp for the timer,
> - * so any automatic reload attempt will punt on seeing
> - * that we have reset the timer manually.
> - */
> - timer->it_requeue_pending = (timer->it_requeue_pending + 2) &
> - ~REQUEUE_PENDING;
> - timer->it_overrun_last = 0;
> - timer->it_overrun = -1;
> + posix_timer_set_common(timer, new);

So before this patch if a posix cpu timer is set with:

.it_value = 0,
.it_interval = 5

a further retrieval would return the same. But after this patch
it will return:

.it_value = 0,
.it_interval = 0

That's an ABI change, not sure if it matters though...