Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3849188rdb; Mon, 11 Dec 2023 01:32:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IEU5ScClRuG8IvKME/9oHHwgWaKUIrdTlib3+4F1cCjceNvc3LmB/fGr4upSPUQ7f+axkoO X-Received: by 2002:a17:902:7202:b0:1d0:5fd7:867c with SMTP id ba2-20020a170902720200b001d05fd7867cmr5507665plb.4.1702287122058; Mon, 11 Dec 2023 01:32:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702287122; cv=none; d=google.com; s=arc-20160816; b=mN3hNr2kudxLPH2NQOTi6OH3oFBGYNSH+sF+PhChtcjEZyeFQf+n354WjCmqiOimyV xZsZfMuMRAMwCpN5bsKlAhXvrfvrOEYwrzjCccmQIoEAV4fVT+uE6riPR9OU5CXDuCax Emgrv8N9eq423mxQBm5+PbzEsH8ovF9TAyBmgRvVbfAUUfR196GNaflE/r27Ew+pbZhQ 1Sdmrpi6LHhVWPsHYsgNh7nKA1GCBheQe4AnLTqRiOenEAvmgXjcW9OpcqTKCbuP/JX7 kvjxiujxjTYLxNiPaXkjw6p4MvbmLGr10JzAdI0Cf2r7fXEqSXziaWF+C/xynZ0Iaqqr ZSpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=bJe20/B6V+1jA/nSiEGTI9TatZJ/dlgC/IshXSznt1k=; fh=D6QWuILL9YhHLPIVOk6uP5BMxFMRU1KcaxkIPPe00TI=; b=Em+4Ixl5cuTbQ59xAyt7YbNhTvPdRCh82x0gYyjk+4baM0uFXEZbTNV5F4DwCuDpbC foZnyqnWuHF/AU8P8f8kHuqV9cAaP1cXCLAauoE2FWH7zPvzCRYOkI+7yQ0N3/4LZfVb n4KU6I8WNutl72yh3z/TpAumlukC/h7KgNhbst6YCAA8MXBqEPSFXaZitJ5+Ho8iL5qP 5D4qFG0fwYWa/o4Gqo+5C0X9v2vUUmV6HPhWSlCAJkI/rNQrYkhqTKGe7DJ+eAGBP/J8 sngYb96ETSb9ht6ZBWETTUPDQyo60ts55/pI5nr9+Mdy9HApr/thgV7F028D5R1TSrBI vP+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DQkLaLJk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id t9-20020a170902e84900b001d09711b7b7si5924605plg.334.2023.12.11.01.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 01:32:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DQkLaLJk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 71F4E806BF0E; Mon, 11 Dec 2023 01:31:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229654AbjLKJbT (ORCPT + 99 others); Mon, 11 Dec 2023 04:31:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229521AbjLKJbT (ORCPT ); Mon, 11 Dec 2023 04:31:19 -0500 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCDECB3; Mon, 11 Dec 2023 01:31:24 -0800 (PST) Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2c9f4bb2e5eso57376971fa.1; Mon, 11 Dec 2023 01:31:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702287083; x=1702891883; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bJe20/B6V+1jA/nSiEGTI9TatZJ/dlgC/IshXSznt1k=; b=DQkLaLJkD7Ex8oJ6wG0A2SxJgSrP3q0wpHNRu56Evzs2Y09MLLq9R6njYRbZMhPYu8 75WOEaZ18/CO2Dkkf0NjW/gMYrB+XN0vCnXwlYXb/Y90s5+SWR4agqPy54HKJ23d8yia 2sKiEZCYcpjwKea6m2ivPmf0dqcX1MtMITStzPJCJNyhOihXxR28ZCaKYwd7TXqu5sof dRHkeZ4hfUw0HgEgzmCx7MI4Pl8fXR4RutrhkPeI8JvIP/FzZ0KLans5NBEfGitFAwZX kVWAFj4TS8oYTaQuFS5S8lUKM+pittOV9cT2D/rEzlCby2m0lTBT4KAXl8/l4AQM7Pqy ZcMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702287083; x=1702891883; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bJe20/B6V+1jA/nSiEGTI9TatZJ/dlgC/IshXSznt1k=; b=VpLAM/MUCeSoI66NUiqfyhL2wDzSEg2uh+ozXrXGN8/jOvUdFYJ/DoRjv4I7KoZadz oOiIUtaFQ1j6bq8os8AKHXtKoHGDZkQfsMXRP6IBhzaQeD60Qn5jKqZ7C/kZ1tZeGsQP GSLvnnl58ax2v013kChnz/HCsGdywO3wNJuWZMVX9Cpjl3+EY0riE1rXtL32cb3Rtpfs je+JUZd/O+/JSVS9R2TY4RpatRBzYVuBVIHXnvANxs8FpaFvqo2R595Ym9wxZ29yhOVW +2B3rc8OvjTsN2nyTaKJ5fTszD19fl2zW2UvTCQPzXaw/WBf1nNltOhWnyNTL7mXso9+ kSTQ== X-Gm-Message-State: AOJu0Yy+0XKQVtvqGOHNPna3owcKgHMfSoNRwasve/uHYPb3g9/NGudb uBRx9uRPQUjpJEZRSseieMTssbp+JiCN0/d5gYU= X-Received: by 2002:a05:651c:19a4:b0:2cc:1db0:4a6f with SMTP id bx36-20020a05651c19a400b002cc1db04a6fmr839578ljb.32.1702287082654; Mon, 11 Dec 2023 01:31:22 -0800 (PST) MIME-Version: 1.0 References: <20231207192406.3809579-1-nphamcs@gmail.com> In-Reply-To: From: Kairui Song Date: Mon, 11 Dec 2023 17:31:05 +0800 Message-ID: Subject: Re: [PATCH v6] zswap: memcontrol: implement zswap writeback disabling To: Chris Li Cc: Nhat Pham , akpm@linux-foundation.org, tj@kernel.org, lizefan.x@bytedance.com, hannes@cmpxchg.org, 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, Minchan Kim , Zhongkun He Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 11 Dec 2023 01:31:58 -0800 (PST) Chris Li =E4=BA=8E2023=E5=B9=B412=E6=9C=889=E6=97=A5=E5= =91=A8=E5=85=AD 07:56=E5=86=99=E9=81=93=EF=BC=9A > > Hi Nhat, > > On Thu, Dec 7, 2023 at 5:03=E2=80=AFPM Nhat Pham wrot= e: > > > > On Thu, Dec 7, 2023 at 4:19=E2=80=AFPM Chris Li wro= te: > > > > > > Hi Nhat, > > > > > > > > > On Thu, Dec 7, 2023 at 11:24=E2=80=AFAM Nhat Pham = wrote: > > > > > > > > During our experiment with zswap, we sometimes observe swap IOs due= to > > > > occasional zswap store failures and writebacks-to-swap. These swapp= ing > > > > IOs prevent many users who cannot tolerate swapping from adopting z= swap > > > > to save memory and improve performance where possible. > > > > > > > > This patch adds the option to disable this behavior entirely: do no= t > > > > writeback to backing swapping device when a zswap store attempt fai= l, > > > > and do not write pages in the zswap pool back to the backing swap > > > > device (both when the pool is full, and when the new zswap shrinker= is > > > > called). > > > > > > > > This new behavior can be opted-in/out on a per-cgroup basis via a n= ew > > > > cgroup file. By default, writebacks to swap device is enabled, whic= h is > > > > the previous behavior. Initially, writeback is enabled for the root > > > > cgroup, and a newly created cgroup will inherit the current setting= of > > > > its parent. > > > > > > > > Note that this is subtly different from setting memory.swap.max to = 0, as > > > > it still allows for pages to be stored in the zswap pool (which its= elf > > > > consumes swap space in its current form). > > > > > > > > This patch should be applied on top of the zswap shrinker series: > > > > > > > > https://lore.kernel.org/linux-mm/20231130194023.4102148-1-nphamcs@g= mail.com/ > > > > > > > > as it also disables the zswap shrinker, a major source of zswap > > > > writebacks. > > > > > > I am wondering about the status of "memory.swap.tiers" proof of conce= pt patch? > > > Are we still on board to have this two patch merge together somehow s= o > > > we can have > > > "memory.swap.tiers" =3D=3D "all" and "memory.swap.tiers" =3D=3D "zswa= p" cover the > > > memory.zswap.writeback =3D=3D 1 and memory.zswap.writeback =3D=3D 0 c= ase? > > > > > > Thanks > > > > > > Chris > > > > > > > Hi Chris, > > > > I briefly summarized my recent discussion with Johannes here: > > > > https://lore.kernel.org/all/CAKEwX=3DNwGGRAtXoNPfq63YnNLBCF0ZDOdLVRsvzU= mYhK4jxzHA@mail.gmail.com/ > > Sorry I am traveling in a different time zone so not able to get to > that email sooner. That email is only sent out less than one day > before the V6 patch right? > > > > > TL;DR is we acknowledge the potential usefulness of swap.tiers > > interface, but the use case is not quite there yet, so it does not > > I disagree about no use case. No use case for Meta !=3D no usage case > for the rest of the linux kernel community. That mindset really needs > to shift to do Linux kernel development. Respect other's usage cases. > It is not just Meta's Linux kernel. It is everybody's Linux kernel. > > I can give you three usage cases right now: > 1) Google producting kernel uses SSD only swap, it is currently on > pilot. This is not expressible by the memory.zswap.writeback. You can > set the memory.zswap.max =3D 0 and memory.zswap.writeback =3D 1, then SSD > backed swapfile. But the whole thing feels very clunky, especially > what you really want is SSD only swap, you need to do all this zswap > config dance. Google has an internal memory.swapfile feature > implemented per cgroup swap file type by "zswap only", "real swap file > only", "both", "none" (the exact keyword might be different). running > in the production for almost 10 years. The need for more than zswap > type of per cgroup control is really there. > > 2) As indicated by this discussion, Tencent has a usage case for SSD > and hard disk swap as overflow. > https://lore.kernel.org/linux-mm/20231119194740.94101-9-ryncsn@gmail.com/ > +Kairui Yes, we are not using zswap. We are using ZRAM for swap since we have many different varieties of workload instances, with a very flexible storage setup. Some of them don't have the ability to set up a swapfile. So we built a pack of kernel infrastructures based on ZRAM, which so far worked pretty well. The concern from some teams is that ZRAM (or zswap) can't always free up memory so they may lead to higher risk of OOM compared to a physical swap device, and they do have suitable devices for doing swap on some of their machines. So a secondary swap support is very helpful in case of memory usage peak. Besides this, another requirement is that different containers may have different priority, some containers can tolerate high swap overhead while some cannot, so swap tiering is useful for us in many ways. And thanks to cloud infrastructure the disk setup could change from time to time depending on workload requirements, so our requirement is to support ZRAM (always) + SSD (optional) + HDD (also optional) as swap backends, while not making things too complex to maintain. Currently we have implemented a cgroup based ZRAM compression algorithm control, per-cgroup ZRAM accounting and limit, and a experimental kernel worker to migrate cold swap entry from high priority device to low priority device at very small scale (lack of basic mechanics to do this at large scale, however due to the low IOPS of slow device and cold pages are rarely accessed, this wasn't too much of a problem so far but kind of ugly). The rest of swapping (eg. secondary swap when ZRAM if full) will depend on the kernel's native ability. So far it works, not in the best form, need more patches to make it work better (eg. the swapin/readahead patch I sent previously). Some of our design may also need to change in the long term, and we also want a well built interface and kernel mechanics to manage multi tier swaps, I'm very willing to talk and collaborate on this.