linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Huang, Ying" <ying.huang@intel.com>
To: Yosry Ahmed <yosryahmed@google.com>
Cc: Chris Li <chriscli@google.com>,
	 Zhongkun He <hezhongkun.hzk@bytedance.com>,
	 Andrew Morton <akpm@linux-foundation.org>,
	 Johannes Weiner <hannes@cmpxchg.org>,
	 Nhat Pham <nphamcs@gmail.com>,
	 Seth Jennings <sjenning@redhat.com>,
	 Dan Streetman <ddstreet@ieee.org>,
	 Vitaly Wool <vitaly.wool@konsulko.com>,
	linux-mm <linux-mm@kvack.org>,
	 LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm:zswap: fix zswap entry reclamation failure in two scenarios
Date: Tue, 21 Nov 2023 09:53:48 +0800	[thread overview]
Message-ID: <875y1vc1n7.fsf@yhuang6-desk2.ccr.corp.intel.com> (raw)
In-Reply-To: <CAJD7tkamaGjmP0anhez+JHxJx++UQcykyxRDieQxcTt5Q4+YuQ@mail.gmail.com> (Yosry Ahmed's message of "Mon, 20 Nov 2023 17:15:15 -0800")

Yosry Ahmed <yosryahmed@google.com> writes:

> On Mon, Nov 20, 2023 at 4:57 PM Huang, Ying <ying.huang@intel.com> wrote:
>>
>> Yosry Ahmed <yosryahmed@google.com> writes:
>>
>> > On Sun, Nov 19, 2023 at 7:20 PM Huang, Ying <ying.huang@intel.com> wrote:
>> >>
>> >> Chris Li <chriscli@google.com> writes:
>> >>
>> >> > On Thu, Nov 16, 2023 at 12:19 PM Yosry Ahmed <yosryahmed@google.com> wrote:
>> >> >>
>> >> >> Not bypassing the swap slot cache, just make the callbacks to
>> >> >> invalidate the zswap entry, do memg uncharging, etc when the slot is
>> >> >> no longer used and is entering the swap slot cache (i.e. when
>> >> >> free_swap_slot() is called), instead of when draining the swap slot
>> >> >> cache (i.e. when swap_range_free() is called). For all parts of MM
>> >> >> outside of swap, the swap entry is freed when free_swap_slot() is
>> >> >> called. We don't free it immediately because of caching, but this
>> >> >> should be transparent to other parts of MM (e.g. zswap, memcg, etc).
>> >> >
>> >> > That will cancel the batching effect on the swap slot free, making the
>> >> > common case for  swapping  faults take longer to complete, righ?
>> >> > If I recall correctly, the uncharge is the expensive part of the swap
>> >> > slot free operation.
>> >> > I just want to figure out what we are trading off against. This is not
>> >> > one side wins all situations.
>> >>
>> >> Per my understanding, we don't batch memcg uncharging in
>> >> swap_entry_free() now.  Although it's possible and may improve
>> >> performance.
>> >
>> > Yes. It actually causes a long tail in swapin fault latency as Chris
>> > discovered in our prod. I am wondering if doing the memcg uncharging
>> > outside the slots cache will actually amortize the cost instead.
>> >
>> > Regardless of memcg charging, which is more complicated, I think we
>> > should at least move the call to zswap_invalidate() before the slots
>> > cache. I would prefer that we move everything non-swapfile specific
>> > outside the slots cache layer (zswap_invalidate(),
>> > arch_swap_invalidate_page(),  clear_shadow_from_swap_cache(),
>> > mem_cgroup_uncharge_swap(), ..).  However, if some of those are
>> > controversial, we can move some of them for now.
>>
>> That makes sense for me.
>>
>> > When draining free swap slots from the cache, swap_range_free() is
>> > called with nr_entries == 1 anyway, so I can't see how any batching is
>> > going on. If anything it should help amortize the cost.
>>
>> In swapcache_free_entries(), the sis->lock will be held to free multiple
>> swap slots via swap_info_get_cont() if possible.  This can reduce
>> sis->lock contention.
>
> Ah yes that's a good point. Since most of these callbacks don't
> actually access sis, but use the swap entry value itself, I am
> guessing the reason we need to hold the lock for all these callbacks
> is to prevent swapoff and swapon reusing the same swap entry on a
> different swap device, right?

In,

swapcache_free_entries()
  swap_entry_free()
    swap_range_free()

Quite some sis fields will be accessed.

--
Best Regards,
Huang, Ying


  reply	other threads:[~2023-11-21  1:55 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-13 13:06 Zhongkun He
2023-11-13 15:11 ` Nhat Pham
2023-11-14  5:21   ` [External] " 贺中坤
2023-11-14 16:30     ` Nhat Pham
2023-11-15 12:12       ` 贺中坤
2023-11-14 17:16 ` Yosry Ahmed
2023-11-15 12:53   ` [External] " 贺中坤
2023-11-15 20:12     ` Yosry Ahmed
2023-11-16  3:33       ` 贺中坤
2023-11-16  4:09         ` Yosry Ahmed
2023-11-16  4:23           ` 贺中坤
2023-11-16  8:31   ` Huang, Ying
2023-11-16 10:34     ` [External] " 贺中坤
2023-11-16 20:11   ` Chris Li
2023-11-16 20:18     ` Yosry Ahmed
2023-11-16 20:30       ` Chris Li
2023-11-16 20:45         ` Yosry Ahmed
2023-11-17 23:30           ` Chris Li
2023-11-17  9:56         ` [External] " Zhongkun He
2023-11-17 23:47           ` Chris Li
2023-11-18  1:45             ` Zhongkun He
2023-11-18 18:43               ` Nhat Pham
2023-11-19  8:29                 ` Chris Li
2023-11-20  2:42                 ` Zhongkun He
2023-11-19  8:23               ` Chris Li
2023-11-20  3:16                 ` Zhongkun He
2023-11-20  3:18         ` Huang, Ying
2023-11-20  5:31           ` Chris Li
2023-11-20  5:39             ` Huang, Ying
2023-11-20  5:51               ` Chris Li
2023-11-20 18:52           ` Yosry Ahmed
2023-11-21  0:54             ` Huang, Ying
2023-11-21  1:15               ` Yosry Ahmed
2023-11-21  1:53                 ` Huang, Ying [this message]
2023-11-21  2:46                   ` Yosry Ahmed
2023-11-21  3:32                     ` Huang, Ying
2023-11-21  3:37                       ` Yosry Ahmed

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=875y1vc1n7.fsf@yhuang6-desk2.ccr.corp.intel.com \
    --to=ying.huang@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=chriscli@google.com \
    --cc=ddstreet@ieee.org \
    --cc=hannes@cmpxchg.org \
    --cc=hezhongkun.hzk@bytedance.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nphamcs@gmail.com \
    --cc=sjenning@redhat.com \
    --cc=vitaly.wool@konsulko.com \
    --cc=yosryahmed@google.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