Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4932350rdb; Tue, 12 Dec 2023 13:36:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcdNpmYIJbs4gSNzqwJQEIdPwL9ra0DnGf4QcIwEcqDjPobn+v8tovCR7Ku3B/MO03G5Oq X-Received: by 2002:a05:6a20:7344:b0:190:17a6:24c1 with SMTP id v4-20020a056a20734400b0019017a624c1mr8835119pzc.74.1702417016912; Tue, 12 Dec 2023 13:36:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702417016; cv=none; d=google.com; s=arc-20160816; b=xbpAikw8sFUd8O4CGtZou4BQWZNW9T5aq+QY2Pi4mhGRxrI5uBwLeVqBkg2J/4sQKA wDIpM/BIVihvIrJ7AiPMdjFgV79/MH4vLaf5y8KV4UpbZxF0wmUoLb+s5Wj3WJb2p4dF jTjBeaHHzp8vRoR7V0Xw7hmJQ0t9jZRlOCJZGpOmFlu2YBNqE71GhzzMxO/WEzOJpq8p 9cb4SmKFmEusdCqlUhouWMJ+W3vIBpaqz6EgLXGrQCB2TffJjvWh0FbsbQ17WF2K3KTB BO16rhg2PoPBVi0sdloaJ/Y7ybtY4reA1qvHyGHGakcMxOLhmQX2MRMw9wQjAivLL1Xm 2rEQ== 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=QqP0NZs3Xrf1lShIPhdYETxSBrVBzpiJjKpJblNh5Yc=; fh=Mg0lwYvLeeymgltqMdzarhDIz23bcICIws/QXw5HgtY=; b=Ep7doybcqRDuTueR28thLSU16vWe3yTNy8FkPA+k2Kwjnc9mAVhW/hvIt5+u6zf1iZ mmrul8n42leGPsM14b3t6SequanZRpmZZOgU5IXC8FTDkvTTo1CZkt/KLw+7IWocvyfK MHtSVyPEm243207pklsxWkvAwra0HUt2F4CW2f8C+mC7EodQCMVjtj5EW08PrwC4YJgq XUbMMLk2AOMEgoc6cMtG36+uft2X7bjd5mjuGpk3j6kkFgShcHlyvfoPndez3AcWKw5t l4znqK7cmS/jJL8S/yNV0hWnXT+zsktmex0NMoT9nMfc4YXxiLevFCydF0ZNZR3pTl4Q aAwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AYjQLFc1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id e6-20020a654786000000b005c680fbab23si8476501pgs.527.2023.12.12.13.36.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 13:36:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AYjQLFc1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 51BEE804B87B; Tue, 12 Dec 2023 13:36:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377601AbjLLVgc (ORCPT + 99 others); Tue, 12 Dec 2023 16:36:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377195AbjLLVga (ORCPT ); Tue, 12 Dec 2023 16:36:30 -0500 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D090DC; Tue, 12 Dec 2023 13:36:36 -0800 (PST) Received: by mail-il1-x12c.google.com with SMTP id e9e14a558f8ab-35da93ba227so22255695ab.0; Tue, 12 Dec 2023 13:36:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702416995; x=1703021795; 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=QqP0NZs3Xrf1lShIPhdYETxSBrVBzpiJjKpJblNh5Yc=; b=AYjQLFc1mWm7PsZVf+mTAK5HAKJH5Poe3QMyAHDIxYkbtkv+J4MDVuGgR0FErzujJW DJmboS3UaiwT5HeUUHSW7Mi7veWepqgiSn+HrTg6o4VXVTLslmzgCbdM1LIwRSWnvTIP mlzUTaF13btk/yk4E0LqjFlDiHqUqzH66AK4QgReh2YaiYzuXOuZRrF4xZvEpHv7rsg2 XBYItqI3wTbOUhBWvI/7ceA8dCTad3fEQ1S0Z9MrJwWDQHJ/dUJ6v20pfG2rK0BLAnvH kRmUrO76zkvxw8vFeE7o1HBr2bVVC7mqemNnHoLQpkzGFgoMnHAGirim2KXr+08kYPl/ FarA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702416995; x=1703021795; 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=QqP0NZs3Xrf1lShIPhdYETxSBrVBzpiJjKpJblNh5Yc=; b=dGStNsrYZOnZ4QmnKq+SwhazG2ccfOLI3X3knYzWl+yM37m8UN/i3GhSEIzlKY8Xes Tat2WrvruKSoSJ1Ea1lc53Vs9UHr3NogHD2+t3RCyHI7H7/Jw1GoeR7x2biXVA+/XbmD hmdK4gaC021qlV46qh7Ak1LTt7xIBCqwnXyTDzgICusBcwISTG4RCnNL2ca4NCkUtliz v6rzjHqczuH4+ZiTm6wRXEFwXyQ+fcS86z5BihJ/oJMsvG3XQPrAOgDymf24u/RmSGKy 76mWlhda8BZ28p58ef8O2J88lixSSziPP7cnLeY1H/ZDcQ+Qnx1Gvq19zOJec3L4kqNj r6ig== X-Gm-Message-State: AOJu0YykSIsb24nuSose2vY500n+4NGoNyQ3WURZKWCvV7hQZvz3XZeu f4CioT1pVi5KZ8DpoN3VrF2ERxjuUvJjZ5fklgg= X-Received: by 2002:a05:6e02:1cab:b0:35d:59a2:bb5 with SMTP id x11-20020a056e021cab00b0035d59a20bb5mr6404771ill.75.1702416994943; Tue, 12 Dec 2023 13:36:34 -0800 (PST) MIME-Version: 1.0 References: <20231207192406.3809579-1-nphamcs@gmail.com> <20231209034229.GA1001962@cmpxchg.org> In-Reply-To: <20231209034229.GA1001962@cmpxchg.org> From: Nhat Pham Date: Tue, 12 Dec 2023 13:36:23 -0800 Message-ID: Subject: Re: [PATCH v6] zswap: memcontrol: implement zswap writeback disabling To: Johannes Weiner Cc: Chris Li , 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 , 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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 12 Dec 2023 13:36:52 -0800 (PST) On Fri, Dec 8, 2023 at 7:42=E2=80=AFPM Johannes Weiner = wrote: > > On Fri, Dec 08, 2023 at 03:55:59PM -0800, Chris Li wrote: > > 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 S= SD > > 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. > > We use regular swap on SSD without zswap just fine. Of course it's > expressible. > > On dedicated systems, zswap is disabled in sysfs. On shared hosts > where it's determined based on which workload is scheduled, zswap is > generally enabled through sysfs, and individual cgroup access is > controlled via memory.zswap.max - which is what this knob is for. > > This is analogous to enabling swap globally, and then opting > individual cgroups in and out with memory.swap.max. > > So this usecase is very much already supported, and it's expressed in > a way that's pretty natural for how cgroups express access and lack of > access to certain resources. > > I don't see how memory.swap.type or memory.swap.tiers would improve > this in any way. On the contrary, it would overlap and conflict with > existing controls to manage swap and zswap on a per-cgroup basis. > > > 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.co= m/ > > +Kairui > > Multiple swap devices for round robin or with different priorities > aren't new, they have been supported for a very, very long time. So > far nobody has proposed to control the exact behavior on a per-cgroup > basis, and I didn't see anybody in this thread asking for it either. > > So I don't see how this counts as an obvious and automatic usecase for > memory.swap.tiers. > > > 3) Android has some fancy swap ideas led by those patches. > > https://lore.kernel.org/linux-mm/20230710221659.2473460-1-minchan@kerne= l.org/ > > It got shot down due to removal of frontswap. But the usage case and > > product requirement is there. > > +Minchan > > This looks like an optimization for zram to bypass the block layer and > hook directly into the swap code. Correct me if I'm wrong, but this > doesn't appear to have anything to do with per-cgroup backend control. > > > > zswap.writeback is a more urgent need, and does not prevent swap.tier= s > > > if we do decide to implement it. > > > > I respect that urgent need, that is why I Ack on the V5 path, under > > the understanding that this zswap.writeback is not carved into stones. > > When a better interface comes alone, that interface can be obsolete. > > Frankly speaking I would much prefer not introducing the cgroup API > > which will be obsolete soon. > > > > If you think zswap.writeback is not removable when another better > > alternative is available, please voice it now. > > > > If you squash my minimal memory.swap.tiers patch, it will also address > > your urgent need for merging the "zswap.writeback", no? > > We can always deprecate ABI if something better comes along. > > However, it's quite bold to claim that memory.swap.tiers is the best > way to implement backend control on a per-cgroup basis, and that it'll > definitely be needed in the future. You might see this as a foregone > conclusion, but I very much doubt this. > > Even if such a file were to show up, I'm not convinced it should even > include zswap as one of the tiers. Zswap isn't a regular swap backend, > it doesn't show up in /proc/swaps, it can't be a second tier, the way > it interacts with its backend file is very different than how two > swapfiles of different priorities interact with each other, it's > already controllable with memory.zswap.max, etc. This is honestly the thing I was originally most iffy about :) zswap is architecturally and semantically separate from other swap options. It gets really confusing to lump it as part of the swap tiers. > > I'm open to discussing usecases and proposals for more fine-grained > per-cgroup backend control. We've had discussions about per-cgroup > swapfiles in the past. Cgroup parameters for swapon are another > thought. There are several options and many considerations. The > memory.swap.tiers idea is the newest, has probably had the least > amount of discussion among them, and looks the least convincing to me. Definitely. zswap.writeback is a really concrete feature, with immediate use-case, whereas swap.tiers seem a bit nebulous to me now, the more we discuss it. I'm not against the inclusion of something along its line though, and I'm definitely not trying to limit the use case of other folks - I'd be happy to contribute my engineering hours towards the discussion of the multi-tier swapping design (both internal implementation and and public interface), as well as actual code, when that design is fully fleshed out :) > > Let's work out the requirements first. > > The "conflict" with memory.zswap.writeback is a red herring - it's no > more of a conflict than setting memory.swap.tiers to "zswap" or "all" > and then setting memory.zswap.max or memory.swap.max to 0. Yup. > > So the notion that we have to rush in a minimal version of a MUCH > bigger concept, just to support zswap writeback disabling is > misguided. And then hope that this format works as the concept evolves > and real usecases materialize... There is no reason to take that risk.