Thanks. I ran into this while testing bcachefs performance changes. The 
bcachefs ktest end checks write `do_rcu_barrier` before reading 
`/proc/allocinfo`, with the expectation that allocations still reported 
afterwards are leaks. Small objects released with `kfree_rcu()` remained 
visible after repeated writes to the hook and 20 seconds of waiting, so 
otherwise clean tests failed their leak check.

Strictly, that ktest is assuming a stronger contract than the hook currently 
documents: `do_rcu_barrier` promises an ordinary `rcu_barrier()`, not a 
complete drain of objects still held in `kfree_rcu()` batching. I nevertheless 
think the stronger behaviour is useful for this test-only quiescence hook, 
because it lets allocation-leak checks reliably separate deferred frees from 
genuine leaks.

I followed those allocations across repeated filesystem lifecycles. Their 
number eventually fell when an RCU sheaf filled, so I have no evidence that 
this path grows without bound or causes OOM. The problem I observed is limited 
to test isolation: the hook can leave deferred frees behind and make them look 
like leaks. With the proposed change, the same unmodified bcachefs workload 
passed the leak check.

After tracing that behaviour, I wrote the private-cache module in the cover 
letter to reproduce it without bcachefs. I can publish the original bcachefs 
workload and results if anyone is interested.

I also found that this exact follow-on was discussed when 
`kvfree_rcu_barrier()` was added in 2024: Paul proposed calling it from 
`rcu_barrier_throttled()` for clean userspace benchmark baselines, and 
Uladzislau agreed that adding it and documenting both operations was safest: 
https://lore.kernel.org/all/[email protected]/

You are right about the `Fixes:` tag. `kvfree_rcu()` batching predates 
`do_rcu_barrier`, and the existing interface does what it documents, so the 
later sheaf commit is not the right introduction point. I will omit the 
`Fixes:` tag in v2 and present this as a strengthening of the test interface.

-- 
Matthias

Reply via email to