From: Jesper Dangaard Brouer <hawk@kernel.org>
To: Yosry Ahmed <yosryahmed@google.com>
Cc: tj@kernel.org, cgroups@vger.kernel.org, shakeel.butt@linux.dev,
hannes@cmpxchg.org, lizefan.x@bytedance.com, longman@redhat.com,
kernel-team@cloudflare.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH V8 1/2] cgroup/rstat: Avoid flushing if there is an ongoing overlapping flush
Date: Fri, 2 Aug 2024 13:43:11 +0200 [thread overview]
Message-ID: <ee0f7d29-1385-4799-ab4b-6080ca7fd74b@kernel.org> (raw)
In-Reply-To: <CAJD7tkaZuiSCj4RZ2v6jOCtwiv++YNQxA0x6MEp-HrHaYO6_9g@mail.gmail.com>
On 30/07/2024 20.54, Yosry Ahmed wrote:
> [..]
>>
>> Well... I'm still not convinced that it makes sense to have level >= 2
>> be the ongoing flusher.
>>
>> E.g. if a level 2 cgroup becomes ongoing flusher, and kswapd starts 12
>> NUMA flushes at the same time, then the code will have these 12 kswapd
>> threads spin on the lock, until ongoing flusher finishes. That is likely
>> what happened above (for a level 1). These 12 spinning (root) flushers
>> will not recheck ongoing_flusher and will all flush the root
>> (unnecessarily 11 times).
>
> Hmm regardless of whether or not the level-2 cgroup becomes the
> ongoing flusher, the kswapd threads will all spin on the lock anyway
> since none of them can be the ongoing flusher until the level-2 cgroup
> finishes. Right?
>
> Is the scenario you have in mind that the level-2 cgroup starts
> flushing at the same time as kswapd, so there is a race on who gets to
> be the ongoing flusher? In this case as well, whoever gets the lock
> will be the ongoing flusher anyway.
>
> Not allowing whoever is holding the lock to be the ongoing flusher
> based on level is only useful when we can have multiple ongoing
> flushers (with lock yielding). Right?
>
> Perhaps I am missing something here.
>
>>
>> So, I don't think it is a good idea to have anything else that the root
>> as the ongoing flusher.
>>
>> Can you explain/convince me why having sub-cgroups as ongoing flusher is
>> an advantage?
>
> I just don't see the benefit of the special casing here as I mentioned
> above. If I missed something please let me know.
>
I do think you missed something. Let me try to explain this in another
way. (I hope my frustrations doesn't shine through).
The main purpose of the patch is/was to stop the thundering herd of
kswapd thread flushing (root-cgrp) at exactly the same time, leading to
lock contention. This happens all-the-time/constantly in production.
The first versions (where ongoing was limited to root/level=0) solved
this 100%. The patches that generalized this to be all levels can
become ongoing flush, doesn't solve the problem any-longer!
I hope it is clear what fails. E.g. When a level>0 becomes ongoing
flusher, and 12 kswapd simultaneously does a level=0/root-cgrp flush,
then we have 12 CPU cores spinning on the rstat lock. (These 12 kswapd
threads will all go-through completing the flush, as they do not
discover/recheck that ongoing flush was previously became their own level).
I think we need to go back to only having root-cgroup as ongoing flusher.
--Jesper
next prev parent reply other threads:[~2024-08-02 11:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-19 13:06 [PATCH V8 1/2] cgroup/rstat: Avoid flushing if there is an ongoing overlapping flush Jesper Dangaard Brouer
2024-07-19 13:07 ` [PATCH V8 2/2] cgroup/rstat: add tracepoints for ongoing flusher waits Jesper Dangaard Brouer
2024-07-22 17:02 ` [PATCH V8 1/2] cgroup/rstat: Avoid flushing if there is an ongoing overlapping flush Yosry Ahmed
2024-07-30 16:50 ` Jesper Dangaard Brouer
2024-07-30 18:54 ` Yosry Ahmed
2024-07-30 20:15 ` Jesper Dangaard Brouer
2024-08-02 11:43 ` Jesper Dangaard Brouer [this message]
2024-08-02 16:10 ` Yosry Ahmed
2024-08-05 14:23 ` Jesper Dangaard Brouer
2024-08-05 18:50 ` Yosry Ahmed
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=ee0f7d29-1385-4799-ab4b-6080ca7fd74b@kernel.org \
--to=hawk@kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@cloudflare.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizefan.x@bytedance.com \
--cc=longman@redhat.com \
--cc=shakeel.butt@linux.dev \
--cc=tj@kernel.org \
--cc=yosryahmed@google.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;
as well as URLs for NNTP newsgroup(s).