Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3251967rdg; Tue, 17 Oct 2023 08:52:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFcufVnNlDJ9KpNp/SHWIEdhRCKTRO2a3grly9/G9wvTRbu7rPc4rP2QEk9JUQfJxZmud4A X-Received: by 2002:a17:902:e551:b0:1ca:8e79:53c1 with SMTP id n17-20020a170902e55100b001ca8e7953c1mr2834381plf.13.1697557945905; Tue, 17 Oct 2023 08:52:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697557945; cv=none; d=google.com; s=arc-20160816; b=m+5jT6HgYd3H5PmLFnuSHQaQLkKDfxbqWPn4yy7el5sf+81Q0JtgbOndthMFGIYj3P ooqMGFSzWpPONdxsjZrAYPe11mnKJ836y6YJjXffkqnaobjm1rcqHBuLNsmXcfPpof7e uWDZN/FWypj8BskTV2rurBgLSC0ILX/xV5FTzNWj0nVBHiNOb4xWfW/EVf+SiiXaHk2R hex+jTtHfr6FlsxUbn725p5LhPdpawGas1R5VolkHlH2JQzKK3FpDWsTSqYzEtIiXeQ1 gaXHqwpqCj9LVGddeyz3NiXRl+EyegfA+SezBpcSvBy2FrlBmqekHjbZ8z0lOngMvkyr KSkA== 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=h+Szb6nB1OdOcsJ1SkkUkZWUvsgJwxEYpCHP9bITXYs=; fh=8lJitN7r2Z8KAfNO7Bw0pI+QRzPh5CXZYxF8fer8FYA=; b=ZwVESrrHefyA12elHDnt3HhJ17PtNQn9R1AlRqZhJMEl9ajHE9OOxZSTuHFzq6MTWo k7no6zCC9NebwbamBM7/3Y+yknM7zPUhBF2+Zr7rwZ0/q6nHT9gchYVND/BHhwdr/Zch 798zj0K+8ENoCNujS8AZ4cxQhuddF4W4/eZfvIaopBbEJnSDroZixJJHak++e0IItfvE YTzcO/8ddl7HzTPZmvmgYSlJEd7Rbl87fep0BUxPVbuREIHCVwnrtStiN9hcN90B7G+j tXSowyqOd8CeCp4CasC32xPtd7XCJ57chSMxtE/AJu4jkR4gYm8pXj2GfHJ/es60C0Zb BGKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=n81K1t2o; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id k13-20020a170902760d00b001c0c4be62basi1922840pll.617.2023.10.17.08.52.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 08:52:25 -0700 (PDT) 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=@google.com header.s=20230601 header.b=n81K1t2o; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 0B17580320CC; Tue, 17 Oct 2023 08:52:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344121AbjJQPwG (ORCPT + 99 others); Tue, 17 Oct 2023 11:52:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343979AbjJQPwF (ORCPT ); Tue, 17 Oct 2023 11:52:05 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE8209E for ; Tue, 17 Oct 2023 08:52:03 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-9a6190af24aso967799166b.0 for ; Tue, 17 Oct 2023 08:52:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697557922; x=1698162722; 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=h+Szb6nB1OdOcsJ1SkkUkZWUvsgJwxEYpCHP9bITXYs=; b=n81K1t2oANRy3fTGZsMLI3lZ+AAxoqGV9gmhTIQHwkj2sVoVfAjUIAOeZvfE491zPO +KGDzkVs+b8l/jqPx3hRxs3BRytRJQD30PIYuis9jwAmpZvMQTPCNBwq3gcYxgAqofzS VieknTV9aPyTCTqNx/1+tnZu7LdfjwhQWa54S0Mm/2QweW2NW81kOvVgD9lgsW/pCqCh w28872Xkc1Nn2weN6IHPhi4cEbzmJAt6P5ilazEaQd5qUNW9rLyg+38C20zzGLzyp3um vlGk+QK2AGfZ/flP38c0j6ZNk9t3gzBxaNEkKtU2qU47YR/Q3ie9nSGrdxkeU0f1N847 PUQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697557922; x=1698162722; 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=h+Szb6nB1OdOcsJ1SkkUkZWUvsgJwxEYpCHP9bITXYs=; b=iOqWo/7Mnhg6dKz8zIJ65wP29OIowthe4wnYeaZ+Q4wJEODHuEJZldeaSaL+TSPPyT m1YQ70GhbSRzbSMndjNKnOc/IiQ0HMrWhhFuRy6YT/+NQy8GDmGv1K/zpcw7z9SMGPPQ Sv8MDqW5Ya91o8fKL9bET4+Oq/p2i+bbTPW/Gz+rmf7V8uKr67ewpAGckVF4YaKJl5Gl ixh9fMeazHPfnDK3GzeTLr3ZDTPPhtzJB4LonoAvI+Zyc141VbarYpdWOSEO3oA7v6UB deQIR+1bii8H9zben5vuxLVSH4MCiD8ciQzYo9hRw/p/qNdDuetKj/VX6l9jMG5RleR+ ev2w== X-Gm-Message-State: AOJu0Yzz+D2VSSBfmTLWKzH8TBrelgVh/nCTRFT39JplYh4mXCAQ/Vj4 p/puTQ08Mdcorq7/lIqG/H9azH99PGMOq4MxyoQGVw== X-Received: by 2002:a17:907:1c24:b0:9be:68db:b763 with SMTP id nc36-20020a1709071c2400b009be68dbb763mr2141954ejc.71.1697557921772; Tue, 17 Oct 2023 08:52:01 -0700 (PDT) MIME-Version: 1.0 References: <20231017003519.1426574-1-nphamcs@gmail.com> <20231017044745.GC1042487@cmpxchg.org> <20231017145124.GA1122010@cmpxchg.org> In-Reply-To: <20231017145124.GA1122010@cmpxchg.org> From: Yosry Ahmed Date: Tue, 17 Oct 2023 08:51:25 -0700 Message-ID: Subject: Re: [PATCH 0/2] minimize swapping on zswap store failure To: Johannes Weiner Cc: Nhat Pham , akpm@linux-foundation.org, cerasuolodomenico@gmail.com, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com, 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, david@ixit.cz, Wei Xu , Chris Li , Greg Thelen Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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, 17 Oct 2023 08:52:22 -0700 (PDT) On Tue, Oct 17, 2023 at 7:51=E2=80=AFAM Johannes Weiner wrote: > > On Mon, Oct 16, 2023 at 10:33:23PM -0700, Yosry Ahmed wrote: > > On Mon, Oct 16, 2023 at 9:47=E2=80=AFPM Johannes Weiner wrote: > > > On Mon, Oct 16, 2023 at 05:57:31PM -0700, Yosry Ahmed wrote: > > > > On Mon, Oct 16, 2023 at 5:35=E2=80=AFPM Nhat Pham wrote: > > > So I obviously agree that we still need to invest in decoupling zswap > > > space from physical disk slots. It's insanely wasteful, especially > > > with larger memory capacities. But while it would be a fantastic > > > optimization, I don't see how it would be an automatic solution to th= e > > > problem that inspired this proposal. > > > > Well, in my head, I imagine such a world where we have multiple > > separate swapping backends with cgroup knob(s) that control what > > backends are allowed for each cgroup. A zswap-is-terminal knob is > > hacky-ish way of doing that where the backends are only zswap and disk > > swap. > > "I want compression" vs "I want disk offloading" is a more reasonable > question to ask at the cgroup level. We've had historically a variety > of swap configurations across the fleet. E.g. it's a lot easier to add > another swapfile than it is to grow an existing one at runtime. In > other cases, one storage config might have one swapfile, another > machine model might want to spread it out over multiple disks etc. > > This doesn't matter much with ghost files. But with conventional > swapfiles this requires an unnecessary awareness of the backend > topology in order to express container policy. That's no bueno. Oh I didn't mean that cgroups would designate specific swapfiles, but rather swapping backends, which would be "zswap" or "disk" or both in this case. I just imagined an interface that is more generic and extensible rather than a specific zswap-is-terminal knob. > > > > > Perhaps there is a way we can do this without allocating a zswap en= try? > > > > > > > > I thought before about having a special list_head that allows us to > > > > use the lower bits of the pointers as markers, similar to the xarra= y. > > > > The markers can be used to place different objects on the same list= . > > > > We can have a list that is a mixture of struct page and struct > > > > zswap_entry. I never pursued this idea, and I am sure someone will > > > > scream at me for suggesting it. Maybe there is a less convoluted wa= y > > > > to keep the LRU ordering intact without allocating memory on the > > > > reclaim path. > > > > > > That should work. Once zswap has exclusive control over the page, it > > > is free to muck with its lru linkage. A lower bit tag on the next or > > > prev pointer should suffice to distinguish between struct page and > > > struct zswap_entry when pulling stuff from the list. > > > > Right. > > > > We handle incompressible memory internally in a different way, we put > > them back on the unevictable list with an incompressible page flag. > > This achieves a similar effect. > > It doesn't. We want those incompressible pages to continue aging > alongside their compressible peers, and eventually get written back to > disk with them. Sorry I wasn't clear, I was talking about the case where zswap is terminal. When zswap is not, in our approach we just skip zswap for incompressible pages and write them directly to disk. Aging them on the LRU is probably the better approach here. For the case where zswap is terminal, making them unevictable incurs less page faults, at least for shmem.