linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Chris Li <chrisl@kernel.org>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Minchan Kim <minchan@kernel.org>, Nhat Pham <nphamcs@gmail.com>,
	akpm@linux-foundation.org,  tj@kernel.org,
	lizefan.x@bytedance.com, cerasuolodomenico@gmail.com,
	 yosryahmed@google.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, hughd@google.com, corbet@lwn.net,
	 konrad.wilk@oracle.com, senozhatsky@chromium.org,
	rppt@kernel.org,  linux-mm@kvack.org, kernel-team@meta.com,
	linux-kernel@vger.kernel.org,  linux-doc@vger.kernel.org,
	david@ixit.cz, Kairui Song <kasong@tencent.com>,
	 Zhongkun He <hezhongkun.hzk@bytedance.com>
Subject: Re: [PATCH v6] zswap: memcontrol: implement zswap writeback disabling
Date: Thu, 14 Dec 2023 14:54:52 -0800	[thread overview]
Message-ID: <CAF8kJuN=6CfU2mXP4VFgCkngRGz6Ni67SSHLps8_A+ZScDckUw@mail.gmail.com> (raw)
In-Reply-To: <20231214221140.GA269753@cmpxchg.org>

On Thu, Dec 14, 2023 at 2:11 PM Johannes Weiner <hannes@cmpxchg.org> wrote:
>
> On Thu, Dec 14, 2023 at 09:34:06AM -0800, Christopher Li wrote:
> > On Thu, Dec 14, 2023 at 9:11 AM Johannes Weiner <hannes@cmpxchg.org> wrote:
> >
> > > > Hi Johannes,
> > > >
> > > > I haven't been following the thread closely, but I noticed the discussion
> > > > about potential use cases for zram with memcg.
> > > >
> > > > One interesting idea I have is to implement a swap controller per cgroup.
> > > > This would allow us to tailor the zram swap behavior to the specific needs of
> > > > different groups.
> > > >
> > > > For example, Group A, which is sensitive to swap latency, could use zram swap
> > > > with a fast compression setting, even if it sacrifices some compression ratio.
> > > > This would prioritize quick access to swapped data, even if it takes up more space.
> > > >
> > > > On the other hand, Group B, which can tolerate higher swap latency, could benefit
> > > > from a slower compression setting that achieves a higher compression ratio.
> > > > This would maximize memory efficiency at the cost of slightly slower data access.
> > > >
> > > > This approach could provide a more nuanced and flexible way to manage swap usage
> > > > within different cgroups.
> > >
> > > That makes sense to me.
> > >
> > > It sounds to me like per-cgroup swapfiles would be the easiest
> > > solution to this. Then you can create zram devices with different
> > > configurations and assign them to individual cgroups.
> >
> > Ideally you need zram then following swap file after the zram. That
> > would be a list of the swap files rather than just one swapfile per
> > cgroup.
> >
> > > This would also apply to Kairu's usecase: assign zrams and hdd backups
> > > as needed on a per-cgroup basis.
> >
> > Same there, Kairui's request involves ZRAM and at least one extra swap
> > file. In other words, you really need a per cgroup swap file list.
>
> Why is that a problem?

It is not a problem. It is the necessary infrastructure to support the
requirement. I am merely saying just having one swap file is not
enough.

>
> swapon(zram, cgroup=foo)
> swapon(hdd, cgroup=foo)

Interesting idea. I assume you want to use swapon/swapoff to turn on
off a device for a specific cgroup.
That seems to implite each cgroup will have a private copy of the swap
device list.

I have considered the memory.swap.tiers for the same thing, with one
minor optimization. The list is system wide maintained with a name.
The per cgroup just has a pointer to that named list. There shouldn't
be too many such lists of swap back end combinations on the system.

We are getting into the weeds. The bottom line is, we need to have per
cgroup a swap file list. That is the necessary evil we can't get away
with.

>
> > > In addition, it would naturally solve scalability and isolation
> > > problems when multiple containers would otherwise be hammering on the
> > > same swap backends and locks.
> > >
> > > It would also only require one, relatively simple new interface, such
> > > as a cgroup parameter to swapon().
> > >
> > > That's highly preferable over a complex configuration file like
> > > memory.swap.tiers that needs to solve all sorts of visibility and
> > > namespace issues and duplicate the full configuration interface of
> > > every backend in some new, custom syntax.
> >
> > If you don't like the syntax of memory.swap.tiers, I am open to
> > suggestions of your preferred syntax as well. The essicents of the
> > swap.tiers is a per cgroup list of the swap back ends. The names imply
> > that. I am not married to any given syntax of how to specify the list.
> > Its goal matches the above requirement pretty well.
>
> Except Minchan said that he would also like different zram parameters
> depending on the cgroup.

Minchan's requirement is new. We will need to expand the original
"memory.swap.tiers" to support such usage.

> There is no way we'll add a memory.swap.tiers with a new configuration
> language for backend parameters.
>

I agree that we don't want a complicated configuration language for
"memory.swap.tiers".

Those backend parameters should be configured on the back end side.
The "memory.swap.tiers" just reference the already configured object.
Just brainstorming:
/dev/zram0 has compression algo1 for fast speed low compression ratio.
/dev/zram1 has compression algo2 for slow speed high compression ratio.

"memory.swap.tiers" point to zram0 or zram1 or a custom list has "zram0 + hdd"

Chris


  reply	other threads:[~2023-12-14 22:55 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-07 19:24 Nhat Pham
2023-12-07 19:26 ` Yosry Ahmed
2023-12-07 22:11 ` Andrew Morton
2023-12-08  0:42   ` Nhat Pham
2023-12-08  1:14     ` Nhat Pham
2023-12-08 19:58       ` Andrew Morton
2023-12-08 19:57     ` Andrew Morton
2023-12-08  0:19 ` Chris Li
2023-12-08  1:03   ` Nhat Pham
2023-12-08  1:12     ` Yosry Ahmed
2023-12-08 16:34       ` Johannes Weiner
2023-12-08 20:08         ` Yosry Ahmed
2023-12-09  2:02         ` Chris Li
2023-12-09  0:09       ` Chris Li
2023-12-08 23:55     ` Chris Li
2023-12-09  3:42       ` Johannes Weiner
2023-12-09 17:39         ` Chris Li
2023-12-11 22:55         ` Minchan Kim
2023-12-12  2:43           ` [External] " Zhongkun He
2023-12-12 23:57           ` Chris Li
2023-12-20 10:22             ` Kairui Song
2023-12-14 17:11           ` Johannes Weiner
2023-12-14 17:23             ` Yu Zhao
2023-12-14 18:00               ` Fabian Deutsch
2023-12-14 23:22                 ` Chris Li
2023-12-15  7:42                   ` Fabian Deutsch
2023-12-15  9:40                     ` Chris Li
2023-12-15  9:50                       ` Fabian Deutsch
2023-12-15  9:18                   ` Fabian Deutsch
2023-12-14 18:03               ` Fabian Deutsch
2023-12-14 17:34             ` Christopher Li
2023-12-14 22:11               ` Johannes Weiner
2023-12-14 22:54                 ` Chris Li [this message]
2023-12-15  2:19                   ` Nhat Pham
2023-12-12 21:36         ` Nhat Pham
2023-12-13  0:29           ` Chris Li
2023-12-11  9:31       ` Kairui Song
2023-12-12 23:39         ` Chris Li
2023-12-20 10:21           ` Kairui Song
2023-12-15 21:21 ` Yosry Ahmed
2023-12-18 14:44   ` Johannes Weiner
2023-12-18 19:21     ` Nhat Pham
2023-12-18 21:54       ` Yosry Ahmed
2023-12-18 21:52     ` Yosry Ahmed
2023-12-20  5:15       ` Johannes Weiner
2023-12-20  8:59         ` Yosry Ahmed
2023-12-20 14:50           ` Johannes Weiner
2023-12-21  0:24             ` Yosry Ahmed
2023-12-21  0:50               ` Nhat Pham
2023-12-21  0:57 ` [PATCH v6] zswap: memcontrol: implement zswap writeback disabling (fix) Nhat Pham
2023-12-24 17:17   ` Chris Li

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='CAF8kJuN=6CfU2mXP4VFgCkngRGz6Ni67SSHLps8_A+ZScDckUw@mail.gmail.com' \
    --to=chrisl@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=cerasuolodomenico@gmail.com \
    --cc=corbet@lwn.net \
    --cc=david@ixit.cz \
    --cc=ddstreet@ieee.org \
    --cc=hannes@cmpxchg.org \
    --cc=hezhongkun.hzk@bytedance.com \
    --cc=hughd@google.com \
    --cc=kasong@tencent.com \
    --cc=kernel-team@meta.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lizefan.x@bytedance.com \
    --cc=mhocko@kernel.org \
    --cc=minchan@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=nphamcs@gmail.com \
    --cc=roman.gushchin@linux.dev \
    --cc=rppt@kernel.org \
    --cc=senozhatsky@chromium.org \
    --cc=shakeelb@google.com \
    --cc=sjenning@redhat.com \
    --cc=tj@kernel.org \
    --cc=vitaly.wool@konsulko.com \
    --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