From patchwork Fri Feb 16 03:05:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song <21cnbao@gmail.com> X-Patchwork-Id: 13559559 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 EADEEC48260 for ; Fri, 16 Feb 2024 05:49:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 69F2A8D0001; Fri, 16 Feb 2024 00:49:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6280F6B008A; Fri, 16 Feb 2024 00:49:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C9918D0001; Fri, 16 Feb 2024 00:49:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 3AA6D6B0089 for ; Fri, 16 Feb 2024 00:49:02 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2B523C6677 for ; Fri, 16 Feb 2024 03:06:00 +0000 (UTC) X-FDA: 81796177722.24.28F5F33 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf26.hostedemail.com (Postfix) with ESMTP id 7199414000F for ; Fri, 16 Feb 2024 03:05:57 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nUOAZWqK; spf=pass (imf26.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708052757; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=I7PSTWVmaYWH42bBGC9KPcBO882rqj+Igdtxrd/WR4k=; b=KW/FBkjWTd6ZzCAvoKt5KCwnEP7WhlBvpwPeJYsGkKuL9OGsF1TUS7pFQmd5en7q4RdRmJ clKH0jSi9+hHZFLenjk+Pu7AeOIWDqmu+BPkWVIGF+gCNVQuTqgzcZ/IlOViChmCtCp7i0 MpZD4uZ8iIf8xz8CeMr1fSWA7kkOIeY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708052757; a=rsa-sha256; cv=none; b=g5XFd8YCc7z0TgvKWYokXPQHy7qC/mZ0DG149t0oJXYmOAx52B3ThV5w81HO6LGVK/zDW0 8BA2l3TzTw9ypzhoRYi5xHauQDUOjRj4RMgFiGOCttbtcgge0iCnzSSWAknxlkAoIWYvds jLOKxXouyIuAxFBwp8qmBdEcjHOPVk8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nUOAZWqK; spf=pass (imf26.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6e104196e6eso1661995b3a.0 for ; Thu, 15 Feb 2024 19:05:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708052756; x=1708657556; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=I7PSTWVmaYWH42bBGC9KPcBO882rqj+Igdtxrd/WR4k=; b=nUOAZWqKY/pts9pC0jHR2/y2pUy55KtEjII3cvLB6N9SzPapad5z3SjB/a3G7FT6Uf 1svbd+/dAc2qAZalAjty5E0q4HlrbAglAqRAo3ZHJpzL9LPP0cMKtmRjDLkX6U0XqaIV xgTD84SRVlhlJ/MnhWink8QpDVohowfb23SNZYtmM+z6DdU7fxfrDR4jVtvgw2s/zO1w u9VSAXZ7eq91tO9ErSjiO+8OAy6DNRghPtGMgVK9S8ApEb23meyyx3snJSlNoYFl2zT6 ehtxFDe9a2Nty9lobxRG6LJDnDc6wJlHFBGlPxIK7INnrBcMWJtXVxeDiogrzCcfL1pb youA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708052756; x=1708657556; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=I7PSTWVmaYWH42bBGC9KPcBO882rqj+Igdtxrd/WR4k=; b=CZOIYKFhr/dTNUWUKM06yn5yx+0POFWVu/zd2d2mMgikouBAAfSYhrmlzqj7CBJTY9 nNin7GDbd4znLJR+Fcnint+bhoyqZCD5ZnxQ3lTZcqael+ICh0WNgrPDqN5tQyTmnkcb EADODh769S3pqroCIWdMaPLZfZpu5q8E55mHlOtQSUqPtqhibbD+hhiSS8SObkOWzZ5K Fwg7fwygwNVVZYVW201EdiXzYxMQ0IIqrmkVbpP8hFlkCBoGFz3v2p6ZM74fa/Jb3DY/ 6/DGupxNa0hygCSGz/6nU4pflShk+SWv1FKfpkk5Z9vApL/HqlVYFQUj5LyCmhjC/jj4 rw4A== X-Forwarded-Encrypted: i=1; AJvYcCU0VgVCcb2KNiRFP84Yb1uQhWIQcPJ8Cr1+mLeVDUE2NfQfzpHADRSOzzhLv2bNv0UHpLvllnQ+vpkfK0K6HRWg05A= X-Gm-Message-State: AOJu0YxDXqOcArWq50EKLKpsAU2IYij2oIzTGWG6PUBGLxQ0ZJuOn8yg mLPFAYLUv6GGVdpCbqzKbNV+cuYJJzE303AEWwuMgGjR7vM1W5MQ X-Google-Smtp-Source: AGHT+IG/Jyyl1szf73bIkO4ooPyYiVveqIprdngc3VwOxDhtbiHy2HZn3gG5Y8dH1/cckeRAeAjZvg== X-Received: by 2002:a05:6a00:22c9:b0:6e0:fb6e:124e with SMTP id f9-20020a056a0022c900b006e0fb6e124emr4794443pfj.26.1708052756168; Thu, 15 Feb 2024 19:05:56 -0800 (PST) Received: from barry-desktop.hub ([2407:7000:8942:5500:f28b:3925:777f:45d4]) by smtp.gmail.com with ESMTPSA id lc25-20020a056a004f5900b006e0eece1ca4sm2017757pfb.4.2024.02.15.19.05.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 19:05:55 -0800 (PST) From: Barry Song <21cnbao@gmail.com> To: akpm@linux-foundation.org, hannes@cmpxchg.org, linux-mm@kvack.org, yosryahmed@google.com Cc: linux-kernel@vger.kernel.org, Barry Song , Chengming Zhou , Nhat Pham , Sergey Senozhatsky Subject: [PATCH] mm: zswap: increase reject_compress_poor but not reject_compress_fail if compression returns ENOSPC Date: Fri, 16 Feb 2024 16:05:39 +1300 Message-Id: <20240216030539.110404-1-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 7199414000F X-Rspam-User: X-Stat-Signature: beik811pnyz3jqthhisgsnzgn18m1ers X-Rspamd-Server: rspam03 X-HE-Tag: 1708052757-109078 X-HE-Meta: U2FsdGVkX1+05KmxLpdOsN8NuXexvdxv/X13WHe3a7yHlBXuQXigA5S1/q67O+jek4p3jHpmkXB0lj6q4eEvCS0RrfnwLU8bzQCWNn1lZ1eQTj7VwdKcBy//ADeeiYumXwvM+b66/dOLi9Yty1VlcHnx3xBxCUKeCPnLrqq490Z3FGta2NmOLm3kIIAte2pVqLVxTmmGZLbTVxFwit5pSGoHAvEG8gURXnc9tGG5rkzJbmkFpKljuNgoXa/VZ0Yi+ojFreDgeZc6a03hCvk/VsTDSSoyUK5jAV4oFXtFRACQLP0yTp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inonR0C8Vg98xmaE6A0RPGq44XBpHD/gXcgfUp9JyRQVHY0I0t53SDetnx3xzWU6uv45FQmAl4ax85lnq0KzWcDWBmmrh+fSWQwMhPW50FJSw7My59UK33DecWhEelXPc4iUNjRAUdaxv8LGn/16j2P6UYcQaPVUwBEXouuTsve/tqxaIQziNrZXdD7DN1M/hLLbqag/J4JlXFNkwXeCou2548mrsrdslvGZ/OitVFBN+jFAFBwCuj8pjVLweGgrAgU/nEKn/Tzdha8= 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: From: Barry Song My commit fc8580edbaa6 ("mm: zsmalloc: return -ENOSPC rather than -EINVAL in zs_malloc while size is too large") wanted to depend on zs_malloc's returned ENOSPC to distinguish the case that compressed data is larger than the original data from normal compression cases. The commit, for sure, was correct and worked as expected but the code wouldn't run to there after commit 744e1885922a ("crypto: scomp - fix req->dst buffer overflow") as Chengming's this patch makes zswap_store() goto out immediately after the special compression case happens. So there is no chance to execute zs_malloc() now. We need to fix the count right after compressions return ENOSPC. Fixes: fc8580edbaa6 ("mm: zsmalloc: return -ENOSPC rather than -EINVAL in zs_malloc while size is too large") Cc: Chengming Zhou Cc: Nhat Pham Cc: Sergey Senozhatsky Signed-off-by: Barry Song --- mm/zswap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/zswap.c b/mm/zswap.c index 6319d2281020..9a21dbe8c056 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1627,7 +1627,10 @@ bool zswap_store(struct folio *folio) dlen = acomp_ctx->req->dlen; if (ret) { - zswap_reject_compress_fail++; + if (ret == -ENOSPC) + zswap_reject_compress_poor++; + else + zswap_reject_compress_fail++; goto put_dstmem; }