Re: [PATCH] mm: batch per-task lruvec stat updates on the writeback path

From: Xavier Xia

Date: Tue Nov 24 2026 - 06:43:04 EST


Hi Willy,

Thanks for the feedback. That's a fair concern.

The original fio benchmark uses 4K buffered writes with fsync at
the end of each job, rather than after every write. The improvement
is reproducible in that setup, but it is a synthetic workload.

I also tested extracting a tar archive and copying a tree of small
files on ext4 backed by a ramdisk. Initial runs showed 4.3% and 3.5%
reductions in wall time, respectively. However, these improvements
were not consistent across independent boots, so I don't have
convincing evidence of a real-world benefit that justifies the
added complexity.

Further testing also uncovered correctness issues in the patch.
Deferred NR_WRITEBACK increments can temporarily be missing from
the counters while completion decrements are applied immediately,
potentially affecting dirty throttling. I also reproduced 8-12 KiB
of stale file_dirty accounting after fsync in a non-root memcg with
periodic writeback disabled.

I explored a writeback-local alternative without modifying
task_struct. Although it passed the correctness tests I ran, it
did not demonstrate a reproducible end-to-end performance
improvement.

Given these findings, I don't think the current patch is suitable
for merging. Please consider it withdrawn.

Thanks,
Xavier



On Fri, Nov 20, 2026 at 9:41 PM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote:
>
> 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.