Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1575147rdd; Thu, 11 Jan 2024 03:28:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IGcTFzgrkDKkZqlpCGhTthPTdLJfMLvQWXkHI9c7FZqeel8LYPhJYxYYmYrkTsqz8xTowuf X-Received: by 2002:a17:902:dac1:b0:1d3:993b:3af4 with SMTP id q1-20020a170902dac100b001d3993b3af4mr1242879plx.52.1704972511078; Thu, 11 Jan 2024 03:28:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704972511; cv=none; d=google.com; s=arc-20160816; b=bKlSMigXUg2g99v4WHAgWZpyJwykhwPqc371uRMBTDIen2liTbG2u8WDceM9QHFylR bHsRga3Tv0qDkbE3leTFv90oH5GuclzCTZjsr0uQvvei37bMzPoB546X0G/ILmnw3uMJ nMnvr3G0U65+uFiKwlgrZ8NQf991MuBiar1FdUWvtszs8ciTtJjI1pTx/pfdflccTKJC d0YZvkw3MABKxos+sW0Hkr9+M0mlcnPNOBAtF8ya1wOw60WJI+JKJ2mYRiZTydB99sUR q0+ndvTrJsT2MHQqeejjkRNLvuDo5905DbdjjSmPs4kvWjkbMHitW3w/u1QNllqYSCJr 0ywA== 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=1r4p8EZizALAha2W0BpFV/ugv3SVBdRsaxVwbhdyofU=; fh=tqVH3YUKMvYxCAjufIQwyLAgZMFrBGt9NQmYcNaznIk=; b=JfmuIha8CQ37bEkO09lAidHbo6hsnZ2xvw/SnwwgJe3WOm1sArOBOT9Jhq+bPPaTeN gdXzaRBvXStvTDqaHeOKGBgMW2NMFUdHXB/u4ThyzvkjLHSPgs7PtEqk6GU7uydppLYb XIVBzTo3Eh8rkhYKnmtQlCYnH6Ltr4/YxtlgTWg+WJ2tjyBBrq9YNve6JAEXY5sZMo9P 4pr+zD4bsmbYhWY14ZquYIHBzkPznYLkezO3OFuqkosRvuovUc/U3CkDIqH5aYoeU0re knES3wCjzShmUQcb1QLful8S/wEze+U5UzkzhsG2fCuVU9e7sy/XOSi9oTMD1ax2jxot YgGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=q3jlpGM+; spf=pass (google.com: domain of linux-kernel+bounces-23485-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23485-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id jy13-20020a17090342cd00b001d50870e26bsi880970plb.437.2024.01.11.03.28.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 03:28:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23485-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=q3jlpGM+; spf=pass (google.com: domain of linux-kernel+bounces-23485-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23485-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id BBCD72893FF for ; Thu, 11 Jan 2024 11:28:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 59BA11548F; Thu, 11 Jan 2024 11:28:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="q3jlpGM+" Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (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 F32C014F97 for ; Thu, 11 Jan 2024 11:28:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a2a17f3217aso585256166b.2 for ; Thu, 11 Jan 2024 03:28:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704972502; x=1705577302; 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=1r4p8EZizALAha2W0BpFV/ugv3SVBdRsaxVwbhdyofU=; b=q3jlpGM+7f3viLraFKsP1bjc0pynslWLdE4jNaANsFv+gTTURDv60tiLh/q9YzmJS3 BG7+TYcANaX/Y0NC3Z76RnWCwph9UOPHR7E62l2duBj2YPytZZA7Gn9gLZQS4tVt2vIl XKSMKELuF5ELtQUAKuE+UAijSzyI6wR1cWAmpYDk9+NkkEW3Q6XxVjQGHcco/k/AnNOo jUMF/YUwFwe8xaTNJvaBGdkhJrcWjGVAl9rKK1nJlBI+IEQ9VPR82oJ1ougVyquunh/z xMG1hfKWntqCT4YcBsNsWcFV2lOXkjeNf0FwX4mOl/lRzV399s/OD2sYwrtnnGyxVRGH vShw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704972502; x=1705577302; 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=1r4p8EZizALAha2W0BpFV/ugv3SVBdRsaxVwbhdyofU=; b=n17XHV8RSZsGm4umB/41Bm0eU7Rba7agVkG1uBYwOWqjvxSAR5v26140nHoB12UWaJ 046aQ6XWGnMhhWZm2i/W6pwGzl90d0re71lvbLopcGeMC5wj4cZEcF5DqCPIpYADNyE/ Tlsyl8UrjOO23A8wIv9+3diUeDe4Hx9RN2FZaaEE9rPyC1z9PldcvDP3nUQCGwc3rYIS viNVrMRlHX3YxReNtaCZ+hGjHAOFSxg6sQ+2yP2MkqGb0kv7PdTmlSZIhHVc8MYDmX4f 3hNs0nIAx02cdbv+F4XGBsjevSoSN5l4E/TSKEpiKSFnTGb0LgOjY9HvFVGiwllYqYyM gTbg== X-Gm-Message-State: AOJu0Ywq5CYg87cQa/lt4udib8HlYTI70sW2cJ0s8Fjz/V990OWDpKZt r15b3xbg60J1exSSwOJlZCxx0zg5P1XCJTN6YqKObymXrb2g X-Received: by 2002:a17:906:2496:b0:a2c:4a17:1d66 with SMTP id e22-20020a170906249600b00a2c4a171d66mr425894ejb.47.1704972501963; Thu, 11 Jan 2024 03:28:21 -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: Yosry Ahmed Date: Thu, 11 Jan 2024 03:27:44 -0800 Message-ID: Subject: Re: [External] Re: [PATCH] mm: zswap: fix the lack of page lru flag in zswap_writeback_entry To: Zhongkun He Cc: Nhat Pham , 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 , Matthew Wilcox Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 the > > 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 reclaim= 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. > > > > > 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 minimal > > codewise, no? Just a bunch of plumbing. We can also keep the other > > call sites intact if we just rename the old versions - something along > > 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. I agree with Nhat here. Unless someone with enough readahead/page flags knowledge says putting PG_readahead pages at the tail of the LRU is okay (doubtful), I think we should opt for introducing a folio_add_lru_tail() as I initially suggested.