Re: [PATCH 4.19 032/114] timer: Read jiffies once when forwarding base clk

From: Pavel Machek
Date: Sun Oct 13 2019 - 11:48:37 EST


On Thu 2019-10-10 10:35:39, Greg Kroah-Hartman wrote:
> From: Li RongQing <lirongqing@xxxxxxxxx>
>
> commit e430d802d6a3aaf61bd3ed03d9404888a29b9bf9 upstream.
>
> The reason is that the code in collect_expired_timers() uses jiffies
> unprotected:
>
> if (next_event > jiffies)
> base->clk = jiffies;
>
> As the compiler is allowed to reload the value base->clk can advance
> between the check and the store and in the worst case advance farther than
> next event. That causes the timer expiry to be delayed until the wheel
> pointer wraps around.
>
> Convert the code to use READ_ONCE()

Does it really need to use READ_ONCE? "jiffies" is already volatile,
READ_ONCE just adds another volatile...

Best regards,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Attachment: signature.asc
Description: Digital signature