On Wed, Jul 17, 2024 at 11:25 AM Muchun Song <muchun.song@xxxxxxxxx> wrote: > > On Jun 25, 2024, at 01:53, Kairui Song <ryncsn@xxxxxxxxx> wrote: > > > > From: Kairui Song <kasong@xxxxxxxxxxx> > > > > Currently, the (shadow) nodes of the swap cache are not accounted to > > their corresponding memory cgroup, instead, they are all accounted > > to the root cgroup. This leads to inaccurate accounting and > > ineffective reclaiming. > > > > This issue is similar to commit 7b785645e8f1 ("mm: fix page cache > > convergence regression"), where page cache shadow nodes were incorrectly > > accounted. That was due to the accidental dropping of the accounting > > flag during the XArray conversion in commit a28334862993 > > ("page cache: Finish XArray conversion"). > > > > However, this fix has a different cause. Swap cache shadow nodes were > > never accounted even before the XArray conversion, since they did not > > exist until commit 3852f6768ede ("mm/swapcache: support to handle the > > shadow entries"), which was years after the XArray conversion. Without > > shadow nodes, swap cache nodes can only use a very small amount of memory > > and so reclaiming is not very important. > > > > But now with shadow nodes, if a cgroup swaps out a large amount of > > memory, it could take up a lot of memory. > > > > This can be easily fixed by adding proper flags and LRU setters. > > > > Signed-off-by: Kairui Song <kasong@xxxxxxxxxxx> > > I haven't looked at the details of this patch yet, but I think it is not > related to this series, it could be as an individual patch (If it is a real > problem, I think it will be quickly and easily merged). > > Thanks. > The gain of this patch is not as big as being part of the series, but yes, it can be sent independently.