dm bufio: use waitqueue_active in __free_buffer_wake
authorMikulas Patocka <mpatocka@redhat.com>
Thu, 23 Mar 2023 15:25:49 +0000 (11:25 -0400)
committerMike Snitzer <snitzer@kernel.org>
Thu, 30 Mar 2023 19:57:50 +0000 (15:57 -0400)
Save one spinlock by using waitqueue_active. We hold the bufio lock at
this place, so no one can add entries to the waitqueue at this point.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
drivers/md/dm-bufio.c

index e545974..cca43ed 100644 (file)
@@ -1665,7 +1665,12 @@ static void __free_buffer_wake(struct dm_buffer *b)
                c->need_reserved_buffers--;
        }
 
-       wake_up(&c->free_buffer_wait);
+       /*
+        * We hold the bufio lock here, so no one can add entries to the
+        * wait queue anyway.
+        */
+       if (unlikely(waitqueue_active(&c->free_buffer_wait)))
+               wake_up(&c->free_buffer_wait);
 }
 
 static enum evict_result cleaned(struct dm_buffer *b, void *context)