Re: [PATCH v2 3/3] kernel/watch_queue: Remove wqueue->defunct and use pipe for clear check

From: Eric Biggers
Date: Fri Aug 05 2022 - 03:24:38 EST


On Thu, Aug 04, 2022 at 08:11:52PM +0530, Siddh Raman Pant wrote:
> static inline bool lock_wqueue(struct watch_queue *wqueue)
> {
> spin_lock_bh(&wqueue->lock);
> - if (unlikely(wqueue->defunct)) {
> + if (unlikely(!READ_ONCE(wqueue->pipe))) {
> spin_unlock_bh(&wqueue->lock);
> return false;
> }

Why is the READ_ONCE() needed? Doesn't wqueue->lock protect wqueue->pipe?

> + /* This pipe will get freed by the caller free_pipe_info().
> + * Removing this reference also prevents new notifications.
> + */

This isn't the correct block comment format; it should look like:

/*
* This pipe will get freed by the caller free_pipe_info().
* Removing this reference also prevents new notifications.
*/

- Eric