From: Mikulas Patocka <mpato...@redhat.com>

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 <mpato...@redhat.com>
Signed-off-by: Mike Snitzer <snit...@kernel.org>
---
 drivers/md/dm-bufio.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
index 929685011e02..b638ddd161b4 100644
--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -1669,7 +1669,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)
-- 
2.40.0

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel

Reply via email to