From: Filipe Manana Date: Mon, 2 Jun 2025 12:46:23 +0000 (+0100) Subject: btrfs: add comment for optimization in free_extent_buffer() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2697b6159744e5afae0f7715da9f830ba6f9e45a;p=users%2Fjedix%2Flinux-maple.git btrfs: add comment for optimization in free_extent_buffer() There's this special atomic compare and exchange logic which serves to avoid locking the extent buffers refs_lock spinlock and therefore reduce lock contention, so add a comment to make it more obvious. Reviewed-by: Boris Burkov Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 21d2cb7f538e..5e8dd9a99e58 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3493,6 +3493,7 @@ void free_extent_buffer(struct extent_buffer *eb) break; } + /* Optimization to avoid locking eb->refs_lock. */ if (atomic_try_cmpxchg(&eb->refs, &refs, refs - 1)) return; }