Re: [PATCH v2 3/5] f2fs: cache: wake up f2fs_writeback when exceeding threshold
From: Chao Yu
Date: Mon Oct 12 2026 - 05:27:48 EST
Hi Wenjie,
Thanks a lot for the review.
On 10/9/26 18:13, Wenjie Qi wrote:
Hi Chao,
+ if (dirty_threshold && nr_dirty < dirty_threshold)
+ return false;
+
+ /* don't wake up f2fs_writeback if both thresholds are zero */
+ return total_threshold || dirty_threshold;
There is a related case with only the total threshold enabled. With
cache_wb_dirty_threshold=0 and cache_wb_total_threshold=1, clean cached
entries keep the predicate true even when there are no dirty meta/node
caches. Writeback does not necessarily evict those entries, so the
thread can keep looping without sleeping.
I checked this in QEMU using dev-test plus my both-zero fix, which has
the same predicate for these fixed threshold values. In a three-second
idle interval, the writeback thread used about three CPU seconds;
the total cache count was 22 and the dirty count was zero at both
sample points.
Should the thread wait when no dirty caches remain, even if the total
threshold is still met, or is different behavior intended for this mode?
Thanks for the test, yes, it should wait. In v3, the thread won't be
woken up unless there are enough dirty caches for
f2fs_write_{meta,node}_caches() to gather (i.e. dirty count reaches
nr_caches_to_skip()), regardless of the total threshold. Also, threshold
based wakeup will be throttled once a round fails to write anything.
With your setting (dirty_threshold=0, total_threshold=1), I can see the
writeback thread uses 0.0% cpu in idle state, w/ either few or thousands
of clean cached entries, and w/ dirty caches below the threshold under
checkpoint=disable.
Thanks,
Best regards,
Wenjie