From: Yosry Ahmed <yosryahmed@google.com>
To: Jesper Dangaard Brouer <hawk@kernel.org>
Cc: Shakeel Butt <shakeel.butt@linux.dev>,
tj@kernel.org, cgroups@vger.kernel.org, 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 V4 2/2] cgroup/rstat: Avoid thundering herd problem by kswapd across NUMA nodes
Date: Tue, 2 Jul 2024 05:00:05 -0700 [thread overview]
Message-ID: <CAJD7tkYvygYRz9jgUADE8JEH5Na6yrbfwp7bT6JH5tZMgk3PAQ@mail.gmail.com> (raw)
In-Reply-To: <849e7b86-b971-47d7-8e31-7eee0918ea33@kernel.org>
On Tue, Jul 2, 2024 at 3:35 AM Jesper Dangaard Brouer <hawk@kernel.org> wrote:
>
>
>
> On 29/06/2024 00.15, Yosry Ahmed wrote:
> > [..]
> >>>> + /* Obtained lock, record this cgrp as the ongoing flusher */
> >>>> + if (!READ_ONCE(cgrp_rstat_ongoing_flusher)) {
> >>>
> >>> Can the above condition will ever be false?
> >>>
> >>
> >> Yes, I think so, because I realized that cgroup_rstat_flush_locked() can
> >> release/"yield" the lock. Thus, other CPUs/threads have a chance to
> >> call cgroup_rstat_flush, and try to become the "ongoing-flusher".
> >
> > Right, there may actually be multiple ongoing flushers. I am now
> > wondering if it would be better if we drop cgrp_rstat_ongoing_flusher
> > completely, add a per-cgroup under_flush boolean/flag, and have the
> > cgroup iterate its parents here to check if any of them is under_flush
> > and wait for it instead.
> >
> > Yes, we have to add parent iteration here, but I think it may be fine
> > because the flush path is already expensive. This will allow us to
> > detect if any ongoing flush is overlapping with us, not just the one
> > that happened to update cgrp_rstat_ongoing_flusher first.
> >
> > WDYT?
>
> No, I don't think we should complicate the code to "support" multiple
> ongoing flushers (there is no parallel execution of these). The lock
> yielding cause the (I assume) unintended side-effect that multiple
> ongoing flushers can exist. We should work towards only having a single
> ongoing flusher.
>
> With the current kswapd rstat contention issue, yielding the lock in the
> loop, creates the worst possible case of cache-line trashing, as these
> kthreads run on 12 different NUMA nodes.
>
> I'm working towards changing rstat lock to a mutex. When doing so, we
> should not yield the lock in the loop. This will guarantee only having
> a single ongoing flusher, and reduce cache-line trashing.
If the direction we are heading in is not supporting multiple ongoing
flushers then sure, that makes sense. But if we plan to continue
supporting multiple ongoing flushers, then I think we should fully
commit to it. Let's just avoid a halfway support.
next prev parent reply other threads:[~2024-07-02 12:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-27 21:18 [PATCH V4 1/2] cgroup/rstat: Helper functions for locking expose trylock Jesper Dangaard Brouer
2024-06-27 21:18 ` [PATCH V4 2/2] cgroup/rstat: Avoid thundering herd problem by kswapd across NUMA nodes Jesper Dangaard Brouer
2024-06-27 23:34 ` Shakeel Butt
2024-06-28 9:39 ` Jesper Dangaard Brouer
2024-06-28 22:15 ` Yosry Ahmed
2024-07-02 10:35 ` Jesper Dangaard Brouer
2024-07-02 12:00 ` Yosry Ahmed [this message]
2024-07-08 15:26 ` Jesper Dangaard Brouer
2024-07-16 21:54 ` Yosry Ahmed
2024-07-17 7:46 ` Jesper Dangaard Brouer
2024-07-17 16:04 ` Yosry Ahmed
2024-06-27 22:22 ` [PATCH V4 1/2] cgroup/rstat: Helper functions for locking expose trylock Waiman Long
2024-06-28 1:06 ` Waiman Long
2024-06-28 12:13 ` Jesper Dangaard Brouer
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=CAJD7tkYvygYRz9jgUADE8JEH5Na6yrbfwp7bT6JH5tZMgk3PAQ@mail.gmail.com \
--to=yosryahmed@google.com \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=hawk@kernel.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 \
/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).