linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Namhyung Kim <namhyung@google.com>
Cc: David Rientjes <rientjes@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Suren Baghdasaryan <surenb@google.com>,
	Matthew Wilcox <willy@infradead.org>,
	Christoph Lameter <cl@linux.com>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Davidlohr Bueso <dave@stgolabs.net>,
	linux-mm@kvack.org
Subject: Re: MM global locks as core counts quadruple
Date: Sun, 23 Jun 2024 07:59:39 -1000	[thread overview]
Message-ID: <Znhii7B-phzUtngp@slm.duckdns.org> (raw)
In-Reply-To: <CAA4y5iC=B=vuo34D1L9S2wXHiBfu=_qoZzaQ6vcOVs=b5FwFPw@mail.gmail.com>

Hello,

On Fri, Jun 21, 2024 at 02:37:43PM -0700, Namhyung Kim wrote:
> > >  - cgroup_threadgroup_rwsem
> >
> > This one shouldn't matter at all in setups where new cgroups are populated
> > with CLONE_INTO_CGROUP and not migrated further. The lock isn't grabbed in
> > such usage pattern, which should be the vast majority already, I think. Are
> > you guys migrating tasks a lot or not using CLONE_INTO_CGROUP?
> 
> I'm afraid there are still some use cases in Google that migrate processes
> and/or threads between cgroups. :(

I see. I wonder whether we can turn this into a cgroup lock. It's not
straightforward tho. It's protecting migration against forking and exiting
and the only way to turn it into per-cgroup lock would be tying it to the
source cgroup as that's the only thing identifiable from the fork and exit
paths. The problem is that a single atomic migration operation can pull
tasks from multiple cgroups into one destination cgroup, even on cgroup2 due
to the threaded cgroups. This would be pretty rare on cgroup2 but still need
to be handled which means grabbing multiple locks from the migration path.
Not the end of the world but a bit nasty.

But, as long as it's well encapsulated and out of line, I don't see problems
with such approach.

As for cgroup_mutex, it's more complicated as the usage is more spread, but
yeah, the only solution there too would be going for finer grained locking
whether that's hierarchical or hashed.

Thanks.

-- 
tejun


  reply	other threads:[~2024-06-23 17:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-21  0:35 MM global locks as core counts quadruple David Rientjes
2024-06-21  2:01 ` Matthew Wilcox
2024-06-21  2:46 ` Yafang Shao
2024-06-21  2:54   ` Matthew Wilcox
2024-06-26 19:38     ` Karim Manaouil
2024-06-27  5:36       ` Christoph Lameter (Ampere)
2024-06-21 19:10 ` Tejun Heo
2024-06-21 21:37   ` Namhyung Kim
2024-06-23 17:59     ` Tejun Heo [this message]
2024-06-24 21:44       ` David Rientjes

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=Znhii7B-phzUtngp@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=dave@stgolabs.net \
    --cc=hannes@cmpxchg.org \
    --cc=linux-mm@kvack.org \
    --cc=namhyung@google.com \
    --cc=paulmck@kernel.org \
    --cc=rientjes@google.com \
    --cc=surenb@google.com \
    --cc=willy@infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).