Messages in this thread Patch in this message | | | From | Yury Norov <> | Subject | [PATCH 03/34] watch_queue: use atomic find_bit() in post_one_notification() | Date | Sat, 18 Nov 2023 07:50:34 -0800 |
| |
post_one_notification() searches for a set bit in wqueue->notes_bitmap, and after some housekeeping work clears it, firing a BUG() if someone else cleared the bit in-between.
We can allocate a bit atomically with the atomic find_and_clear_bit(), and remove the BUG() possibility entirely.
Signed-off-by: Yury Norov <yury.norov@gmail.com> --- kernel/watch_queue.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c index 778b4056700f..07edd4a2b463 100644 --- a/kernel/watch_queue.c +++ b/kernel/watch_queue.c @@ -112,7 +112,7 @@ static bool post_one_notification(struct watch_queue *wqueue, if (pipe_full(head, tail, pipe->ring_size)) goto lost; - note = find_first_bit(wqueue->notes_bitmap, wqueue->nr_notes); + note = find_and_clear_bit(wqueue->notes_bitmap, wqueue->nr_notes); if (note >= wqueue->nr_notes) goto lost; @@ -133,10 +133,6 @@ static bool post_one_notification(struct watch_queue *wqueue, buf->flags = PIPE_BUF_FLAG_WHOLE; smp_store_release(&pipe->head, head + 1); /* vs pipe_read() */ - if (!test_and_clear_bit(note, wqueue->notes_bitmap)) { - spin_unlock_irq(&pipe->rd_wait.lock); - BUG(); - } wake_up_interruptible_sync_poll_locked(&pipe->rd_wait, EPOLLIN | EPOLLRDNORM); done = true; -- 2.39.2
| |