Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1808887rdb; Sun, 19 Nov 2023 11:09:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGCiPlw7RuRgzQJlJu5vlTXKCWmZD5s7O7V1GxqBa/hYvAX42IKGSzFULMBHiXgfnLf+GNP X-Received: by 2002:a17:90b:3149:b0:280:2406:7021 with SMTP id ip9-20020a17090b314900b0028024067021mr5576000pjb.35.1700420950498; Sun, 19 Nov 2023 11:09:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700420950; cv=none; d=google.com; s=arc-20160816; b=mlcbgwyKYujGxpWuZbY1Hx99/Mh0Uucpg5tvD9sCd8vnSmSasTPtriSAhk178EOQR1 Wx08hLcGC0P72dZALzgYMbtypvW0NywKYJUa40h4LBmcH46NXVZTRNx6dyd6/HvyWSXf NyqLxRfEGltxHkwbzYq7MwNvGNPtJVssWUuKTZNIl7dncGrJyIbN3xWZESnJwCWyfp4D a1m0sdL/Gg36Om4aYh8X6Z18cgK3IOXlJRLVFaS5SqZHVZHvzNTRoPH2Zr/14mfXy8bN QEGKmwlaX3EpdYihu+4oShWVQpVU50Sh+/eyec+0eYzl7bCIfyT6BqJPvwdYLdqmo7kn eqIw== 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=wQzML+5J+6LxzG9Fex5fRKa0VePfb5Ddx26BaYmrHCA=; fh=vEONM0p04E5f97au0NULvpBa9ihqN9PKzxzqQeRWRos=; b=oeOjz6eJ4VHAeRyOLYS5S5MkvMo/ZCt4Euj+n5tyKK7hm+I6f+mMR6/cIShNBMqLvV diQ1egMpaHcqJz7wZHoQqAcIjgCbNu7z8qJjFul9wAdMX1n/IhYbNcbnpJUOXnOgjnJk KJfN44tcbI47XJcJ5apEtkIR3UwKyt6oL00625pKFzG89m5PDjKGrto9nekZjzk8Lg7t VRiVnpycjQlEop2hkH3i8Y3URTx3mJ/3cWfMnyZBE6PlWe4kwK561S8hZRQiWXWQSnUn 7Fl/xo2AqsEzgJCzV9ZtkpW1nzmxiEu9UU/zSnDuEu8nU9Lr2EBoGYia6Ahq25881ynF mGHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PZvhQO1N; 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 w28-20020a63161c000000b00584ca25959csi6536323pgl.540.2023.11.19.11.09.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 11:09:10 -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=PZvhQO1N; 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 DD01E8058B5F; Sun, 19 Nov 2023 11:09:07 -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 S229694AbjKSTI5 (ORCPT + 99 others); Sun, 19 Nov 2023 14:08:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbjKSTI4 (ORCPT ); Sun, 19 Nov 2023 14:08:56 -0500 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7CC0F2; Sun, 19 Nov 2023 11:08:52 -0800 (PST) Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-7a93b7fedb8so118728539f.3; Sun, 19 Nov 2023 11:08:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700420932; x=1701025732; 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=wQzML+5J+6LxzG9Fex5fRKa0VePfb5Ddx26BaYmrHCA=; b=PZvhQO1NHKeMwZsF5gZZTrCOtkpAWUAOtJ9ueIvVjR2KWg7+NZ+yCedcS81lbq9xNC jnzkY9ZcQ887o609P8J+9EZH+/XwNWjMR+DJV4d3CBix398tvNeI+dk7tsWfWK0sLDaz Z2A6vSqJukQfLUxouoCobzOAXnWijXsYuuUXto6/vYcFIixYmIor408lXWW3/KfjvAxj ezefHuPQdNHPwrs+/2rUUaUn8wWbAqvn+ETL0QBORDVvpiGTTmKhWIpsYm2KldOdN7S0 2qJQ+TP1RRocCAEHTyAWTavU6Ht6aIf/c6WWlK8wkxt9rl2iXv1kgrRtushMiY1QoL57 Cv2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700420932; x=1701025732; 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=wQzML+5J+6LxzG9Fex5fRKa0VePfb5Ddx26BaYmrHCA=; b=SniWhIwskc+DTLO0xmKeZz9jLTGA11YCe9LlxEbUnWYKMpVpNXEMsTij5883bw4vR7 Q2gFrsLyTM0hq4yJSZ9TaKxdssVSpcxM76LMSOLR0PqSVonXO7Uh/jYwPQ9E/3a17cyu lOFvA8y3BaGZAu6+GCbIqXTl2xHmfLztyUwtHoRkWDZvbUmXpIsmnK4rlSOECSZJD7h3 pL1AwL1FLKpR1j9n8z2yyukvt+UPmHEaQH3c7ME21vdFbOh6gjmRfg0D9K61AkjJc6Ro 3tqYNLHUuZNZMNnXp7F7krwWfaOFGiy7qrWNTv6iVhwwoV9siCrq14bTf4QT+1bwatmc jodw== X-Gm-Message-State: AOJu0YwNuk9MlgwtwaZ9lLvoLByeqN6fWXukYBWu7BLXNNMJSSfQ16Ju /ACrTwR+ySu7raKc1EWL9YcRw+9rCMyQFTjvvDM= X-Received: by 2002:a05:6602:3145:b0:7a2:dee5:84b6 with SMTP id m5-20020a056602314500b007a2dee584b6mr5948252ioy.21.1700420932030; Sun, 19 Nov 2023 11:08:52 -0800 (PST) MIME-Version: 1.0 References: <20231115172344.4155593-1-nphamcs@gmail.com> In-Reply-To: From: Nhat Pham Date: Sun, 19 Nov 2023 11:08:40 -0800 Message-ID: Subject: Re: [PATCH v5] zswap: memcontrol: implement zswap writeback disabling To: Chris Li 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-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]); Sun, 19 Nov 2023 11:09:08 -0800 (PST) On Sun, Nov 19, 2023 at 1:39=E2=80=AFAM Chris Li wrote: > > On Sat, Nov 18, 2023 at 11:23=E2=80=AFAM Nhat Pham wr= ote: > > > > 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 eac= h > > 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. I'm a bit weary about API changes, especially changes that affect backward compatibility. Breaking existing userspace programs simply with a kernel upgrade does not sound very nice to me. (although I've heard that the eventual plan is to deprecate cgroupv1 - not sure how that is gonna proceed). Hence my attempt at creating something that can both serve the current use case, while still remaining (fairly) extensible for future ideas. > > 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. swap.tiers =3D=3D "none" or "disabled" means disallowing zswap as well, correct? > > "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 I don't have any major argument against this. It just seems a bit heavyweight for what we need at the moment (only disabling swap-to-disk usage). I'll let other people weigh in about this of course. Johannes, how do you feel about this proposed API? > > That would define two custom tiers. "ssd" can use zswap then /dev/nvme01p= 4. > 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 h= ere. > 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-usa= ble. > I'm less concerned about internals - that is always up to changes. I'm a bit more concerned with the API we're exposing to the users. > 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 This is a fair point. > > Chris