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 71987C5ACB3 for ; Thu, 16 Nov 2023 20:46:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B020F6B04A3; Thu, 16 Nov 2023 15:46:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AB0486B04A4; Thu, 16 Nov 2023 15:46:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 977D96B04A5; Thu, 16 Nov 2023 15:46:20 -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 88A256B04A3 for ; Thu, 16 Nov 2023 15:46:20 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 61B0FB5FEE for ; Thu, 16 Nov 2023 20:46:20 +0000 (UTC) X-FDA: 81465000120.11.349798E Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) by imf09.hostedemail.com (Postfix) with ESMTP id 898FD14001F for ; Thu, 16 Nov 2023 20:46:18 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=jlxCgF8g; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf09.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.45 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700167578; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9aSp9lzLdexzLy4YCwYMOeITU16swn1+BuYTl7JNpDU=; b=HfZ74qD6KiLP6Sxh1APJ1I8zJtlQRvbsQedkA2S5YmORGPSkmyI6RZWAct1FLBY3RvrcFJ 99b/PomWmOuQ2S2dKLhHAtoj/W9Ilf3RDRAaDXfp3lTyoBeep/R0Ph9qUWvSMIchTZcUOF cBZnslJXAoBZAT6MvJBzpsikC2Thlbw= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=jlxCgF8g; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf09.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.45 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700167578; a=rsa-sha256; cv=none; b=4CV5Tv0wF44v4JLLl1kfv9YUZN6ZthAyH8396FeLHEgEgSzor3QHnB0EVYYK3ml1cwtwv1 4iwJ6Qqkk2zw4vNMqnT8oINxbhBWvIgAhKsiPR2aKG9B5jt4+1BvYJtghtYqexic2ZPArB i3rUt5dhQzI4ZRUI0IIZs+r52z2Y2FI= Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-9d0b4dfd60dso169484766b.1 for ; Thu, 16 Nov 2023 12:46:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700167577; x=1700772377; darn=kvack.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=9aSp9lzLdexzLy4YCwYMOeITU16swn1+BuYTl7JNpDU=; b=jlxCgF8ge2wyschX1A0lNbbRRY6Q/M2YtELUDI9HGVqQNJLal9iTXD0ou+tfLb11/6 UHkoUmQ7nnBfesJm1CvBv5uRwYXLwluk76Dmuh44WlV1wyRuyDg9C90JaT90fuwiaOF8 PSnmc3UQyG7pZeFuC+0GsBfsp3ef1D0Ht06vrp7hiEj68Q+beThBSO2lBzQcNuuV7bAL NJqpQfxnbeNm6plBS9VlhBs0dtYYiNNX0xJRdz9uxXNEAEOgRmGq1uBPtFvHmLUPLRWT f8aGTekBCWj47RdjzecqCayN2FXoe2hMjRsMrNfR6NNRn4sq+P2uhFQSw/1SXFX5Mdxh kZsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700167577; x=1700772377; 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=9aSp9lzLdexzLy4YCwYMOeITU16swn1+BuYTl7JNpDU=; b=cPwFuJB5YIlnNhXJgqpfAZHsgNt31XlgGe3o0zx+wizvgm0uBfmrPH4fPcIyKOVj9V PxmdGmXL/iSDemQN6g0UwtqA+UugMCXYLZkOBVrJU3kwHwYSIOhnIyM1v674ygWAmxGo rbrU0Vr2CQ5oB1ba4/qq9AVriXc7sfl5Xiy118+rHAi346wqwsGFBrnLAuNrJaXOZ+99 A5OSjNdJRwUjmkwZ9MK2xjUPxd5/nzfYQ2dH2R1MX47K1KMuSc1h4csq9eRtvrGlRVOo GwPJkysMxmEycvFN4LsV0kFbCP2BU8kaQJvnxb3OVsdqxHuO2vTOrUWmjbpJUfej5fmQ c9kQ== X-Gm-Message-State: AOJu0Yzm6ZXnZYcNC+6SFLzB4SOlrJCgVQbAPv0PfJEMB0IDqzFTmGzh JfLJmpqXLURY0ndcvuldgaqWj1W7/FloIYCNSkJFeQ== X-Google-Smtp-Source: AGHT+IGDUciKmW57AZBbBvkRcBsP8S8YUWoooRjJ005PGY5aBzSh8gq27qCQsjfHqiKze4TuMVww56esuF+d+Nlvc5A= X-Received: by 2002:a17:906:361a:b0:9dd:bd42:4ec2 with SMTP id q26-20020a170906361a00b009ddbd424ec2mr11685133ejb.10.1700167576851; Thu, 16 Nov 2023 12:46:16 -0800 (PST) MIME-Version: 1.0 References: <20231113130601.3350915-1-hezhongkun.hzk@bytedance.com> In-Reply-To: From: Yosry Ahmed Date: Thu, 16 Nov 2023 12:45:38 -0800 Message-ID: Subject: Re: [PATCH] mm:zswap: fix zswap entry reclamation failure in two scenarios To: Chris Li Cc: Zhongkun He , Andrew Morton , Johannes Weiner , Nhat Pham , Seth Jennings , Dan Streetman , Vitaly Wool , linux-mm , LKML , Ying Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 898FD14001F X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: x77rit4cs7qi1hbb9n9hm1oc6r34r5ia X-HE-Tag: 1700167578-966531 X-HE-Meta: U2FsdGVkX1+3qKC0RqlhWCp452djwB5dZL1rlWfHLlZUNSJLWHj9msI9GiTaG7uZ8LepYJccPygLewzrGdcqmtlGl950uI/Ynzca3h2DDO6UAgE3Rfj4lGrFCk6pJ7260xBvQu45x+y83DxeEgpd7IJxhvKj688b2C/Sw8gY7pPpB1oOUwxanB95EM0YnGSV8wELtvr25Zvud6kATZ94qcKN6jDjNfApsFrR5B66QWjFGrkIFDQTTR9mjivIgOAH7+qnmJTX33ksfAwcc/C+xbKWlCcacIKb9MbeoKs6/woT3AR+IcHDFRuO5seqGofacEg6NC+8IJtxApu7HbbreCXAqTGMAL8zqnsZs25OSerMBjXEHTq9X5sLwxBKW0MKBl6JGh51FeLRD41R5G07/QCyvZucOtawhmbMD+PD2bSYNuVZ12OCclENzv3I8tMVDeW34npOs98pmJDz8tV0pBGnCS7IkKsShd1rSua3vBN8WoJQBr8hSjWwShNY/wQXE5cH/FTKOJz2NFATem1ary1gG+GodbUYuoiNpsMdFe19UDJoBuqed3rAU7KB2LgPTxV5RKpcfugRvjvcbjY6lzPnaPUR4CEJYAhGRlFPnZKRlf35r4sYGLPxbV+kWN7Y3f/WLh683e6lnJr5Gz9u94JuanyP8dzTQKxNkvUP3ddB5SU9aCIlTqTMk6QBeNxHTmWueaPIvbJv1U27GENQlR2r5BYDAJCAXjgZ8COuR0QkWrXLlrsFlrNeYx9Flb79vkVRcvZpB/uQm+SrdF8zj1GpxFwAfm0SSA1OmlElsSpISnoD+/N0UpJtY4I/Do6OO592Mnym640fo4IxPZbBszirsQc54VdZux3FkZO0X1Y4AzCxIM2tjGKWHWPMcHUG+/jNOWy5FLlASAc5ELMpf7w3LQxnlUDKbCCjcROk0h7BOituxadPdgvl/Iz8dCkvGyBQObHIIZwB85BKXG/ hD/FGGLi GCP1IizpniF+3j8/CPETxdhCBc1i3CHqy47NC0NURHtfLbdKmSqUTbQw31CHn9F47qVAM2wEQC0H1FvAGkv59I8uPhDNIukdTu3+VfV06Nshy0OTMHvaGQhvRDL6tKftDNqbjQzW4oXbnyE3Vf9+Crw+hkMwKxfel7HjfoJ/+XJsKYfpcFO/Z0q2H5HbRYGKcgyDIjaZOUi3/plw/tJS2eKJpbrYnF6sYMc92to8aqy6DPKNm1b6m0lgc/g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000066, 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, Nov 16, 2023 at 12:30=E2=80=AFPM Chris Li wro= te: > > On Thu, Nov 16, 2023 at 12:19=E2=80=AFPM Yosry Ahmed wrote: > > > > Not bypassing the swap slot cache, just make the callbacks to > > invalidate the zswap entry, do memg uncharging, etc when the slot is > > no longer used and is entering the swap slot cache (i.e. when > > free_swap_slot() is called), instead of when draining the swap slot > > cache (i.e. when swap_range_free() is called). For all parts of MM > > outside of swap, the swap entry is freed when free_swap_slot() is > > called. We don't free it immediately because of caching, but this > > should be transparent to other parts of MM (e.g. zswap, memcg, etc). > > That will cancel the batching effect on the swap slot free, making the > common case for swapping faults take longer to complete, righ? > If I recall correctly, the uncharge is the expensive part of the swap > slot free operation. > I just want to figure out what we are trading off against. This is not > one side wins all situations. Interesting. Maybe we can just move the zswap_invalidate() call to save memory early, and leave the memcg uncharge call to be batched? IIUC we already do some version of this internally at Google. > > > Chris