From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E9D4C5ACB3 for ; Sun, 19 Nov 2023 09:39:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B272D6B015E; Sun, 19 Nov 2023 04:39:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AB0396B02A5; Sun, 19 Nov 2023 04:39:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 951066B03BE; Sun, 19 Nov 2023 04:39:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7E07C6B015E for ; Sun, 19 Nov 2023 04:39:47 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 54ED3A02F6 for ; Sun, 19 Nov 2023 09:39:47 +0000 (UTC) X-FDA: 81474206814.26.FE418E8 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf03.hostedemail.com (Postfix) with ESMTP id CA9B420008 for ; Sun, 19 Nov 2023 09:39:44 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=t2zyPFTp; spf=pass (imf03.hostedemail.com: domain of chrisl@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=chrisl@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700386785; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=aCW4SVJ+cIdlSq8fknB4EDGZdRnZrMiXMw7O8fIkAzM=; b=NAn1TXdrx76oHWL9MTV5jtoiBZ6AqBxfwBoVg+7Z4hAZh04UAq8XP+yeo6/90yivzWbeb6 JR4k3reHCn0XL6hdp/XvDvOD6WVwCwDM//ne3UefhT8Xu31YLbovuj/JEf3Pfny1CAgyjD KgOJzdhyYL+uYxgrL51yvTDtsV9DVPM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700386785; a=rsa-sha256; cv=none; b=KvTw8ug4cVGFBxHm+VBeCgJKwFjYRDxVFogyh7OHNqygtgJPyvy1mhhZXTog+JuPhMr5tS HWHZwBemrmqjyEOQvDnTaZfS0XV+IyUNbfIRHgZQ5E+6124QJCFroVnZPmE3jQ2rkhOMwW kRLsyFIoT3PsYURD7MN5whXdO2JHrVw= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=t2zyPFTp; spf=pass (imf03.hostedemail.com: domain of chrisl@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=chrisl@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 5E939CE0B53 for ; Sun, 19 Nov 2023 09:39:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1046C433D9 for ; Sun, 19 Nov 2023 09:39:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700386778; bh=1H3PX+IaX0IE7nBiCSB6MDB9bd00MwQRqkdTv+DsTGo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=t2zyPFTpjXh/6vARsA3UNuP/BAY0oYM5K9Gb5HIo93RSGyTFoBf5gcZc8eTAmrrOA lpQ5dn8gDNgCCryY441hFoxP9AUyxbDpFh2d7Q0J6PG7JkSfFRTKvX3ttPI0lFvZNq mXn1u91IWinQJ6jQg6OA20PkNPS7Kegdqy98DpGId9aK8jPFyFUOcSf6+EVCTYlT4i y5QhIz9wvbtF3CFWxe7oBP3yJxAVSo/FJFHIFuDAtieJOY7LG6z/7xuvyyIMuFMN9/ p7p6FgROOKKXi9uOHiTzuMSfeqDf4K6W/e/j5AG3oZUdeJsg0+6z3VkSvYs7KLj4+o 92Df9W+SAHNww== Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-5bde80aad05so2768059a12.2 for ; Sun, 19 Nov 2023 01:39:38 -0800 (PST) X-Gm-Message-State: AOJu0YzGQ3pQ5gigya6sSJZqtq86XZSwEkmeJLYwXXTxjIBmILlFxaos QZaAZpGLDmqZw/Q1piHqa+JuATh5tw5lXFs4W5SKdQ== X-Google-Smtp-Source: AGHT+IG7ALAXFRt0rSRdXIIOwPxSiyJfQXJRU2wOroVNeGeY/g6Ptf7fNUnIyT383O0M8tozXwhmekS00d5nM2Nnbic= X-Received: by 2002:a05:6a20:1612:b0:187:cf88:1a34 with SMTP id l18-20020a056a20161200b00187cf881a34mr5758611pzj.8.1700386778223; Sun, 19 Nov 2023 01:39:38 -0800 (PST) MIME-Version: 1.0 References: <20231115172344.4155593-1-nphamcs@gmail.com> In-Reply-To: From: Chris Li Date: Sun, 19 Nov 2023 01:39:26 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5] zswap: memcontrol: implement zswap writeback disabling To: Nhat Pham Cc: Yosry Ahmed , Andrew Morton , tj@kernel.org, lizefan.x@bytedance.com, Johannes Weiner , Domenico Cerasuolo , Seth Jennings , Dan Streetman , Vitaly Wool , mhocko@kernel.org, roman.gushchin@linux.dev, Shakeel Butt , muchun.song@linux.dev, Hugh Dickins , corbet@lwn.net, Konrad Rzeszutek Wilk , senozhatsky@chromium.org, rppt@kernel.org, linux-mm , kernel-team@meta.com, LKML , linux-doc@vger.kernel.org, david@ixit.cz Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: CA9B420008 X-Rspam-User: X-Stat-Signature: axgfyujo5znysr854jtxtqxq8c9kijb7 X-Rspamd-Server: rspam03 X-HE-Tag: 1700386784-256759 X-HE-Meta: U2FsdGVkX18yKUWksJ+VKIZsjME9MY7E3bzgoWfGDcsgGZElteSiQmbm0UjNAJkRGkBRBd/8RZHbSIKAlRjPH2/U0c3+pX33ITX7wnLvRJ3sxfLrH+zeP6bsVsLoTDmKOrq9WWxLJpZTB1syQ+eiJBsOdNUzUgGIELjXIeubVuYB4gw3ZjdGDzxAvJhSyu4QvhI32TJcAVlVznlTdqDOzC625qPp8RaLQy0n7lKevYLNW5ggyNVcQN9aYrj4GwZR/KMDD2aNOtTpny5pKA4TvWzUPDu3U92vBeJR+Uf6NVAi1GWtXx4LycPUtsCfsHgyy0YcWapyYIRBoNgWGQjvXLyajO0DKO5Lnj9BspFU/Z01OXk2+qvUewJ5l5/LKntIrtJr2z2LiQj1Pjh+Ntn5YgqYkH20/BkVSuQP/NLVJiE97JC6RQCg1vBC73/rEejAhQlFeYNCob6KPSOnLhFL8CF41r+g38WiN3i6LY7pHAbClMqiKZXUDp7/VARoGbXoXVMOxExMPfCrmugfKgsjxEIZTSkB5mU4GY60mLUDhqTSOjqczfyY18oJYwhcVArgoJ11PgC30kG7oROEK5KH21qTVhkXCjCKLLt9Ox1byAqfhFxmngLtQ30ssAMn96JhYWTNdCkWGzeuymorNZP9K6ExOELyTW5eDOyR0lSLU4pBqOLMn5cIQXlm45O4jDWCFbbA0o5WYS01hz2nVxKn/4wM5ITKzRnemBY5NqnhHBU858VQbiqcYyON8Rv/9VtzcgkyYW1MC1kq1wfmKlyhLrtCRV7hxZfeIm02RginT5+azB997HgvFTx/7w1Lc58jiLTb2JxHxENClkRyHhw1qQxKdo/ihRLxRjV4OWdk545lSlX2u9VawMeSYwCKd3TxNTxbYwpVmq+Eo4zM+bag4E8CI4J7bYaoPQxVu17+7uaoYuUskuZf54t7w7Yo+aYkHnudLcP9HgFRJeP3ID3 wWE4PgKF cW3tkWJ1IoL9l6QCl2dQmy5ZjfeCDx+1LoFNu02BbrcjQ+SYkR5PcSlFenSu0qGWVE2cLj5x7yfIQsJAx0VPdkVxiXba4FoN20ZiZtPzD8VA6oZ/3ygkjaPhrDwcmA7zz0HV/sIQQzdqz48ZiATG+60RdWfApXiAc77W7BoJa+wTlSpEpC0EX33/wz3G8kqx8KCtZC2Ix1XmzN74NuSjFLE2jxaq+oynYccpbpuFfPJnh1rhmUCoYFMlGZw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Sat, Nov 18, 2023 at 11:23=E2=80=AFAM Nhat Pham wrot= e: > > Hmm how about this - in the future, we support the following > options: > > 1. zswap.writeback =3D=3D 1: no limitation to zswap writeback. > All backing swap devices (sorted by priorities?) are fair game. > > 2. zswap.writeback =3D=3D 0: disable all forms of zswap writeback. > > 3. zswap.writeback =3D=3D : attempt to write to each > tier, one at a time. We can merge the zswap.writeback as it is for now to unblock you. For the future. I think we should remove zswap.writeback completely. Instead we have: swap.tiers =3D=3D swap.tiers =3D=3D "all" all available swap tiers. "zswap + swap file". This is the default. swap.tiers =3D=3D "zswap" zswap only, no other swap file. Internally set zswap.writeback =3D 0 swap.tiers =3D=3D "foo" foo is a list of swap devices it can use. You can define your town custom swap tier list in swap.tiers =3D=3D "none" or "disabled" Not allowed to swap. "all", "zswap", "none" are reserved keywords. "foo", "bar" etc are custom lists of swap tiers. User define custom tier list in sys/kernel/mm/swap/tiers: ssd:zswap,/dev/nvme01p4 hdd:/dev/sda4,/dev/sdb4 That would define two custom tiers. "ssd" can use zswap then /dev/nvme01p4. The exact name of the "swap.tiers" and tiers name are open to suggestions. > > The first two are basically what we have for this patch. > The last one will be added in a future patch. > > This is from the userspace perspective. Internally, we can modify > memcg->writeback to be a pointer or a struct instead of this bool. > (as you suggested). Internally I would suggest memcg->swaptiers, the write back name is somewhat confusing. As your patch indicated. It has two situation: 1. shrinking from zpool to real swapfile. The write back is appropriate her= e. 2. zswap store failed (compression ratio too low, out of memory etc). The write back is confusing here. It is more like writing through or skip. > > This way, the API remains intact and backward compatible > (and FWIW, I think there are still a lot of values in having simple > options for the users who have simple memory hierarchies). swap.tiers can be simple. For example, you can modify your patch to "swap.tires =3D=3D zswap" to set zswap.writeback bool to 0 for now. Most of your patch is still re-usabl= e. I think we should discuss if we want to keep zswap.writeback in the future because that would be some code undeletable and functionally overlap with swap.tiers Chris