All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Yosry Ahmed <yosryahmed@google.com>
To: Barry Song <21cnbao@gmail.com>
Cc: Zhongkun He <hezhongkun.hzk@bytedance.com>,
	Chengming Zhou <chengming.zhou@linux.dev>,
	 Johannes Weiner <hannes@cmpxchg.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	 linux-mm <linux-mm@kvack.org>,
	wuyun.abel@bytedance.com, zhouchengming@bytedance.com,
	 Nhat Pham <nphamcs@gmail.com>, Kairui Song <kasong@tencent.com>,
	Minchan Kim <minchan@kernel.org>,
	 David Hildenbrand <david@redhat.com>,
	Chris Li <chrisl@kernel.org>, Ying <ying.huang@intel.com>
Subject: Re: [External] Re: [bug report] mm/zswap :memory corruption after zswap_load().
Date: Fri, 22 Mar 2024 17:42:27 -0700	[thread overview]
Message-ID: <CAJD7tkb0fN+9GRMYXfW4wixeBCwFbm1f-q10aNV0_J9=gNLF+A@mail.gmail.com> (raw)
In-Reply-To: <CAGsJ_4wuiVgdX0PU3HaGjiy3nE1qDN_eHzkyP4974ZShB-WTiQ@mail.gmail.com>

[..]
>
> > This is only a problem when we skip the swapcache during swapin.
> > Otherwise the swapcache synchronizes this. I wonder how much does
> > skipping the swapcache buy us on recent kernels? This optimization was
> > introduced a long time ago.
>
> Still performs quite good. according to kairui's data:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=13ddaf26be324a7f951891ecd9ccd04466d27458
>
> Before: 10934698 us
> After: 11157121 us
> Cached: 13155355 us (Dropping SWP_SYNCHRONOUS_IO flag)

That's 17.9% slower if we use the swapcache. Commit 0bcac06f27d7 ("mm,
swap: skip swapcache for swapin of synchronous device") says:
"""
This patch aims to reduce swap-in latency by skipping swapcache if the
swap device is synchronous device like rw_page based device.  It
enhances 45% my swapin test(5G sequential swapin, no readahead, from
2.41sec to 1.64sec).
"""

So went from 45% to 17.9%, we are getting close :)

>
> BTW, zram+zswap seems pointless from the first beginning. it seems a wrong
> configuration for users.  if this case is really happening, could we
> simply fix it

Yeah we can do that. Zhongkun said they have a use case for zram+zswap
tho, but I don't know what it is.

If we can find a better (yet still simple) fix, then I would prefer
that. Otherwise enforcing the use of the swapcache when zswap is
enabled sounds like a viable option.

> by:
>
> diff --git a/mm/memory.c b/mm/memory.c
> index b7cab8be8632..6742d1428373 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -3999,7 +3999,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
>         swapcache = folio;
>
>         if (!folio) {
> -               if (data_race(si->flags & SWP_SYNCHRONOUS_IO) &&
> +               if (!is_zswap_enabled() && data_race(si->flags &
> SWP_SYNCHRONOUS_IO) &&
>                     __swap_count(entry) == 1) {
>                         /*
>                          * Prevent parallel swapin from proceeding with


  reply	other threads:[~2024-03-23  0:43 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-21  4:34 [bug report] mm/zswap :memory corruption after zswap_load() Zhongkun He
2024-03-21  4:42 ` Chengming Zhou
2024-03-21  5:09   ` [External] " Zhongkun He
2024-03-21  5:24     ` Chengming Zhou
2024-03-21  6:36       ` Zhongkun He
2024-03-21  9:28         ` Chengming Zhou
2024-03-21 15:25           ` Nhat Pham
2024-03-21 18:32             ` Yosry Ahmed
2024-03-22  3:27               ` Chengming Zhou
2024-03-22  3:16             ` Zhongkun He
2024-03-22  3:04           ` Zhongkun He
2024-03-22 19:34             ` Yosry Ahmed
2024-03-22 23:04               ` Barry Song
2024-03-22 23:08                 ` Yosry Ahmed
2024-03-22 23:18                   ` Barry Song
2024-03-22 23:22                     ` Yosry Ahmed
2024-03-22 23:32                       ` Barry Song
2024-03-22 23:34                         ` Yosry Ahmed
2024-03-22 23:38                           ` Barry Song
2024-03-22 23:41                             ` Yosry Ahmed
2024-03-23  0:34                               ` Barry Song
2024-03-23  0:42                                 ` Yosry Ahmed [this message]
2024-03-23 10:48                                 ` Chris Li
2024-03-23 11:27                                   ` Chris Li
2024-03-23 12:41                                   ` Zhongkun He
2024-03-23  1:34               ` Zhongkun He
2024-03-23  1:36                 ` Yosry Ahmed
2024-03-23 10:52                 ` Chris Li
2024-03-23 10:55                   ` Barry Song

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='CAJD7tkb0fN+9GRMYXfW4wixeBCwFbm1f-q10aNV0_J9=gNLF+A@mail.gmail.com' \
    --to=yosryahmed@google.com \
    --cc=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=chengming.zhou@linux.dev \
    --cc=chrisl@kernel.org \
    --cc=david@redhat.com \
    --cc=hannes@cmpxchg.org \
    --cc=hezhongkun.hzk@bytedance.com \
    --cc=kasong@tencent.com \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=nphamcs@gmail.com \
    --cc=wuyun.abel@bytedance.com \
    --cc=ying.huang@intel.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.