linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Shakeel Butt <shakeel.butt@linux.dev>
To: Kairui Song <ryncsn@gmail.com>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
	 Matthew Wilcox <willy@infradead.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	 Roman Gushchin <roman.gushchin@linux.dev>,
	Nhat Pham <nphamcs@gmail.com>, Michal Hocko <mhocko@suse.com>,
	 Chengming Zhou <zhouchengming@bytedance.com>,
	Muchun Song <muchun.song@linux.dev>,
	 Chris Li <chrisl@kernel.org>,
	Yosry Ahmed <yosryahmed@google.com>,
	 "Huang, Ying" <ying.huang@intel.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm/swap, workingset: make anon shadow nodes memcg aware
Date: Wed, 21 Aug 2024 11:14:22 -0700	[thread overview]
Message-ID: <67wuawgnf5os22gb2woshxve2kdkxz3pkcfdy7kcm7irj6d5tn@h42jzenif3wa> (raw)
In-Reply-To: <CAMgjq7D9WWXWFKcGs1ZsU7pNykoWV7RmsoBdP9CcGEa4N7d3fg@mail.gmail.com>

On Thu, Aug 22, 2024 at 01:35:29AM GMT, Kairui Song wrote:
> Shakeel Butt <shakeel.butt@linux.dev> 于 2024年8月21日周三 08:22写道:
[...]
> 
> Hi, Thanks for the comments.
> 
> > Is this a real issue? Have you seen systems in the production with
> > large amount of memory occupied by anon shadow entries? This is still
> > limited to the amount of swap a cgroup is allowed to use.
> 
> No, this patch is cherry picked from previous series, this help
> separating the shadows to different cgroup properly according to my
> test, and reduces the lock contention of list_lru by a lot combined
> with later patches. Not very convincing on its own indeed, so I
> hesitated to send it alone.
> 

So, list_lru lock contention is the problem you are trying to solve.
Without this patch, do you see less impact of your list_lru series?
Anyways this patch is not the right way to solve the list_lru lock
contention issue.

> > The reason I am asking is that this solution is worse than the perceived
> > problem at least to me. With this patch, the kernel will be charging
> > unrelated cgroups for the memory of swap xarray nodes during global
> > reclaim and proactive reclaim.
> 
> Yes, this could be a problem.
> 
> I didn't observe this happening frequently with tests though, SWAP
> tends to cluster the SWAP allocations, and reclaiming tends to batch
> reclaim pages, so usually there is a fair high chance that shadows of
> pages of the same memcg stay on the same node.
> 
> It could end up completely random when the SWAP device is getting
> fragmented or reclaim is struggling though.

In actual production, fragmentation and memory over-commit is very
normal. So, such scenarios would occure more often.

> 
> > You can reduce this weirdness by using set_active_memcg() in
> > add_to_swap_cache() using the given folio's memcg but still you have the
> > case of multiple unrelated folios and shadow entries of different
> > cgroups within the same node. For filesystem case, the userspace can
> > control which files are shared between different cgroups and has more
> > control on it. That is not the case for swap space.
> 
> Right, this fix is not perfect, it's arguable if this new behaviour is
> better or worse than before. There is some ongoing work from the SWAP
> side so things may get fixed differently in the future, but I'll also
> check if this patch can be improved.

Yeah with mTHP we can reevaluate this approach.


      reply	other threads:[~2024-08-21 18:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-20  9:23 Kairui Song
2024-08-21  0:21 ` Shakeel Butt
2024-08-21 17:35   ` Kairui Song
2024-08-21 18:14     ` Shakeel Butt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=67wuawgnf5os22gb2woshxve2kdkxz3pkcfdy7kcm7irj6d5tn@h42jzenif3wa \
    --to=shakeel.butt@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=chrisl@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=nphamcs@gmail.com \
    --cc=roman.gushchin@linux.dev \
    --cc=ryncsn@gmail.com \
    --cc=willy@infradead.org \
    --cc=ying.huang@intel.com \
    --cc=yosryahmed@google.com \
    --cc=zhouchengming@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox