From: "Mika Penttilä" <mpenttil@redhat.com>
To: Yosry Ahmed <yosryahmed@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Nhat Pham <nphamcs@gmail.com>,
Chengming Zhou <chengming.zhou@linux.dev>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Barry Song <21cnbao@gmail.com>, Chris Li <chrisl@kernel.org>,
Ryan Roberts <ryan.roberts@arm.com>,
David Hildenbrand <david@redhat.com>,
Matthew Wilcox <willy@infradead.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm: zswap: handle incorrect attempts to load of large folios
Date: Tue, 11 Jun 2024 07:14:19 +0300 [thread overview]
Message-ID: <811778e4-6af4-563a-757e-83fec207e79f@redhat.com> (raw)
In-Reply-To: <CAJD7tkYepf6z1Q7HiSRAc7-S9OwYCphx=9NcyHxtW0YrkFv0sQ@mail.gmail.com>
On 6/10/24 20:35, Yosry Ahmed wrote:
> On Fri, Jun 7, 2024 at 9:08 PM Mika Penttilä <mpenttil@redhat.com> wrote:
>> On 6/8/24 05:36, Yosry Ahmed wrote:
>>> diff --git a/mm/zswap.c b/mm/zswap.c
>>> index b9b35ef86d9be..ebb878d3e7865 100644
>>> --- a/mm/zswap.c
>>> +++ b/mm/zswap.c
>>> @@ -1557,6 +1557,26 @@ bool zswap_load(struct folio *folio)
>>>
>>> VM_WARN_ON_ONCE(!folio_test_locked(folio));
>>>
>>> + /*
>>> + * Large folios should not be swapped in while zswap is being used, as
>>> + * they are not properly handled. Zswap does not properly load large
>>> + * folios, and a large folio may only be partially in zswap.
>>> + *
>>> + * If any of the subpages are in zswap, reading from disk would result
>>> + * in data corruption, so return true without marking the folio uptodate
>>> + * so that an IO error is emitted (e.g. do_swap_page() will sigfault).
>>> + *
>>> + * Otherwise, return false and read the folio from disk.
>>> + */
>>> + if (folio_test_large(folio)) {
>>> + if (xa_find(tree, &offset,
>>> + offset + folio_nr_pages(folio) - 1, XA_PRESENT)) {
>>> + WARN_ON_ONCE(1);
>>> + return true;
>>> + }
>> How does that work? Should it be xa_find_after() to not always find
>> current entry?
> By "current entry" I believe you mean the entry corresponding to
> "offset" (i.e. the first subpage of the folio). At this point, we
> haven't checked if that offset has a corresponding entry in zswap or
> not. It may be on disk, or zwap may be disabled.
Okay you test if there's any matching offset in zswap for the folio.
>> And does it still mean those subsequent entries map to same folio?
> If I understand correctly, a folio in the swapcache has contiguous
> swap offsets for its subpages. So I am assuming that the large folio
> swapin case will adhere to that (i.e. we only swapin a large folio if
> the swap offsets are contiguous). Did I misunderstand something here?
Yes I think that is fair assumption for now. But also saw your v3 which
doesn't depend on this.
>
>>
>> --Mika
>>
>>
next prev parent reply other threads:[~2024-06-11 4:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-08 2:36 Yosry Ahmed
2024-06-08 3:13 ` Barry Song
2024-06-10 17:42 ` Yosry Ahmed
2024-06-10 20:05 ` Barry Song
2024-06-10 20:11 ` Yosry Ahmed
2024-06-10 21:00 ` Barry Song
2024-06-10 21:11 ` Yosry Ahmed
2024-06-10 23:34 ` Barry Song
2024-06-10 23:41 ` Yosry Ahmed
2024-06-11 0:02 ` Barry Song
2024-06-08 4:08 ` Mika Penttilä
2024-06-10 17:35 ` Yosry Ahmed
2024-06-11 4:14 ` Mika Penttilä [this message]
2024-06-11 15:47 ` 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=811778e4-6af4-563a-757e-83fec207e79f@redhat.com \
--to=mpenttil@redhat.com \
--cc=21cnbao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=chengming.zhou@linux.dev \
--cc=chrisl@kernel.org \
--cc=david@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=ryan.roberts@arm.com \
--cc=willy@infradead.org \
--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