Re: [PATCH 4.19 089/114] hrtimer: Annotate lockless access to timer->state

Pavel Machek
2020-01-03T19:07:15Z

[-- Attachment #1: Type: text/plain, Size: 1116 bytes --]

Hi!

> From: Eric Dumazet <edumazet@google.com>
>
> commit 56144737e67329c9aaed15f942d46a6302e2e3d8 upstream.
>
> syzbot reported various data-race caused by hrtimer_is_queued() reading
> timer->state. A READ_ONCE() is required there to silence the warning.
>
> Also add the corresponding WRITE_ONCE() when timer->state is set.
>
> In remove_hrtimer() the hrtimer_is_queued() helper is open coded to avoid
> loading timer->state twice.

Is there a reason why READ_ONCE is not neccessary in remove_hrtimer?

Should there be comment there explaining it?

Best regards,
Pavel

> @@ -1002,8 +1004,9 @@ static void __remove_hrtimer(struct hrti
> static inline int
> remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base, bool restart)
> {
> - if (hrtimer_is_queued(timer)) {
> - u8 state = timer->state;
> + u8 state = timer->state;
> +
> + if (state & HRTIMER_STATE_ENQUEUED) {
> int reprogram;
>
> /*
>

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]