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 40952C4828D for ; Fri, 2 Feb 2024 01:04:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 570C36B0072; Thu, 1 Feb 2024 20:04:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5219C6B0074; Thu, 1 Feb 2024 20:04:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C2426B0075; Thu, 1 Feb 2024 20:04:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 273AF6B0072 for ; Thu, 1 Feb 2024 20:04:06 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F1D1EA25BF for ; Fri, 2 Feb 2024 01:04:05 +0000 (UTC) X-FDA: 81745067250.01.E855437 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) by imf05.hostedemail.com (Postfix) with ESMTP id 3DF0C100004 for ; Fri, 2 Feb 2024 01:04:04 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=F1UlAQod; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf05.hostedemail.com: domain of 3gj-8ZQoKCCcbRVUbDKPHGJRRJOH.FRPOLQXa-PPNYDFN.RUJ@flex--yosryahmed.bounces.google.com designates 209.85.210.202 as permitted sender) smtp.mailfrom=3gj-8ZQoKCCcbRVUbDKPHGJRRJOH.FRPOLQXa-PPNYDFN.RUJ@flex--yosryahmed.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706835844; a=rsa-sha256; cv=none; b=q4pRb2WBQ+UBdVsgjivEf9WBfwGkRkaiYsPJSm1zJXbqqE7I3kcMyHsqdXWLayfCt7NCy3 dPKAgtFnc7d0BK7GJR2A2EyW7KTtx0lg/cGvTAnuKPTOhaA5DH0+4UJzLGKt4zH/Vn8+Yf EJGnPCaIFg+X4bELGhTLhmeB8mPpz0A= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=F1UlAQod; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf05.hostedemail.com: domain of 3gj-8ZQoKCCcbRVUbDKPHGJRRJOH.FRPOLQXa-PPNYDFN.RUJ@flex--yosryahmed.bounces.google.com designates 209.85.210.202 as permitted sender) smtp.mailfrom=3gj-8ZQoKCCcbRVUbDKPHGJRRJOH.FRPOLQXa-PPNYDFN.RUJ@flex--yosryahmed.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706835844; 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=XbgnQJwz1vgU0uxdyyb22RvKZPgmTtLqOjZGD/vUXYI=; b=ToQrSourrbBAqspruuQ7D6ie3fAV8PjNmlydCnhWso4gsgWg7LeCvAQMBayAPxWx1//T+v ihzAKeZmldwDesIot9MybFBUFRMU7+5I3AjhEsJHswQMA8wvLCnLW2zSwxocba+77fV3u+ fa/mdbkxiELm8fPUSInWCHoVMWdjdac= Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-6ddc2aefbe4so1582353b3a.0 for ; Thu, 01 Feb 2024 17:04:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706835843; x=1707440643; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=XbgnQJwz1vgU0uxdyyb22RvKZPgmTtLqOjZGD/vUXYI=; b=F1UlAQodpTzuj8d12Yz5rR/hIK7+5S/uNVMc3KAfTbaB1692xXwleWvn8d4dk1EmD3 2hzHczJy43ypoxVbnEUl3YTCaagmFCNU+AuGr2nK9zfule7WmVCXirqM0DjFOyGNLwHE sbXGJKqIPBpkV5aEgxNxtht41Ek0inViadvtiJx4f3kFO2PoTMPpGUZMDKdE2woQ6cel XMz5XMtpQ22dgP91PR4mOFv7I7ChKsP0jhU2BQJd78eXb1bV2FNhkiXMSikV3EbsM6St ILeP9lN1aCxpTD8OAcB7ORUfRQFSdJuhLVpX5fGZZtd6RTkRcjETQAklOJ1kVBsowMKz fLug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706835843; x=1707440643; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XbgnQJwz1vgU0uxdyyb22RvKZPgmTtLqOjZGD/vUXYI=; b=S5qlovllCqgoP6oT+YxPEB9IGYh8JaL09Z4PiAp8rOjn+pSiGHRyV9/aHiAGxKjKRx rJFe+Ar4pRKAjvLUJMf48TX9k2t5VorfGOfspD4KEmBcVyFhx15I3JSXv3AaJcC5SN2K zga4fZYqGIbuK9YhwKFE3Sv+nkAphzkGQmAC4IPLvR+rUb1HOpJs48W1SklG6a9UNBvX Lxpc6FA/albzbiTOPh+pOdikOVxadVPBMSI38b63zleyKHxO00BNw8lG+iaChZ/GIKd+ EpJ71JJhZaeUTy/HIIeXpt9AEJps8Fnn0atvDdF5ANvkL41dyLqjYf6gYp+7fgFP56NA yoYw== X-Gm-Message-State: AOJu0YySIjGH9obJ/keeGqns59PwqnJ+K7aJWM96BKXT1xoQ0W5mOlJS UPepFam4fVAnnT8KqH/Hdus4TuU9UsiLbc12j5Ximy+/QMnLncEsrt9dtoxbhEEolVkaaRi2WJN K9QHCbI7plkK/4bQR/Q== X-Google-Smtp-Source: AGHT+IE/JxLkSou/VDo5U1rx0tT391GDl15vJuyWnddaQq63I5wd1sjbiRacqQYzWmPRXa7XRZALYt4dElsYU/6X X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a05:6a00:1c9b:b0:6df:e31e:e995 with SMTP id y27-20020a056a001c9b00b006dfe31ee995mr274511pfw.6.1706835842950; Thu, 01 Feb 2024 17:04:02 -0800 (PST) Date: Fri, 2 Feb 2024 01:04:01 +0000 In-Reply-To: <20240201181240.GE321148@cmpxchg.org> Mime-Version: 1.0 References: <20240201-b4-zswap-invalidate-entry-v1-0-56ed496b6e55@bytedance.com> <20240201-b4-zswap-invalidate-entry-v1-5-56ed496b6e55@bytedance.com> <20240201181240.GE321148@cmpxchg.org> Message-ID: Subject: Re: [PATCH 5/6] mm/zswap: only support zswap_exclusive_loads_enabled From: Yosry Ahmed To: Johannes Weiner Cc: Chengming Zhou , Nhat Pham , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="us-ascii" X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 3DF0C100004 X-Stat-Signature: sej1erjwijhtxc1b4zfobhzkbb9oyygh X-HE-Tag: 1706835844-457303 X-HE-Meta: U2FsdGVkX19utB9lpnljNHrIzKrcRyA+1Q7iv7nCCVMUT0fn7NTnyAoqQbX1RwKYYH0+WcN8hP1fHQRziGzER7yu3Qc4MZ4fBSWtaauRxwm2UK+3FyzF2rKf5I7VHFpIqaNx5JRYWJ353w46TFfBpLtcVkVta1qs+2UC+gJrInmnmseSpgidnuYuXkktOxAIAjA0TsetFazqYRrkXv1lP6RFuAmT5RE1hOvWLVWGtOUZgfqeN2aPzsu021sbkCpLKEo8yGeyfWEzb/HTqSjb6M3oMsYLp/rcj/UezNuNgzwz+PQvM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JjskXy235dNZiUev/CoNw6zDUh2hsV6utIMD8MUkxEoPr/LcSF2u7r+MYIe8O5UaRyrfMIy2TiFsAW/6uTmMASbRIx9BaoMcNTrWtWtEoux3akXZ/fqb7WJrILdtVBVDbBGlVf2jBaZz1DTk4/UGOhcdl3FwpK8lgA1FeMJbACvOq1Gk5v4N3m7lyJ7CZdDwGXkKaHqp9bsq3fDoqhN0TsZAbLh3CWI4Hcv3ctCq+jmHQPSuYT6+NsH8cNl45IhLO8CNcf5izYqkpHwBDOUPGGFC3GcsT2QICCLv2tl5YaikakMakoz+jq36aE+OD3jdfyiu9YHaONXxsHjjIaE2xnPcAJtnm33ykR+W X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 01:12:40PM -0500, Johannes Weiner wrote: > 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. Agreed. At Google, we have been using exclusive loads for a very long time in production, so I have no objections to this. The user interface is also relatively new, so I don't think it will have accumulated users. > > 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? That would be interesting :)