Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp114853rdf; Thu, 2 Nov 2023 15:41:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG1/W7yxf/IPKnhaGBUKz1TFxbPaYpxnA7qxATYYRVUxYl9Ls6o9uD1FDhjIvlcMBcNV9fV X-Received: by 2002:a05:6a20:9390:b0:159:e4ab:15ce with SMTP id x16-20020a056a20939000b00159e4ab15cemr1542125pzh.15.1698964889696; Thu, 02 Nov 2023 15:41:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698964889; cv=none; d=google.com; s=arc-20160816; b=VBrM2IyAcFVz+5bF/grWzd5gXRQJqenuddVbWJMV60sm9X1GlvzNoXcmbozlQE5eGF u+3WV5wmS+5imdN1xVUmHcnvTXs8upOzFSv8L5bBovA3v3wZfVi9lNbmfZoJXRJjOtrE CvLmcLiqY1FMiUtkz+WSRXOIMxup/qcFH6q6ly06yzk2GsZ2ZyzRR3au2Z8SMxjxODml 2/yd+rS/tnDn8V2wr0wmFbIA3tMAx5rqv9BgR/YYYHTHhsH2qr2Fx+Wq8w5Yg3t2DRvr QMm2nGidc1La6AnsAs7aU7Hz9Ypff3X3YjLnSQms5e7qH8anHvARF8rL0U3aYjZpnleJ 6dHA== 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=Qc8asfYOeO/AOwc/brrfBGOOvr6zT/uDTRraWYt21O4=; fh=h1lohKeKPxxMxx/45UM5cgKdzE9Q6SXAVF1QF5ggjuU=; b=gy+S+hNdrCriPXV9WotDjBdyhNiUPCkkBakMcNIPdindate9wbuPqcEgWY24kWcXwg iYDU0/LFt0ONfut/m7uPQ+qqWkqQjAOgop2pGn7eTNqEjJG7+85SW8p/2KAhpZnKre/R 3Uqx0VyZELUtL5ndAY9CKD1y0PTcsO2RjWX9UTmENdHqhXTQ+tn4UKl9AmndhoU1PYSS FTKMMtCtMinjxWaPOhG2yiZT+MNShn/sb67tp+B4XMCKXwolZQql0rB9fhfqXjhyqIFR FSV8UyjGmpxkitZmJkjcD+cMvYjOe628xSwUNLZxb79s0z2GkgaxMkuaLhjouj6pQQAM Ssuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YFdqAowQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id bk13-20020a056a02028d00b005bce484bff8si371050pgb.647.2023.11.02.15.41.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 15:41:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YFdqAowQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 001DC808A352; Thu, 2 Nov 2023 15:40:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377512AbjKBWkc (ORCPT + 99 others); Thu, 2 Nov 2023 18:40:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229675AbjKBWkb (ORCPT ); Thu, 2 Nov 2023 18:40:31 -0400 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10AD7B7; Thu, 2 Nov 2023 15:40:29 -0700 (PDT) Received: by mail-il1-x12d.google.com with SMTP id e9e14a558f8ab-3594c100735so4419275ab.1; Thu, 02 Nov 2023 15:40:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698964828; x=1699569628; 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=Qc8asfYOeO/AOwc/brrfBGOOvr6zT/uDTRraWYt21O4=; b=YFdqAowQLwabt2w2zzPeDWLSwP0gaJFysRShrtpeiElZUZDmjEyojza/kijnCjEGdG gqJCL+z48Jc9fdonjD83jaAEUXQrCRAph7e7m/Zdg/saOn+zUBPzd1MyceFw/DzLAn/n YLrTCHU80l9z4ELEehIOOXD8j8IlQS0fHEJJx3KfcUd56fulDkOzwRxkc87qe21ksxUp KvNiGPILeLqzSP0GOb3cFcWkWCrGRlTZljGtu2XKYS8ccwoTT8OHPlYvfzRcqdMfa6Ot 7ZGQDE8tdG3uGbZ1U+W7/0vMlMz5+8c/3PRNitMwUcTU+mEPK1hqneae1xwqzPgju9RE UO+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698964828; x=1699569628; 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=Qc8asfYOeO/AOwc/brrfBGOOvr6zT/uDTRraWYt21O4=; b=tGjtZ7VHXOP0Niwq/GOmgLLmjbMDbeMvsUiakbsFOp9ktv7WLcR/yw04OuoS1itesw Q9L01yAqMfDLtb5H2H+no98PiWpRjjNAHk5/gh9vw7e4yMtLj0RNmqlHZrRmMejtUXEN beF65feuvcfNIhNH9FdoMgPX45jvWKtxr6OQYCw4jyqk7b4VRBVANaTBkdRMySP3lAFd 4Dwpqhpc8W+RiBRErZ6najSz/m4Roj60DY2ikEDbyJKKeUizu6/ncYcnEnjoMswJ4e7A b2Kxb6onmRE+3GxodfHnJefQa/+JwYGBuNmKoOOPUuFP01SEc9bYAI0IJdIZHzm/7BfX 5C5Q== X-Gm-Message-State: AOJu0YxBmicHXPFqkErHYaXfGlytN5aqcfeqTdBlMan5zICrkJVRIf9Q dtH+IvINElNcSaWxHA/zUJoFGWZN1cJ4yKGTttc= X-Received: by 2002:a92:d74b:0:b0:359:3ff:17c6 with SMTP id e11-20020a92d74b000000b0035903ff17c6mr943748ilq.4.1698964828290; Thu, 02 Nov 2023 15:40:28 -0700 (PDT) MIME-Version: 1.0 References: <20231102200202.920461-1-nphamcs@gmail.com> <20231102205022.GA3265934@cmpxchg.org> In-Reply-To: From: Nhat Pham Date: Thu, 2 Nov 2023 15:40:17 -0700 Message-ID: Subject: Re: [RFC PATCH v2] zswap: memcontrol: implement zswap writeback disabling To: Yosry Ahmed Cc: Johannes Weiner , akpm@linux-foundation.org, tj@kernel.org, lizefan.x@bytedance.com, cerasuolodomenico@gmail.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 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 fry.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 (fry.vger.email [0.0.0.0]); Thu, 02 Nov 2023 15:40:42 -0700 (PDT) On Thu, Nov 2, 2023 at 1:54=E2=80=AFPM Yosry Ahmed = wrote: > > On Thu, Nov 2, 2023 at 1:50=E2=80=AFPM Johannes Weiner wrote: > > > > On Thu, Nov 02, 2023 at 01:27:24PM -0700, Yosry Ahmed wrote: > > > On Thu, Nov 2, 2023 at 1:02=E2=80=AFPM Nhat Pham = wrote: > > > > @@ -201,6 +201,12 @@ int swap_writepage(struct page *page, struct w= riteback_control *wbc) > > > > folio_end_writeback(folio); > > > > return 0; > > > > } > > > > + > > > > + if (!mem_cgroup_zswap_writeback_enabled(folio_memcg(folio))= ) { > > > > + folio_mark_dirty(folio); > > > > + return AOP_WRITEPAGE_ACTIVATE; > > > > + } > > > > + > > > > > > I am not a fan of this, because it will disable using disk swap if > > > "zswap_writeback" is disabled, even if zswap is disabled or the page > > > was never in zswap. The term zswap_writeback makes no sense here tbh. > > > > > > I am still hoping someone else will suggest better semantics, because > > > honestly I can't think of anything. Perhaps something like > > > memory.swap.zswap_only or memory.swap.types which accepts a string > > > (e.g. "zswap"/"all",..). > > > > I had suggested the writeback name. > > > > My thinking was this: from a user pov, the way zswap is presented and > > described, is a fast writeback cache that sits on top of swap. It's > > implemented as this lookaside thing right now, but that's never how it > > was sold. And frankly, that's not how it's expected to work, either. > > > > From the docs: > > > > Zswap is a lightweight compressed cache for swap pages. > > > > Zswap evicts pages from compressed cache on an LRU basis to the > > backing swap device when the compressed pool reaches its size limit. > > > > When zswap is enabled, IO to the swap device is expected to come from > > zswap. Everything else would be a cache failure. There are a few cases > > now where zswap rejects and bypasses to swap. It's not a stretch to > > call them accelerated writeback or writethrough. But also, these > > represent failures and LRU inversions, we're working on fixing them. > > > > So from a user POV it's reasonable to say if I have zswap enabled and > > disable writeback, I don't expect swapfile IO. > > Makes sense (although now you had me thinking whether > memory.zswap.writethrough is a better name). Hmmm I lean towards writeback because it's already used in zswap context. Users not familiar with the writethrough concept might be confused by the naming. > > > > > But yes, if zswap isn't enabled at all, this shouldn't prevent pages > > from going to swap. > > Right, at least mem_cgroup_zswap_writeback_enabled() should always > return true if zswap is disabled. Sure enough! In the next version, I'll always return true in this case. > > One more unrelated thing, I think we should drop the > cgroup_subsys_on_dfl() check there. I understand the interface is only > exposed in v2, but I don't see any reason why it wouldn't work in v1. > Let's not make it harder for anyone who tries to expose this in v1 > (whether upstream or in an internal patch). I don't have anything against cgroup v1 per se :) I just happened to notice that zswap charging is not available in v1, so I just played it safe here. If nobody objects I can unguard this feature from v1. Seems reasonable to me tbh.