From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E03BC4828D for ; Thu, 1 Feb 2024 18:12:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 943096B0093; Thu, 1 Feb 2024 13:12:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F2C96B0095; Thu, 1 Feb 2024 13:12:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 792D76B0096; Thu, 1 Feb 2024 13:12:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 65F776B0093 for ; Thu, 1 Feb 2024 13:12:49 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 048C5408CD for ; Thu, 1 Feb 2024 18:12:48 +0000 (UTC) X-FDA: 81744030858.30.3034D83 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) by imf28.hostedemail.com (Postfix) with ESMTP id 20DACC0017 for ; Thu, 1 Feb 2024 18:12:46 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=bqD6WmR5; spf=pass (imf28.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.173 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706811167; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=X7pFNo9wllIUlLWgzZSFIzQX8/BIsC9AxRoRCkFQD3o=; b=NqpI6MVbyxhGykybARXz8Hg56EDd+58eOUEsgGajzvv4erPYCOPpvMZC6qNICzxyY+ydLt UpuzkJMuW/MTakobN/UXUJih+2GEzgJOeSTsDb8JDFb3IkqdgSSdNULHkSSvXOvmMEirLc 16f17Qa+E3d5MdLBxCT8/Uflx5VS/o0= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=bqD6WmR5; spf=pass (imf28.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.173 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706811167; a=rsa-sha256; cv=none; b=sXMlkmW1x11Qd/igI3Ds8M66CdL/8etXbKgBWfNwg/OrMEuArycoyC45KV2FDH2TuoyHjH H1AF0o0dlVwySfXk4R1gSmNZZQdcF1/3rJPBh9TGzmSbXH7/Pwbuw3vSuhiXS7NVp0iE/A 8P8OnHuqhTRoAmVHmU0dGTCEjxhzAIQ= Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-78541a1c5b0so109085785a.1 for ; Thu, 01 Feb 2024 10:12:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1706811166; x=1707415966; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=X7pFNo9wllIUlLWgzZSFIzQX8/BIsC9AxRoRCkFQD3o=; b=bqD6WmR5Ep1qZ5uV5EmMYL6bO8T9M9gyDjKws7rQxiB6GMlZVYo7Ymxp+w5nZzKa2o kAfhFbioGpvXu2fjoiva/1eaCz6rruyTAKaVByUUYAZioodCu/WAopGb/sA4w8dydAjl cwAYNEwVMw8WH14DYluwbsKXJdmTlZgd/KtVwTQb6o/2sylQmIeEElscAGgVEJs70ga/ tcxEpUDKgndqU0DSmrpK6LSZC8UBUoa5f3cTIKPXo3dD3zsyvDs62nJekHryIqnfu2Vx fRMyEdxp8gMhzwdRB9NLUJIp4Za2e6ztegAWe+VDwEuoCHa+Q4YS1GQVABykBeHLUgk0 yCbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706811166; x=1707415966; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=X7pFNo9wllIUlLWgzZSFIzQX8/BIsC9AxRoRCkFQD3o=; b=gj30MnoRrgO2v9aVI1hAsMfI6bRNL4Dm9WsI+J0JOoObEWl0cFykCXIZQjoIpmeYke UGrsdSS96vz7gfeXazq8nLLNOjMJ8+WVmkMKJRXN9HOiUxVi74A8e0Rvr/XDabRhuu/z SQHTELbkPERX+0K0Y3E96zTq6qwXUMGAuFKBY2MFJ97MIqPhQOuReiiWEdRrbdJC/XFN 05TRDftW1EzJGHqneisQvdliUNRSTwGX82l0jG/qT8Dg0lrsg4Oh5VIC/5gVXDAlpqwA dZ00vVjK+14dYDok91QRBjqK0Ege59YkordxRA3xZrqvxL3UnlPoGYOjZopqBbDWUX7G P/2A== X-Gm-Message-State: AOJu0Yw4ipzb0opjdk1N18U06e4I7MTeT2gS4mvBmhzSzvZ98bAWco63 pLU0Jzetz/ZX4cMFe5LkuKP5Eit8/ijq6olH0fK5Vx2CTsCAYFqoml85UmheEYE= X-Google-Smtp-Source: AGHT+IH+kpI7VVtmvFtvKwua4b/SnW+Caog8FEaXBrC3QNWDmleH6fXAbOl8JftGfv8N2puw18DjZQ== X-Received: by 2002:a05:620a:46a9:b0:785:3c7f:304b with SMTP id bq41-20020a05620a46a900b007853c7f304bmr4534794qkb.39.1706811166216; Thu, 01 Feb 2024 10:12:46 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXcpzEYHSB9QtnuNeBy/nj/gZmwU9fKY7dvMJLTUzSlVxOjfHZ7NT+Or1jhBuwspiHPIUSYp5tD2BnTrQqTgB0gonYjW1Zw2HLckwPO5F6+oOJiSh/G+WuseOsPzvZSVsk1CFeWm+ct5lRrinSxTQ8d98vc44APWKEdjaiOoGrrInVJ/fjORxr9ymMExz5QtBGRUw== Received: from localhost (2603-7000-0c01-2716-97cf-7b55-44af-acd6.res6.spectrum.com. [2603:7000:c01:2716:97cf:7b55:44af:acd6]) by smtp.gmail.com with ESMTPSA id d27-20020a05620a159b00b00783dd0f9383sm28770qkk.7.2024.02.01.10.12.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:12:45 -0800 (PST) Date: Thu, 1 Feb 2024 13:12:40 -0500 From: Johannes Weiner To: Chengming Zhou Cc: Nhat Pham , Andrew Morton , Yosry Ahmed , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 5/6] mm/zswap: only support zswap_exclusive_loads_enabled Message-ID: <20240201181240.GE321148@cmpxchg.org> References: <20240201-b4-zswap-invalidate-entry-v1-0-56ed496b6e55@bytedance.com> <20240201-b4-zswap-invalidate-entry-v1-5-56ed496b6e55@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240201-b4-zswap-invalidate-entry-v1-5-56ed496b6e55@bytedance.com> X-Rspamd-Queue-Id: 20DACC0017 X-Rspam-User: X-Stat-Signature: ju49o5f5w1xa87zrz8bz98xhm8np9biq X-Rspamd-Server: rspam01 X-HE-Tag: 1706811166-954146 X-HE-Meta: U2FsdGVkX18sSkDNj7Na8xoSxCpfeCrxtOxwxiXpNBfhtOjzPT7aybG1JuvQcRgpW0+b8qwbBV/i6sqN99laHYdb0fYN8B8wx2xUYV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rV7IsY/Tm+ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000004, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Feb 01, 2024 at 03:49:05PM +0000, Chengming Zhou wrote: > The !zswap_exclusive_loads_enabled mode will leave compressed copy in > the zswap tree and lru list after the folio swapin. > > There are some disadvantages in this mode: > 1. It's a waste of memory since there are two copies of data, one is > folio, the other one is compressed data in zswap. And it's unlikely > the compressed data is useful in the near future. > > 2. If that folio is dirtied, the compressed data must be not useful, > but we don't know and don't invalidate the trashy memory in zswap. > > 3. It's not reclaimable from zswap shrinker since zswap_writeback_entry() > will always return -EEXIST and terminate the shrinking process. > > On the other hand, the only downside of zswap_exclusive_loads_enabled > is a little more cpu usage/latency when compression, and the same if > the folio is removed from swapcache or dirtied. > > Not sure if we should accept the above disadvantages in the case of > !zswap_exclusive_loads_enabled, so send this out for disscusion. > > Signed-off-by: Chengming Zhou This is interesting. First, I will say that I never liked this config option, because it's nearly impossible for a user to answer this question. Much better to just pick a reasonable default. What should the default be? Caching "swapout work" is helpful when the system is thrashing. Then recently swapped in pages might get swapped out again very soon. It certainly makes sense with conventional swap, because keeping a clean copy on the disk saves IO work and doesn't cost any additional memory. But with zswap, it's different. It saves some compression work on a thrashing page. But the act of keeping compressed memory contributes to a higher rate of thrashing. And that can cause IO in other places like zswap writeback and file memory. It would be useful to have an A/B test to confirm that not caching is better. Can you run your test with and without keeping the cache, and in addition to the timings also compare the deltas for pgscan_anon, pgscan_file, workingset_refault_anon, workingset_refault_file?