From nobody Mon Feb 9 02:13:51 2026 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 6F8C3B64B for ; Fri, 5 Apr 2024 01:35:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712280954; cv=none; b=VRRHK6nApzvosCKKmJXMLzCovB/dT1PzgpdxPjTz9VI6VMDnkwwNMrcO7BnoUimD644885GSc0ugUUH5X0pjswZ0d3opXYJ3cPx2wKTQbGlZ24FOmPa3KzcL3Xr2Sui5UKOhWOFsfCUxMCrWYjJ4U2hGrA5gN+vqb7bS4aheMm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712280954; c=relaxed/simple; bh=0EwsJFsFqxelfzk3PZ8b/+zJHvbghrn5+keHiziw9TE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=tUU0Nz7B8Dmzq57QShiRqCQIG6401ww63lgn7fg2qNWPTe8SnF3GGn0gVw5HDs35BoGgFycGPDO6A9IMrFkHXQVqwaC3s7vs0jVE7QAF5D3f1sOUH2V5iAEma1+A6U4f4nRp+28vlRjPwQivBtkF4Yql9wp5aLGMB9gPeLNx2eo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--yosryahmed.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=X/IkkluX; arc=none smtp.client-ip=209.85.128.202 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=flex--yosryahmed.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="X/IkkluX" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-610b96c8ca2so27492427b3.2 for ; Thu, 04 Apr 2024 18:35:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712280951; x=1712885751; darn=vger.kernel.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=fbFnbwv9ZL9vnT6aD0Y4iZUVe+aMA3yOt75trlF6TiA=; b=X/IkkluXiEVJ5EKk7J0A8+yObqRNvDLo0ep30HXuSpU0+npT3vZt2uJypTJEfJGjJd 1SgVawoNeHogbJPS7AMmqdVcxlCg1yCLXpdqnC6uIlDI02bS8N9NfwphPROp9iFAp17g CL/Y4nZrSHQysvn3XQB9sS0CReeDHKJVWoqdK5FSATcH40Wx7rbiPKNradeXNsmTc5o8 kSUCA9nsMzw6l9pdrrH1M0dAM4ofoGFqluGil0aR+RG62cLEzc/u7/xbGYs5ogqv2/iR GBnucTFJyvVuMxobpuaxodiL9rPatwrCb34/+3d3Y20V0gLl5e7+uzg2Ej844PyAKNRq IxnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712280951; x=1712885751; 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=fbFnbwv9ZL9vnT6aD0Y4iZUVe+aMA3yOt75trlF6TiA=; b=qV7Hm82iwDxK78nGGsnxkK7z/S1rMWe4K23dO0smWXy1d4tX+mSCCp/5w10nHAQIhF WoT3VdWFIS5O0XweYnT6ETZN3FEH/fHSxgNdVPhc60OuWuovO5chu+K07Fu4btru/5Eh Gdhi99iDbrEdyLCjs0llSnkzFpMblsMM3LChKDJ0T9IUlGj4sqcMACwB8iFzORNZQK6V iA6F9RS7o8njTnhAV0IUzxlyZ/59f067x2jAbeFItjUCDlJ3rNCJ9h35JVavvd43l4Go MvmVw01aD4jg9b99HbAkrEB3sRu94ms4NHYsfuWsjAjRML7+ow9V7iAbeOk/dsUVqJYn NZCw== X-Forwarded-Encrypted: i=1; AJvYcCVYxi4ZO6MLB51+K+HzemvT0GuN2KAGmAYwIPUIxO++Yfm3JhDa/2qNdLr3mVOW/8wAxFc9oAfEK7Hbn1wasbiIZEN8jdOEFsiUskcD X-Gm-Message-State: AOJu0Yw0YQL1SWNyoArGTxGO3JYW1CR8VX1dokd4LOBz+JqScCaBTTLD T3DqFIdcQ28q8kos7YbZuHBw7AEndPfgaBPzj6vakht1y2+9HJDlyr4l6wORyEOcTeuObdz5Elw ere7HrxmlKQBfluHbcw== X-Google-Smtp-Source: AGHT+IGJTA/i85YTUBVw2cs8xuSEjY+bqpz8Alc8JIdeIpUrh1LGBbhlTI/u/mBkLRKZfoJj4MNZLvSP1tmwvTZh X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a05:690c:dc4:b0:615:102e:7d3b with SMTP id db4-20020a05690c0dc400b00615102e7d3bmr343711ywb.1.1712280951511; Thu, 04 Apr 2024 18:35:51 -0700 (PDT) Date: Fri, 5 Apr 2024 01:35:43 +0000 In-Reply-To: <20240405013547.1859126-1-yosryahmed@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240405013547.1859126-1-yosryahmed@google.com> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240405013547.1859126-2-yosryahmed@google.com> Subject: [PATCH v1 1/5] mm: zswap: always shrink in zswap_store() if zswap_pool_reached_full From: Yosry Ahmed To: Andrew Morton Cc: Johannes Weiner , Nhat Pham , Chengming Zhou , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yosry Ahmed Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The cleanup code in zswap_store() is not pretty, particularly the 'shrink' label at the bottom that ends up jumping between cleanup labels. Instead of having a dedicated label to shrink the pool, just use zswap_pool_reached_full directly to figure out if the pool needs shrinking. zswap_pool_reached_full should be true if and only if the pool needs shrinking. The only caveat is that the value of zswap_pool_reached_full may be changed by concurrent zswap_store() calls between checking the limit and testing zswap_pool_reached_full in the cleanup code. This is fine because: - If zswap_pool_reached_full was true during limit checking then became false during the cleanup code, then someone else already took care of shrinking the pool and there is no need to queue the worker. That would be a good change. - If zswap_pool_reached_full was false during limit checking then became true during the cleanup code, then someone else hit the limit meanwhile. In this case, both threads will try to queue the worker, but it never gets queued more than once anyway. Also, calling queue_work() multiple times when the limit is hit could already happen today, so this isn't a significant change in any way. Signed-off-by: Yosry Ahmed Reviewed-by: Nhat Pham Reviewed-by: Chengming Zhou Acked-by: Johannes Weiner --- mm/zswap.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index c4979c76d58e3..1cf3ab4b22e64 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1429,12 +1429,12 @@ bool zswap_store(struct folio *folio) if (cur_pages >=3D max_pages) { zswap_pool_limit_hit++; zswap_pool_reached_full =3D true; - goto shrink; + goto reject; } =20 if (zswap_pool_reached_full) { if (cur_pages > zswap_accept_thr_pages()) - goto shrink; + goto reject; else zswap_pool_reached_full =3D false; } @@ -1540,6 +1540,8 @@ bool zswap_store(struct folio *folio) zswap_entry_cache_free(entry); reject: obj_cgroup_put(objcg); + if (zswap_pool_reached_full) + queue_work(shrink_wq, &zswap_shrink_work); check_old: /* * If the zswap store fails or zswap is disabled, we must invalidate the @@ -1550,10 +1552,6 @@ bool zswap_store(struct folio *folio) if (entry) zswap_entry_free(entry); return false; - -shrink: - queue_work(shrink_wq, &zswap_shrink_work); - goto reject; } =20 bool zswap_load(struct folio *folio) --=20 2.44.0.478.gd926399ef9-goog From nobody Mon Feb 9 02:13:51 2026 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 1C10ADF5B for ; Fri, 5 Apr 2024 01:35:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712280955; cv=none; b=iQAXhm/nw/Y4DENQgMK9kYUTqEx9s0OBQlbmtA5eL5I1VjSVvsQcbmdvgXnTJAB3kfZQPaKEB3CjlA8fwpxOk/IITduXeAbN72pRLfSvntkTXluLeMSTMTJqZatxvVbOOTH/8w8N55tBtbDbP32Tm5Dyo2T9T6aeP4uGiddOamQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712280955; c=relaxed/simple; bh=xdeoQALEcG6ht6H/qeEdSKcmN0OlKaOV9IG/+7tK4mk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=k56CHoNXFxnhbQhvlcz7+lA1mHMKbK+FAQZ099w1ZSOQwwUjr9oSCGhPank987EN/zxYnr3dXO4GySzxSh0C2CG6+W1PM4gjHPQWTDV3kwOPhNKyQx/dm4EeWdIy5PtmQ0f5VI5m6q2HIYms/CuuIubvZuBLqkaBk4sosrrSk6U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--yosryahmed.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=YClFmMvd; arc=none smtp.client-ip=209.85.128.202 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=flex--yosryahmed.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="YClFmMvd" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-61510f72bb3so28792927b3.0 for ; Thu, 04 Apr 2024 18:35:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712280953; x=1712885753; darn=vger.kernel.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=l7c0YAXHYAARa4t+azzKsBRh7TpDkWZPSyUcI/Ckh5E=; b=YClFmMvdO6u4PCZBotOsmlWxQfLO7ERhi7C4gqTowBxJi+8055omKzgG19ykkSbO5A qVyNh4U88HxH5Zl1jWRIge9qz6Tp1YEWm4K43yPhni2JvFBUUuYX8os7u9clq8/cWJd0 qLk+4FYemfi5sC9JXvorozy73AGJN0hYEoCbwwzcORX5l3+rYUpOsgPKAFlOiUw8KEIv ecEshsxnM3yRMIQXrN4DxaI5NFSqWBLCIola2/pTUiOAAeSD0UshPjMttq0oMs2I/YCU 7RMlEk1SlS4wHitCZ/nDGUeOOubcYQWGD3y089UfoW5I3kIB5Ta/fhF1bBEh6K6amiRV pgbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712280953; x=1712885753; 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=l7c0YAXHYAARa4t+azzKsBRh7TpDkWZPSyUcI/Ckh5E=; b=QjMRPc65NaEfDpFpz7uSxZ4zwzVlrEKkDZIf+/xgJ0Zs0jZyRd/OdMZEb7SO9E0VV0 Z16Dp+u85XbdMjeRQmB0NCI3yVzOqzsyXQcVFz1Sv2vkiZsmvDDOQ2bRsWihk12cn+ti Zi6xIp8/a4DfMopL1CA3yv5oXR+xsvwfiE5nZ9w8x9E2BW7RQ5iRRqTxb+g1pUtE+fdP sdMxfVS64vbJ77STiUDxXYByVliPnWsEox2jlfuzi+M1yX240SKOUmDGF0iyokjn4P/X KyjXfbxxubM80Vs8gUD89vni7CeN3kSPHljk6UXfGCysu7r28OBo+XO4oUow4sw9ytRW dF7A== X-Forwarded-Encrypted: i=1; AJvYcCW2nXueW/aHq2VigevHxbtth/Oj6Hy3EGL3GRw/nx5aVdSYiq7iT1rAs0YI8Aj5jhA85KrvJG5Dy4fhnGYRVVCoVY6P9MGgsB40N5Ct X-Gm-Message-State: AOJu0Ywpl5nzCEU+5QTBe4uSlcV3JJsIoFtclV40F3cQ/QjpgeWpX7tU kqCkDE8mroDa0tMZdg9PrjMLO7ilTPDeF0VRBBWxEDKtYaEuLKQnou292cTJfN695TvSxFBeB+1 m94WSn+QcDDBJidJrjA== X-Google-Smtp-Source: AGHT+IGnr9sjDIzkHfWFA3r7NPAbrRE0n1gPgA8ilwWP/trrO+2CchhEjdvuhVNlYmxNUVKzC30LK0N41cvBJ/wG X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a05:690c:24f:b0:615:2f17:17ca with SMTP id ba15-20020a05690c024f00b006152f1717camr300974ywb.8.1712280953119; Thu, 04 Apr 2024 18:35:53 -0700 (PDT) Date: Fri, 5 Apr 2024 01:35:44 +0000 In-Reply-To: <20240405013547.1859126-1-yosryahmed@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240405013547.1859126-1-yosryahmed@google.com> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240405013547.1859126-3-yosryahmed@google.com> Subject: [PATCH v1 2/5] mm: zswap: refactor limit checking from zswap_store() From: Yosry Ahmed To: Andrew Morton Cc: Johannes Weiner , Nhat Pham , Chengming Zhou , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yosry Ahmed Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Refactor limit and acceptance threshold checking outside of zswap_store(). This code will be moved around in a following patch, so it would be cleaner to move a function call around. Signed-off-by: Yosry Ahmed --- mm/zswap.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index 1cf3ab4b22e64..fba8f3c3596ab 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1391,6 +1391,21 @@ static void zswap_fill_page(void *ptr, unsigned long= value) memset_l(page, value, PAGE_SIZE / sizeof(unsigned long)); } =20 +static bool zswap_check_full(void) +{ + unsigned long cur_pages =3D zswap_total_pages(); + unsigned long thr =3D zswap_accept_thr_pages(); + unsigned long max_pages =3D zswap_max_pages(); + + if (cur_pages >=3D max_pages) { + zswap_pool_limit_hit++; + zswap_pool_reached_full =3D true; + } else if (zswap_pool_reached_full && cur_pages <=3D thr) { + zswap_pool_reached_full =3D false; + } + return zswap_pool_reached_full; +} + bool zswap_store(struct folio *folio) { swp_entry_t swp =3D folio->swap; @@ -1399,7 +1414,6 @@ bool zswap_store(struct folio *folio) struct zswap_entry *entry, *old; struct obj_cgroup *objcg =3D NULL; struct mem_cgroup *memcg =3D NULL; - unsigned long max_pages, cur_pages; =20 VM_WARN_ON_ONCE(!folio_test_locked(folio)); VM_WARN_ON_ONCE(!folio_test_swapcache(folio)); @@ -1422,22 +1436,8 @@ bool zswap_store(struct folio *folio) mem_cgroup_put(memcg); } =20 - /* Check global limits */ - cur_pages =3D zswap_total_pages(); - max_pages =3D zswap_max_pages(); - - if (cur_pages >=3D max_pages) { - zswap_pool_limit_hit++; - zswap_pool_reached_full =3D true; + if (zswap_check_full()) goto reject; - } - - if (zswap_pool_reached_full) { - if (cur_pages > zswap_accept_thr_pages()) - goto reject; - else - zswap_pool_reached_full =3D false; - } =20 /* allocate entry */ entry =3D zswap_entry_cache_alloc(GFP_KERNEL, folio_nid(folio)); --=20 2.44.0.478.gd926399ef9-goog From nobody Mon Feb 9 02:13:51 2026 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 BE2B712E55 for ; Fri, 5 Apr 2024 01:35:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712280957; cv=none; b=QVlMQdWpZptwUcU9AilbfsJcE/BVfJZ1AXBG5YEOg+BQK5Ynm/cP6q+rHzTMlPIDMyu5pWfG6JaN+5+OskX6q5Lhimbz+OQu2x32KGTt29WuCDpJAp3YGYELiy9GJUfly6mcR7Tm7jCDRfKGLA+e3F+5n5BaTjiPkCmdin1VJHg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712280957; c=relaxed/simple; bh=+4kOMOZUceNAiAaZTak6VWosZOv5ss8q35Fj8zPEZs8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=LzovMnivDGWIYvokwUkkzb7AQlIwiqcxYWE3wdw8pzRclOXh/SCwguaN3NXoiRB6cIk1aqMha6sAZtifWC2EBr84LvY1wR3WLLmb9vPqYDAJFFMHye4hjN+MQCaD76Y80Mk4YJSsgZPedWm9kIK1Zq0+/mv4KFZjE+OkkRd3aZM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--yosryahmed.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=EwFRSzSU; arc=none smtp.client-ip=209.85.128.202 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=flex--yosryahmed.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="EwFRSzSU" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6156cef8098so29024587b3.0 for ; Thu, 04 Apr 2024 18:35:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712280955; x=1712885755; darn=vger.kernel.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=yEGVZyHSwt0QZZ3iWSnf36Lx2mkJ2T39ZbIwvSBmEnQ=; b=EwFRSzSUzUC/wausfw1kSXQtCeM5WkmxSlQUG+T8IGuGvqkj7O14aM0clck30HluK7 0tDOJWmDswDcOeIrA8aMyHR1pBarjFjZxWNL7WcM6TdyH3yscRAIIruOn2odBX4anTb+ +GARuQK27PRQ4ERSiMGFlLfbL6b7fXTmbR/ROxCIKTUsneDyvBLLW8K4mdFz2GAfmpR4 +XJ+eqkBlbUdUFti5CkF/G1uprtDTNn2VvIYGYpf/rHP11X9g2bGyUgffdwJEpWgZBVS 8Css2H6+0pWGHvgLiIRrHrx7nclviWldakitYWiVeRUhGufajZvtMcYtLfwqZG88FIg3 dsLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712280955; x=1712885755; 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=yEGVZyHSwt0QZZ3iWSnf36Lx2mkJ2T39ZbIwvSBmEnQ=; b=r8YjmwTXa/3wiORO/ZauR5bvmRrea6maw4bDc255T+sKaXWirtTPnm6vOto3POeR2J iEDIzicJ/TGNjo+FOuEyt5j17jbKN/iSPDHe6PIU1Yd9PVydJLZICq5JfW1OdIZtKJn0 4Ulw94Q2F/DKZpheYZc5+qvFovX+MXPOAdZeqxpoQCj2WOHFbSpG9eFgUeaztSQAo+if 9/gnrvmF3fl/hV3HvZzG6f12Dm+vtWUzmzpFKsXIQyXBmu/0euxeAmu12JJTiKWjzzqD EsIfMXggGK8fDZlz7feLW5oyQr22nMZnacOV4g91BnQ4ROw5yM0OtYR7ncZtJcOpJU5Q gc4A== X-Forwarded-Encrypted: i=1; AJvYcCXME3FuyIYQMiTp/j/lKsPmgn1UpMWHXO/Y078QT+8BFK23PM6YbI5YYT4DXhYh7Bkfj/XWyM5j7UExM1RhtSaycfRujNjOmvhwxQp1 X-Gm-Message-State: AOJu0Yz2Y1vlYXnL8ZbZYTX4zfgxhUIaU8oa73yQDitnO18eZ+JpykTR m4z44DtFfWyGYL2kBbKqIAxq1yphyjljnHadXSufcdU+RlLd4qBq5fJt+eTyUDZfExANqHJn4O/ 7BaLyWAamyG6kACFltg== X-Google-Smtp-Source: AGHT+IH33+SVthekVVKeXhbUOG3wNDshSnpJ5/OwGTrydVxvAVq4kpl3zfciKOFqgaOZ9hcvtHjOLuShz0z5TQ52 X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a05:690c:e1e:b0:615:1b90:d987 with SMTP id cp30-20020a05690c0e1e00b006151b90d987mr342246ywb.6.1712280954789; Thu, 04 Apr 2024 18:35:54 -0700 (PDT) Date: Fri, 5 Apr 2024 01:35:45 +0000 In-Reply-To: <20240405013547.1859126-1-yosryahmed@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240405013547.1859126-1-yosryahmed@google.com> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240405013547.1859126-4-yosryahmed@google.com> Subject: [PATCH v1 3/5] mm: zswap: move more same-filled pages checks outside of zswap_store() From: Yosry Ahmed To: Andrew Morton Cc: Johannes Weiner , Nhat Pham , Chengming Zhou , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yosry Ahmed Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently, zswap_store() checks zswap_same_filled_pages_enabled, kmaps the folio, then calls zswap_is_page_same_filled() to check the folio contents. Move this logic into zswap_is_page_same_filled() as well (and rename it to use 'folio' while we are at it). This makes zswap_store() cleaner, and makes following changes to that logic contained within the helper. While we are at it, rename the insert_entry label to store_entry to match xa_store(). No functional change intended. Signed-off-by: Yosry Ahmed Reviewed-by: Nhat Pham Reviewed-by: Chengming Zhou Acked-by: Johannes Weiner --- mm/zswap.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index fba8f3c3596ab..b92fa37bee277 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1361,26 +1361,32 @@ static void shrink_worker(struct work_struct *w) } while (zswap_total_pages() > thr); } =20 -static int zswap_is_page_same_filled(void *ptr, unsigned long *value) +static bool zswap_is_folio_same_filled(struct folio *folio, unsigned long = *value) { unsigned long *page; unsigned long val; unsigned int pos, last_pos =3D PAGE_SIZE / sizeof(*page) - 1; + bool ret =3D false; =20 - page =3D (unsigned long *)ptr; + if (!zswap_same_filled_pages_enabled) + return false; + + page =3D kmap_local_folio(folio, 0); val =3D page[0]; =20 if (val !=3D page[last_pos]) - return 0; + goto out; =20 for (pos =3D 1; pos < last_pos; pos++) { if (val !=3D page[pos]) - return 0; + goto out; } =20 *value =3D val; - - return 1; + ret =3D true; +out: + kunmap_local(page); + return ret; } =20 static void zswap_fill_page(void *ptr, unsigned long value) @@ -1414,6 +1420,7 @@ bool zswap_store(struct folio *folio) struct zswap_entry *entry, *old; struct obj_cgroup *objcg =3D NULL; struct mem_cgroup *memcg =3D NULL; + unsigned long value; =20 VM_WARN_ON_ONCE(!folio_test_locked(folio)); VM_WARN_ON_ONCE(!folio_test_swapcache(folio)); @@ -1446,19 +1453,11 @@ bool zswap_store(struct folio *folio) goto reject; } =20 - if (zswap_same_filled_pages_enabled) { - unsigned long value; - u8 *src; - - src =3D kmap_local_folio(folio, 0); - if (zswap_is_page_same_filled(src, &value)) { - kunmap_local(src); - entry->length =3D 0; - entry->value =3D value; - atomic_inc(&zswap_same_filled_pages); - goto insert_entry; - } - kunmap_local(src); + if (zswap_is_folio_same_filled(folio, &value)) { + entry->length =3D 0; + entry->value =3D value; + atomic_inc(&zswap_same_filled_pages); + goto store_entry; } =20 if (!zswap_non_same_filled_pages_enabled) @@ -1481,7 +1480,7 @@ bool zswap_store(struct folio *folio) if (!zswap_compress(folio, entry)) goto put_pool; =20 -insert_entry: +store_entry: entry->swpentry =3D swp; entry->objcg =3D objcg; =20 --=20 2.44.0.478.gd926399ef9-goog From nobody Mon Feb 9 02:13:51 2026 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 83A66175BE for ; Fri, 5 Apr 2024 01:35:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712280959; cv=none; b=ZcSYhkegYM4FlK2xmb7n1ZveyGv7H5tqdwQbOOp2dJQ9dsayE+BKFLuskioZtFvqT67oAqm1QS0BAbqRBuqMBzMSWwWA9Inm44FUdMnSkPIkPoyUZN5QU0qaZN4Be07RkbVRDKlpwBJ4nUz9C1zTswXXpd56pMEUQn22PP8JKrM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712280959; c=relaxed/simple; bh=JNiEew8FxcxcGoJSLQWAp+oqkYs1/tc4TYyq14CFOd8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=SO9cW0p0a6WkEhA0WgzqverDjzvLRrLsl/OOxtYu3rDXq6PB60EDxrVmLtetj5FjSRtd+xN2l8dEURthFpQuPasHOWRFgppHeEaBoalvAMuK3b9aKXhHs+OQV9iO8y/koFMQFyRWpD0+4tJZRycgxPfHKKaUH3nvgLdLm26Zzlg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--yosryahmed.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=QvIk1C+Q; arc=none smtp.client-ip=209.85.219.201 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=flex--yosryahmed.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QvIk1C+Q" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc3645a6790so2794293276.0 for ; Thu, 04 Apr 2024 18:35:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712280956; x=1712885756; darn=vger.kernel.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=/m5gy6JRDNvLrFZhE09AdQy3FefAqzIV084ImGWBY7k=; b=QvIk1C+QuErYwc5F+h1YzJ7kj9kruLN8vg3x7rVBAahwU4Uv39lawGst6W3bpN/zqD wWPc5cyDtZpCciBTQEH00vO83RKA2zOSlM2ruruIC4jUlrHsUukOwH6+u2NnWKVkXmjF /K9pC5GijloMujgSyWDRNqZvwxIgMh/5Grxg8LyY1JSe6GeeldBkWmJKEndG32A1MK0N aCzF2GvwA9OmBNb+yA08XNB7zpckYWvsj4QSnViYV0rf9RARtxfTmkcrkV31E0qs9bvP XsK2dxcbUv9nG90Ey2pP8IokENR4dc7Evv6aPVJWK0X+Y/Mn6Pf2V5spExOhBdn/lfmC szCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712280956; x=1712885756; 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=/m5gy6JRDNvLrFZhE09AdQy3FefAqzIV084ImGWBY7k=; b=anIf7KJnjNe3azXWXcx37kqI60ShRaxZLSkR5gCyXhhN40m9HyqacekS0xx9V+OniW k/iT+dJQzeSdIGk2RxDxlr25On9WpJUCgfxpdiMTKmUF8iUFj8nc7/RPVrwXduW8VpRv h1F4ZL+fz04dQDjPAkl0cg3rxQlbGeliYeOvEHU8oe4rBa++0R1GoMPGmRLkbZ4ZY1lM a2w0SaAvxV0Ezx5ZrnIoKmt39tFP3YI+V74n9BD12d0OsLq/G+MQSM4yxyW5avQgBALi HKZcN/dYLYzI32+1u4Et/oneQvRFaitkxVil4GvaGBOVeZ/aY9BiatfvyrKZZC1cT2u+ Q1Jw== X-Forwarded-Encrypted: i=1; AJvYcCUd1MPnN8mOecNifmTR6JkysRdwESBwP8wJB+oPYzpHBFBo2sVCLdf/Wtqbd7kIIGonwgX+keRZ8+UlZmKIAgwL8ybNRxLgGy0XXaWI X-Gm-Message-State: AOJu0YyamzA6PcdFbOEG/rHsCvk3zPARNrBNVo0pMFNI/ulE0KWinNO+ bOJ0hYMypZJO5h7CetvcsZGIypxppNAodtkTv2Pts0TzVnhX7JZKLATC5eokZzQCKgmmCeIaN1f A02ZikUGdMeeEt2fdzA== X-Google-Smtp-Source: AGHT+IF7f54z2FdS42Ou0yg3jjIJwSZWrUbEzwVPRh5Hihv5pxBYL/oylI81O/dhSX/lYtxqrDRNaVzdafD0Up7i X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a05:6902:20c5:b0:dc6:d233:ffdd with SMTP id dj5-20020a05690220c500b00dc6d233ffddmr362563ybb.0.1712280956608; Thu, 04 Apr 2024 18:35:56 -0700 (PDT) Date: Fri, 5 Apr 2024 01:35:46 +0000 In-Reply-To: <20240405013547.1859126-1-yosryahmed@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240405013547.1859126-1-yosryahmed@google.com> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240405013547.1859126-5-yosryahmed@google.com> Subject: [PATCH v1 4/5] mm: zswap: remove same_filled module params From: Yosry Ahmed To: Andrew Morton Cc: Johannes Weiner , Nhat Pham , Chengming Zhou , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yosry Ahmed Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" These knobs offer more fine-grained control to userspace than needed and directly expose/influence kernel implementation; remove them. For disabling same_filled handling, there is no logical reason to refuse storing same-filled pages more efficiently and opt for compression. Scanning pages for patterns may be an argument, but the page contents will be read into the CPU cache anyway during compression. Also, removing the same_filled handling code does not move the needle significantly in terms of performance anyway [1]. For disabling non_same_filled handling, it was added when the compressed pages in zswap were not being properly charged to memcgs, as workloads could escape the accounting with compression [2]. This is no longer the case after commit f4840ccfca25 ("zswap: memcg accounting"), and using zswap without compression does not make much sense. [1]https://lore.kernel.org/lkml/CAJD7tkaySFP2hBQw4pnZHJJwe3bMdjJ1t9VC2VJd= =3Dkhn1_TXvA@mail.gmail.com/ [2]https://lore.kernel.org/lkml/19d5cdee-2868-41bd-83d5-6da75d72e940@maciej= .szmigiero.name/ Signed-off-by: Yosry Ahmed Acked-by: Johannes Weiner --- mm/zswap.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index b92fa37bee277..a85c9235d19d3 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -123,19 +123,6 @@ static unsigned int zswap_accept_thr_percent =3D 90; /= * of max pool size */ module_param_named(accept_threshold_percent, zswap_accept_thr_percent, uint, 0644); =20 -/* - * Enable/disable handling same-value filled pages (enabled by default). - * If disabled every page is considered non-same-value filled. - */ -static bool zswap_same_filled_pages_enabled =3D true; -module_param_named(same_filled_pages_enabled, zswap_same_filled_pages_enab= led, - bool, 0644); - -/* Enable/disable handling non-same-value filled pages (enabled by default= ) */ -static bool zswap_non_same_filled_pages_enabled =3D true; -module_param_named(non_same_filled_pages_enabled, zswap_non_same_filled_pa= ges_enabled, - bool, 0644); - /* Number of zpools in zswap_pool (empirically determined for scalability)= */ #define ZSWAP_NR_ZPOOLS 32 =20 @@ -1368,9 +1355,6 @@ static bool zswap_is_folio_same_filled(struct folio *= folio, unsigned long *value unsigned int pos, last_pos =3D PAGE_SIZE / sizeof(*page) - 1; bool ret =3D false; =20 - if (!zswap_same_filled_pages_enabled) - return false; - page =3D kmap_local_folio(folio, 0); val =3D page[0]; =20 @@ -1460,9 +1444,6 @@ bool zswap_store(struct folio *folio) goto store_entry; } =20 - if (!zswap_non_same_filled_pages_enabled) - goto freepage; - /* if entry is successfully added, it keeps the reference */ entry->pool =3D zswap_pool_current_get(); if (!entry->pool) --=20 2.44.0.478.gd926399ef9-goog From nobody Mon Feb 9 02:13:51 2026 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 708C8DF5B for ; Fri, 5 Apr 2024 01:35:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712280960; cv=none; b=kWPdSouTPAjaHnvOWxSHkrs7SyqPg5WH06YazpN8lAJ0ahQbjNLqyMm1teuqkYo0QGjNwZrpPoVYDfFDoVNzFEaZCoTTrDxKLVGBFKcfitWrF1OiNEtOJbTZiJRhK85kWXgutqc3UhMe5HV5+XmyB6erFADfx908NKqJQsxvm1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712280960; c=relaxed/simple; bh=EKrGZSwVFwew2HMPiLb4JaHCc0fDKmV9LIy0S8SK7FM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=oeSNJD6hZubvPqjMyAQIgBPt72W+lVt35J8UWTqimD28sxoLh5z1bGDWsewo0Wewwca509vOxt28VBy6ss3neh2c/Au4MPP/Ifnx0mak6u3lf6u73jF4VrSywBHpEjBOrQomGunU/Lu9sey0iuLQaTpheY63zMHHjDHzxqaimdc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--yosryahmed.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=cp6dUbSb; arc=none smtp.client-ip=209.85.219.201 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=flex--yosryahmed.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cp6dUbSb" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dcc58cddb50so2641502276.0 for ; Thu, 04 Apr 2024 18:35:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712280958; x=1712885758; darn=vger.kernel.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=LZ1QXrjwhIal4gIkbl9SlMnvEbBP+lXyDn0RpoWpImY=; b=cp6dUbSbSNHw7ZVlTrAfUK7741QJsSJ0N6uQVXswNL8uzz1QjPSHNn+2VTZT3hc//f Dhm5sdWjZko1pUmWRuVFHU/pFTOGnDzqfG2HlFz7dV+9jFYz/7KF0sNm9aYCwxmKuehj 8uFDScG+bFnMP0z0MUBKhqyRuykYzO6KNFe4AM6++Zupw2eXJQ8sH/x0HkQZ5SLSarnn RsTXI5r9Jczb4b/+7CvnPiaDJExwag6rFzU84Jm08yVm1jkzzcbUrP2OQsEgldhopoEn 9MW2mbrYiXjYk4Eo5aoUCfXsipvrUawefuTtXv0GDRqVfDdfG8QCuI2N//XdE4HJvJfp ThPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712280958; x=1712885758; 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=LZ1QXrjwhIal4gIkbl9SlMnvEbBP+lXyDn0RpoWpImY=; b=jzYMbIQrKDqu3L346DkcqzwBxZoXScFg1kv4XkQV0pNhC1DyFtx1NY3xywbR1gDFx6 MVCYTwNtQ9yjOh7PqICGgEildVsqu1R6eWW69K5xh8+lUU9gQAjch2aawyNFG/UD0HT5 wrwD5wFTTJ2YLq56jRxN5KTC7GynnaLVSlY6w41aqpLhaNZY+igCV7UJPpdWsf0+xKMA ddElXGHYbNBb0CSxtpZQKenF2pcTFSUXtpVS+btGqXELqNz0xpMEZOIcjge75KcPIvA0 2/CFSGNcwfZjLGJV5dIyzz5dSBleujMoDiT+YYjnSmuO0gn7ggYpSYhcpTHXspYRpJs6 aV/w== X-Forwarded-Encrypted: i=1; AJvYcCW3iGopi/XKq5kT8dkTOp/hS/1I5FBh2Qz3IQU4VkQRqwKg7LXxZ2QzSgqR2i06ikFnt4zWnahS73f0ecgltSCQ60V21zcmS5k/nrPF X-Gm-Message-State: AOJu0YzcS+2aM5NnxrZCIijJMBvm6Tk+iyInsfX8dZ515lJk94UUEtKZ E4QEucwk7VtSloEGRKBeU/vRLU+unwbUG0GFGfTNsMex/JfaXMeoI/V9I3PoXD+810VQ3T86t89 w9uuk+NCqm/35aUKxvA== X-Google-Smtp-Source: AGHT+IF08nd+KBQE70LXZSIBvDA4LHuHsKmvLNuPmdBMBqFS4+vTxuqxYNRCiDtgu7m3HgM9JubMSqb0OVDe26Bd X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a05:6902:2b05:b0:dc6:e1ed:bd1a with SMTP id fi5-20020a0569022b0500b00dc6e1edbd1amr351076ybb.2.1712280958518; Thu, 04 Apr 2024 18:35:58 -0700 (PDT) Date: Fri, 5 Apr 2024 01:35:47 +0000 In-Reply-To: <20240405013547.1859126-1-yosryahmed@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240405013547.1859126-1-yosryahmed@google.com> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240405013547.1859126-6-yosryahmed@google.com> Subject: [PATCH v1 5/5] mm: zswap: do not check the global limit for same-filled pages From: Yosry Ahmed To: Andrew Morton Cc: Johannes Weiner , Nhat Pham , Chengming Zhou , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yosry Ahmed Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When storing same-filled pages, there is no point of checking the global zswap limit as storing them does not contribute toward the limit Move the limit checking after same-filled pages are handled. This avoids having same-filled pages skip zswap and go to disk swap if the limit is hit. It also avoids queueing the shrink worker, which may end up being unnecessary if the zswap usage goes down on its own before another store is attempted. Ignoring the memcg limits as well for same-filled pages is more controversial. Those limits are more a matter of per-workload policy. Some workloads disable zswap completely by setting memory.zswap.max =3D 0, and those workloads could start observing some zswap activity even after disabling zswap. Although harmless, this could cause confusion to userspace. Remain conservative and keep respecting those limits. Signed-off-by: Yosry Ahmed --- mm/zswap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index a85c9235d19d3..8763a1e938441 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1404,6 +1404,7 @@ bool zswap_store(struct folio *folio) struct zswap_entry *entry, *old; struct obj_cgroup *objcg =3D NULL; struct mem_cgroup *memcg =3D NULL; + bool same_filled =3D false; unsigned long value; =20 VM_WARN_ON_ONCE(!folio_test_locked(folio)); @@ -1427,7 +1428,8 @@ bool zswap_store(struct folio *folio) mem_cgroup_put(memcg); } =20 - if (zswap_check_full()) + same_filled =3D zswap_is_folio_same_filled(folio, &value); + if (!same_filled && zswap_check_full()) goto reject; =20 /* allocate entry */ @@ -1437,7 +1439,7 @@ bool zswap_store(struct folio *folio) goto reject; } =20 - if (zswap_is_folio_same_filled(folio, &value)) { + if (same_filled) { entry->length =3D 0; entry->value =3D value; atomic_inc(&zswap_same_filled_pages); --=20 2.44.0.478.gd926399ef9-goog