From: Yosry Ahmed <yosryahmed@google.com>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Nhat Pham <nphamcs@gmail.com>,
akpm@linux-foundation.org, cerasuolodomenico@gmail.com,
sjenning@redhat.com, ddstreet@ieee.org,
vitaly.wool@konsulko.com, mhocko@kernel.org,
roman.gushchin@linux.dev, shakeelb@google.com,
muchun.song@linux.dev, linux-mm@kvack.org, kernel-team@meta.com,
linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
Chris Li <chrisl@kernel.org>
Subject: Re: [PATCH v2 1/2] zswap: make shrinking memcg-aware
Date: Wed, 27 Sep 2023 13:57:17 -0700 [thread overview]
Message-ID: <CAJD7tkbHsmM9tVTwv2Ve7Ekj_bgcZxVgpXKG8upNtZjAkimeZw@mail.gmail.com> (raw)
In-Reply-To: <20230927205153.GB399644@cmpxchg.org>
On Wed, Sep 27, 2023 at 1:51 PM Johannes Weiner <hannes@cmpxchg.org> wrote:
>
> On Mon, Sep 25, 2023 at 01:17:04PM -0700, Yosry Ahmed wrote:
> > On Tue, Sep 19, 2023 at 10:14 AM Nhat Pham <nphamcs@gmail.com> wrote:
> > > + is_empty = false;
> > > + }
> > > + zswap_pool_put(pool);
> > > +
> > > + if (is_empty)
> > > + return -EINVAL;
> > > + if (shrunk)
> > > + return 0;
> > > + return -EAGAIN;
> > > }
> > >
> > > static void shrink_worker(struct work_struct *w)
> > > {
> > > struct zswap_pool *pool = container_of(w, typeof(*pool),
> > > shrink_work);
> > > - int ret, failures = 0;
> > > + int ret, failures = 0, memcg_selection_failures = 0;
> > >
> > > + /* global reclaim will select cgroup in a round-robin fashion. */
> > > do {
> > > - ret = zswap_reclaim_entry(pool);
> > > + /* previous next_shrink has become a zombie - restart from the top */
> >
> > Do we skip zombies because all zswap entries are reparented with the objcg?
> >
> > If yes, why do we restart from the top instead of just skipping them?
> > memcgs after a zombie will not be reachable now IIUC.
> >
> > Also, why explicitly check for zombies instead of having
> > shrink_memcg() just skip memcgs with no zswap entries? The logic is
> > slightly complicated.
>
> I think this might actually be a leftover from the initial plan to do
> partial walks without holding on to a reference to the last scanned
> css. Similar to mem_cgroup_iter() does with the reclaim cookie - if a
> dead cgroup is encountered and we lose the tree position, restart.
>
> But now the code actually holds a reference, so I agree the zombie
> thing should just be removed.
It might be nice to keep in shrink_memcg() as an optimization and for
fairness. IIUC, if a memcg is zombified the list_lrus will be
reparented, so we will scan the parent's list_lrus again, which can be
unfair to that parent. It can also slow things down if we have a large
number of zombies, as their number is virtually unbounded.
next prev parent reply other threads:[~2023-09-27 20:58 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-19 17:14 [PATCH v2 0/2] workload-specific and memory pressure-driven zswap writeback Nhat Pham
2023-09-19 17:14 ` [PATCH v2 1/2] zswap: make shrinking memcg-aware Nhat Pham
2023-09-25 20:17 ` Yosry Ahmed
2023-09-26 18:24 ` Johannes Weiner
2023-09-26 18:37 ` Yosry Ahmed
2023-09-27 20:39 ` Johannes Weiner
2023-09-27 19:48 ` Domenico Cerasuolo
2023-09-27 20:28 ` Yosry Ahmed
2023-09-27 21:02 ` Johannes Weiner
2023-09-27 21:07 ` Yosry Ahmed
2023-09-27 20:51 ` Johannes Weiner
2023-09-27 20:57 ` Yosry Ahmed [this message]
2023-10-17 17:44 ` Ryan Roberts
2023-10-17 17:56 ` Domenico Cerasuolo
2023-10-17 18:25 ` Ryan Roberts
2023-09-19 17:14 ` [PATCH v2 2/2] zswap: shrinks zswap pool based on memory pressure Nhat Pham
2023-09-25 20:37 ` Yosry Ahmed
2023-09-25 23:29 ` Nhat Pham
2023-09-25 23:59 ` Yosry Ahmed
2023-09-26 0:43 ` Nhat Pham
2023-09-26 1:11 ` Yosry Ahmed
2023-09-27 23:42 ` Nhat Pham
2023-09-19 19:31 ` [PATCH v2 0/2] workload-specific and memory pressure-driven zswap writeback Nhat Pham
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=CAJD7tkbHsmM9tVTwv2Ve7Ekj_bgcZxVgpXKG8upNtZjAkimeZw@mail.gmail.com \
--to=yosryahmed@google.com \
--cc=akpm@linux-foundation.org \
--cc=cerasuolodomenico@gmail.com \
--cc=cgroups@vger.kernel.org \
--cc=chrisl@kernel.org \
--cc=ddstreet@ieee.org \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=nphamcs@gmail.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeelb@google.com \
--cc=sjenning@redhat.com \
--cc=vitaly.wool@konsulko.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