linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: chengming.zhou@linux.dev
To: hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com,
	akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	chengming.zhou@linux.dev,
	Chengming Zhou <zhouchengming@bytedance.com>,
	stable@vger.kernel.org
Subject: [PATCH mm-hotfixes-unstable] mm/zswap: invalidate duplicate entry when !zswap_enabled
Date: Thu,  8 Feb 2024 02:32:54 +0000	[thread overview]
Message-ID: <20240208023254.3873823-1-chengming.zhou@linux.dev> (raw)
In-Reply-To: <20240207154308.bc275f3e72ec1c1fd06cf5a2@linux-foundation.org>

From: Chengming Zhou <zhouchengming@bytedance.com>

We have to invalidate any duplicate entry even when !zswap_enabled
since zswap can be disabled anytime. If the folio store success before,
then got dirtied again but zswap disabled, we won't invalidate the old
duplicate entry in the zswap_store(). So later lru writeback may
overwrite the new data in swapfile.

Fixes: 42c06a0e8ebe ("mm: kill frontswap")
Cc: <stable@vger.kernel.org>
Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
---
 mm/zswap.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/mm/zswap.c b/mm/zswap.c
index fe7ee2640c69..32633d0597dc 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -1516,7 +1516,7 @@ bool zswap_store(struct folio *folio)
 	if (folio_test_large(folio))
 		return false;
 
-	if (!zswap_enabled || !tree)
+	if (!tree)
 		return false;
 
 	/*
@@ -1531,6 +1531,10 @@ bool zswap_store(struct folio *folio)
 		zswap_invalidate_entry(tree, dupentry);
 	}
 	spin_unlock(&tree->lock);
+
+	if (!zswap_enabled)
+		return false;
+
 	objcg = get_obj_cgroup_from_folio(folio);
 	if (objcg && !obj_cgroup_may_zswap(objcg)) {
 		memcg = get_mem_cgroup_from_objcg(objcg);
-- 
2.40.1



  reply	other threads:[~2024-02-08  2:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-07 11:54 [PATCH v4] mm/zswap: invalidate old entry when store fail or !zswap_enabled chengming.zhou
2024-02-07 23:06 ` Nhat Pham
2024-02-08  2:34   ` Chengming Zhou
2024-02-07 23:43 ` Andrew Morton
2024-02-08  2:32   ` chengming.zhou [this message]
2024-02-08 13:14     ` [PATCH mm-hotfixes-unstable] mm/zswap: invalidate duplicate entry when !zswap_enabled Johannes Weiner
2024-02-08 21:09     ` Andrew Morton
2024-02-09  4:50       ` Chengming Zhou
2024-02-08  2:41   ` [PATCH v4] mm/zswap: invalidate old entry when store fail or !zswap_enabled Chengming Zhou
2024-02-09  4:41 ` [PATCH mm-unstable] mm/zswap: optimize and cleanup the invalidation of duplicate entry chengming.zhou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240208023254.3873823-1-chengming.zhou@linux.dev \
    --to=chengming.zhou@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nphamcs@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=yosryahmed@google.com \
    --cc=zhouchengming@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox