Re: [PATCH] mm: batch per-task lruvec stat updates on the writeback path
From: Matthew Wilcox
Date: Fri Nov 20 2026 - 08:41:26 EST
On Fri, Nov 20, 2026 at 05:55:58PM +0800, Xavier Xia wrote:
> The writeback path updates two lruvec stats per folio through the memcg
> rstat machinery: NR_FILE_DIRTY when a folio is dirtied and again when
> writeback clears it, and NR_WRITEBACK when writeback starts on it.
> Consecutive folios almost always share a lruvec, so the same counters
> are updated over and over. On a 4k buffered write + fsync workload
> __mod_memcg_lruvec_state() is about 8% of the profile.
Is this a realistic benchmark? Does it represent some real life workload,
or did you just choose it because it shows the best benefit of this patch?
This is a fairly significant chunk of extra code, and it'd be nice to
know that it benefits a real-world use-case before applying it.
If the real world usecase is more "there's some pretty high overhead
when flushing accumulated megabytes of dirtied page cache", then there
are simpler solutions that don't involve messing with task_struct.