Re: [PATCH v2 1/5] timer_migration: Do not rely always on group->parent
From: Frederic Weisbecker
Date: Mon Jun 24 2024 - 16:29:53 EST
Le Mon, Jun 24, 2024 at 04:53:53PM +0200, Anna-Maria Behnsen a écrit :
> When reading group->parent without holding the group lock it is racy
> against CPUs coming online the first time and thereby creating another
> level of the hierarchy. This is not a problem when this value is read once
> to decide whether to abort a propagation or not. The worst outcome is an
> unnecessary/early CPU wake up. But it is racy when reading it several times
> during a single 'action' (like activation, deactivation, checking for
> remote timer expiry,...) and relying on the consitency of this value
> without holding the lock. This happens at the moment e.g. in
> tmigr_inactive_up() which is also calling tmigr_udpate_events(). Code relys
> on group->parent not to change during this 'action'.
>
> Update parent struct member description to explain the above only
> once. Remove parent pointer checks when they are not mandatory (like update
> of data->childmask). Remove a warning, which would be nice but the trigger
> of this warning is not reliable and add expand the data structure member
> description instead. Expand a comment, why it is safe to rely on parent
> pointer here (inside hierarchy update).
>
> Fixes: 7ee988770326 ("timers: Implement the hierarchical pull model")
> Reported-by: Borislav Petkov <bp@xxxxxxxxx>
> Signed-off-by: Anna-Maria Behnsen <anna-maria@xxxxxxxxxxxxx>
Reviewed-by: Frederic Weisbecker <frederic@xxxxxxxxxx>