Re: [PATCH] timers/migration: Fix ignored event due to missing CPU update

From: Anna-Maria Behnsen
Date: Tue Apr 02 2024 - 05:52:35 EST


Frederic Weisbecker <frederic@xxxxxxxxxx> writes:

> When a group event is updated with its expiry unchanged but a different
> CPU, that target change may go unnoticed and the event may be propagated
> up with a stale CPU value. The following depicts a scenario that has
> been actually observed:

urgh...

>
> Signed-off-by: Frederic Weisbecker <frederic@xxxxxxxxxx>
> ---
> kernel/time/timer_migration.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/time/timer_migration.c b/kernel/time/timer_migration.c
> index c63a0afdcebe..90786bb9a607 100644
> --- a/kernel/time/timer_migration.c
> +++ b/kernel/time/timer_migration.c
> @@ -762,8 +762,11 @@ bool tmigr_update_events(struct tmigr_group *group, struct tmigr_group *child,
> * queue when the expiry time changed only or when it could be ignored.
> */
> if (timerqueue_node_queued(&evt->nextevt)) {
> - if ((evt->nextevt.expires == nextexp) && !evt->ignore)
> + if ((evt->nextevt.expires == nextexp) && !evt->ignore) {
> + if (evt->cpu != first_childevt->cpu)
> + evt->cpu = first_childevt->cpu;

Why not just unconditionally overwriting the evt->cpu value here?

> goto check_toplvl;
> + }
>
> if (!timerqueue_del(&group->events, &evt->nextevt))
> WRITE_ONCE(group->next_expiry, KTIME_MAX);

Thanks,

Anna-Maria