Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2126682rdd; Thu, 11 Jan 2024 23:09:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGcuaNgaX3LWeMNMlfw61BKLRYFyDjVnegUKTfpLQFfzE3ohKYfMsKtDR2nwkcUshqVWiwI X-Received: by 2002:a17:906:d81:b0:a28:fd27:8f64 with SMTP id m1-20020a1709060d8100b00a28fd278f64mr393715eji.1.1705043361927; Thu, 11 Jan 2024 23:09:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705043361; cv=none; d=google.com; s=arc-20160816; b=zr4X5qwsPWUrQiQNmbg3mxfAgGMhkislkJa8f45Ebl2TZeZ6GEAhIxTXCRJaX+c239 OLh5wtsFQE2Vx3BI1E+BzSMDnik6JigyBXAw6vPOc+fBAEPy1qHy7U6X1gorUuD99CM5 7CNRDuZ3z27uaTlDLxN9cCXFrretM2gAXRBjZLgNefA/s3uspjGKEJ7EgqAkUlg/IAIi sY+gA3gSpnrPgLW9FIJkMLV5MyL/YrgzETe93kZnLUZ9+MX6Cd08PpOZoqLu2wIupKJG JgsLmEBbD/30y+VgfSQJciE0h5JZZ8lMCqMFUdoDRZHuklsWakF9a+IBTq6uf4tcTKlN mHvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=d2axIAZPMzrhQEXZe+OtGDs+tak3gwoRFY7MWaUZjPE=; fh=79FixaCLlUWJ+SKvf0t1L2VfDRzOaynk93MHFN+YZls=; b=yjYE3+503+teYLxS3onEoPi3y+7Gl5stWt2+Xb3YD+gcttyRfUI0sxMenPHDNSkB8F c87Q7iBN6ywc7QAklhUnenu8KaLAb5avtweqVGI4HXGIs/Z9iAf7aKPmGoRBJKL8Id9X 4X+nRKg4lWEbqlSUxoaPdc9nHrWPOk+vDjX7Kk0X6uha0DI+c40PsML5nxv7mC2nPg79 x3HxtIH9W0zA4gQTYaeQqCFB0ZKUrzrdswVJHd2fIA5Yik/36z0b3YBzi/J7tXhDE7aF SJ5LQ0yod1jliSTzOFJA87RjRUoEIqG1xHK41OpYmqaobRK8oR+Xd6OFrn9CRIm9kv6B r90g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=gwDTPXA0; spf=pass (google.com: domain of linux-kernel+bounces-24353-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24353-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id me21-20020a170906aed500b00a277335cec7si1175676ejb.570.2024.01.11.23.09.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 23:09:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24353-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=gwDTPXA0; spf=pass (google.com: domain of linux-kernel+bounces-24353-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24353-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7C21F1F2584B for ; Fri, 12 Jan 2024 07:09:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7C61E5C903; Fri, 12 Jan 2024 07:09:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="gwDTPXA0" Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A91C381B7 for ; Fri, 12 Jan 2024 07:09:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-50e78f1f41fso6488387e87.2 for ; Thu, 11 Jan 2024 23:09:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1705043348; x=1705648148; 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=d2axIAZPMzrhQEXZe+OtGDs+tak3gwoRFY7MWaUZjPE=; b=gwDTPXA0XNHWuCTr4lrRjuH+H++qCt2HOG8w4waSsA/kp/l6/mX89orijCSRPM45tD 2oNryQe2FaCNOI/8QZFPlyZL3vSYsSVU6NonwkDximFyh/HdR5QH1xP8z8XIlVAme9ji 4JeownQokalfANRa/eoxva1myYLpEDiTPgraPkGnzyI4ZuoDMnchhUElB/mtUEMHx9UB y++M0pwhShEPxF0guKsVKQD5YUY0iZM0MmiJdgLl4ocZPcM+wVCKjmahEBy/I3exEa36 SJVqpuMzmUNPYjQ4mfa2mavS1QGbQF9sOHwPZPnFL0Kh6V8m3JWzvUzGbgjVBM+zOwOs knyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705043348; x=1705648148; 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=d2axIAZPMzrhQEXZe+OtGDs+tak3gwoRFY7MWaUZjPE=; b=fmvO0aQO9nZm2jVnL+bGoDEN9nHSjj/a0MTTpXNuktEC9BiKjZ58GUnk1AmcdgrqQ7 6YSpDyjHa2KbZTOhgTHORxpFHql7i71GMZv5dnCoTtJNpAWMDD6T9nipqF9Hsal+venc 5iw9MFzT3fy4uE/oVwrJyNbszB5wIak+Zm8kqY48lBEYspB7541+4fgG5vkS4Ckuk3lM t92qibalb4ZxR+a98d3EHpbWxjZn0b9c8tNo4yKU/efG0bBbJXzKIiuN/HIgbpnV7iRN YO7VY6jmJoCLJ/M9NwuiKtMuZvTVv/OuB1O6GZfN9dfwMjQw3gRAaUf5f3N+jmpj+tKQ cCtA== X-Gm-Message-State: AOJu0YxuuklffnRAoPoMRQsfPh1L0/BwdvfAKxfXAHQC7ysl5+SX6iJQ n9tJV+BXBokzWPJ4aO1z4doDiP/snalkALFj35cqP8oqzkbr5A== X-Received: by 2002:ac2:4c05:0:b0:50e:27a9:167e with SMTP id t5-20020ac24c05000000b0050e27a9167emr348204lfq.59.1705043348345; Thu, 11 Jan 2024 23:09:08 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231024142706.195517-1-hezhongkun.hzk@bytedance.com> In-Reply-To: From: Zhongkun He Date: Fri, 12 Jan 2024 15:08:54 +0800 Message-ID: Subject: Re: [External] Re: [PATCH] mm: zswap: fix the lack of page lru flag in zswap_writeback_entry To: Nhat Pham Cc: Yosry Ahmed , akpm@linux-foundation.org, hannes@cmpxchg.org, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chris Li Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jan 12, 2024 at 3:25=E2=80=AFAM Nhat Pham wrote= : > > On Wed, Jan 10, 2024 at 7:49=E2=80=AFPM Zhongkun He > wrote: > > > > > > > > This sounds dangerous. This is going to introduce a rather large > > > unexpected side effect - we're changing the readahead behavior in a > > > seemingly small zswap optimization. In fact, I'd argue that if we do > > > this, the readahead behavior change will be the "main effect", and th= e > > > zswap-side change would be a "happy consequence". We should run a lot > > > of benchmarking and document the change extensively if we pursue this > > > route. > > > > > > > I agree with the unexpected side effect, and here I need > > to clarify the original intention of this patch.Please see the memory > > offloading steps below. > > > > > > memory zswap(reclaim) memory+swap (writeback) > > 1G 0.5G 1G(tmp memory) + 1G=EF= =BC=88swap=EF=BC=89 > > > > If the decompressed memory cannot be released in time, > > zswap's writeback has great side effects(mostly clod pages). > > On the one hand, the memory space has not been reduced, > > but has increased (from 0.5G->1G). > > At the same time, it is not put the pages to the tail of the lru. > > When the memory is insufficient, other pages will be squeezed out > > and released early. > > With this patch=EF=BC=8C we can put the tmp pages to the tail and recla= im it > > in time when the memory is insufficient or actively reclaimed. > > So I think this patch makes sense and hope it can be fixed with a > > suitable approaches. > > Makes sense to me. IIUC, that's the original intention behind calling > SetPageReclaim() - unfortunately that doesn't work :) And IIRC, your > original attempt shows reduction in swap usage (albeit at the cost of > performance regression), which means we're onto something. I believe > that the folio_lru_add_tail() approach will work :) > > Please include a version of the clarification paragraph above in your > later version to explain the goal of the optimization, along with > suitable benchmark numbers to show the effect (such as minimal change > in performance, and reduction in some metrics). Maybe include the link > to the original patch that introduces SetPageReclaim() too, to show > the motivation behind all of this :) It'd be nice to have all the > contexts readily available, in case we need to revisit this in the > future (as was the case with the SetPageReclaim() here). > OK. > > > > > > > > Unless some page flag/readahead expert can confirm that the first > > > option is safe, my vote is on this option. I mean, it's fairly minima= l > > > codewise, no? Just a bunch of plumbing. We can also keep the other > > > call sites intact if we just rename the old versions - something alon= g > > > the line of: > > > > > > __read_swap_cache_async_head(..., bool add_to_lru_head) > > > { > > > ... > > > if (add_to_lru_head) > > > folio_add_lru(folio) > > > else > > > folio_add_lru_tail(folio); > > > } > > > > > > __read_swap_cache_async(...) > > > { > > > return __read_swap_cache_async_tail(..., true); > > > } > > > > > > A bit boilerplate? Sure. But this seems safer, and I doubt it's *that= * > > > much more work. > > > > > > > Yes=EF=BC=8C agree. I will try it again. > > Look forward to seeing it! Thanks for your patience and for working on th= is. Thanks for your time.