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

On Thu, Feb 08, 2024 at 02:32:54AM +0000, chengming.zhou@linux.dev wrote:
> 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>

Acked-by: Johannes Weiner <hannes@cmpxchg.org>

Nice, this is easier to backport and should be less disruptive to
mm-unstable as well. It makes sense to me to put the optimization and
cleanup that was cut out into a separate patch on top of mm-unstable.

>  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);

  reply	other threads:[~2024-02-08 13:14 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   ` [PATCH mm-hotfixes-unstable] mm/zswap: invalidate duplicate entry when !zswap_enabled chengming.zhou
2024-02-08 13:14     ` Johannes Weiner [this message]
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=20240208131414.GA224435@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=akpm@linux-foundation.org \
    --cc=chengming.zhou@linux.dev \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.