Re: [PATCH 5/9] bcache: reduce gc latency by processing less nodes and sleep less time

Robert Pang <[email protected]> Thu, 16 Jul 2026 17:50:39 -0700
Newsgroups org.kernel.vger.linux-bcache
Message-ID <[email protected]>
Hi Coly,

I was reviewing this patch again and noticed that btree_gc_min_nodes() reads the
atomic counter 'search_inflight'. This counter is incremented and decremented by
clients issuing front-side I/O. In this scenario, should we add a memory barrier
(such as `smp_mb__before_atomic`) prior to `atomic_read()`? 

My concern is that if btree_gc_min_nodes() is inlined in the caller
btree_gc_recurse(), the compiler might hoist the `atomic_read()` outside of the
while loop where btree_gc_min_nodes() is inlined, preventing us from fetching the
latest counter value. Adding the barrier would guarantee we read the updated
value.

What are your thoughts on this?

Best regards,
Robert Pang