From: Chengming Zhou <chengming.zhou@linux.dev>
To: Yosry Ahmed <yosryahmed@google.com>
Cc: hannes@cmpxchg.org, nphamcs@gmail.com, akpm@linux-foundation.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Zhongkun He <hezhongkun.hzk@bytedance.com>
Subject: Re: [RFC PATCH] mm: add folio in swapcache if swapin from zswap
Date: Sat, 23 Mar 2024 10:49:47 +0800 [thread overview]
Message-ID: <91c0a5aa-86b0-4dd3-884f-39a47c1ed6b8@linux.dev> (raw)
In-Reply-To: <CAJD7tkYuYEsKFvjKKRxOx3fCekA03jPpOpmV7T20q=9K=Jb2bA@mail.gmail.com>
On 2024/3/23 03:37, Yosry Ahmed wrote:
> On Fri, Mar 22, 2024 at 9:40 AM <chengming.zhou@linux.dev> wrote:
>>
>> From: Chengming Zhou <chengming.zhou@linux.dev>
>>
>> There is a report of data corruption caused by double swapin, which is
>> only possible in the skip swapcache path on SWP_SYNCHRONOUS_IO backends.
>>
>> The root cause is that zswap is not like other "normal" swap backends,
>> it won't keep the copy of data after the first time of swapin. So if
>> the folio in the first time of swapin can't be installed in the pagetable
>> successfully and we just free it directly. Then in the second time of
>> swapin, we can't find anything in zswap and read wrong data from swapfile,
>> so this data corruption problem happened.
>>
>> We can fix it by always adding the folio into swapcache if we know the
>> pinned swap entry can be found in zswap, so it won't get freed even though
>> it can't be installed successfully in the first time of swapin.
>
> A concurrent faulting thread could have already checked the swapcache
> before we add the folio to it, right? In this case, that thread will
> go ahead and call swap_read_folio() anyway.
Right, but it has to lock the folio to proceed.
>
> Also, I suspect the zswap lookup might hurt performance. Would it be
> better to add the folio back to zswap upon failure? This should be
> detectable by checking if the folio is dirty as I mentioned in the bug
> report thread.
Yes, may hurt performance. As for adding back upon failure, the problem
is that adding may fail too... and I don't know how to handle that.
Anyway, I think the fix of Johannes is much better, we should take that way.
Thanks.
prev parent reply other threads:[~2024-03-23 2:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-22 16:39 [RFC PATCH] mm: add folio in swapcache if swapin from zswap chengming.zhou
2024-03-22 19:37 ` Yosry Ahmed
2024-03-22 21:41 ` Barry Song
2024-03-22 22:33 ` Yosry Ahmed
2024-03-22 23:48 ` Johannes Weiner
2024-03-23 0:12 ` Yosry Ahmed
2024-03-23 0:14 ` Yosry Ahmed
2024-03-23 1:55 ` Johannes Weiner
2024-03-23 2:02 ` Yosry Ahmed
2024-03-23 2:40 ` [External] " Zhongkun He
2024-03-23 8:38 ` Zhongkun He
2024-03-23 2:49 ` Chengming Zhou [this message]
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=91c0a5aa-86b0-4dd3-884f-39a47c1ed6b8@linux.dev \
--to=chengming.zhou@linux.dev \
--cc=akpm@linux-foundation.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=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;
as well as URLs for NNTP newsgroup(s).