From: Shivank Garg <shivankg@amd.com>
To: Zi Yan <ziy@nvidia.com>, Liu Shixin <liushixin2@huawei.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
linux-mm@kvack.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Barry Song <baohua@kernel.org>,
David Hildenbrand <david@redhat.com>,
Kefeng Wang <wangkefeng.wang@huawei.com>,
Lance Yang <ioworker0@gmail.com>,
Ryan Roberts <ryan.roberts@arm.com>,
Matthew Wilcox <willy@infradead.org>,
Hugh Dickins <hughd@google.com>,
Charan Teja Kalla <quic_charante@quicinc.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/migrate: fix shmem xarray update during migration
Date: Fri, 28 Feb 2025 22:32:32 +0530 [thread overview]
Message-ID: <028f5f2b-ec42-4704-b82b-2f604fd11cf8@amd.com> (raw)
In-Reply-To: <20250228154219.2214149-1-ziy@nvidia.com>
On 2/28/2025 9:12 PM, Zi Yan wrote:
> Pagecache uses multi-index entries for large folio, so does shmem. Only
> swap cache still stores multiple entries for a single large folio.
> Commit fc346d0a70a1 ("mm: migrate high-order folios in swap cache correctly")
> fixed swap cache but got shmem wrong by storing multiple entries for
> a large shmem folio. Fix it by storing a single entry for a shmem
> folio.
>
> Fixes: fc346d0a70a1 ("mm: migrate high-order folios in swap cache correctly")
> Reported-by: Liu Shixin <liushixin2@huawei.com>
> Closes: https://lore.kernel.org/all/28546fb4-5210-bf75-16d6-43e1f8646080@huawei.com/
> Signed-off-by: Zi Yan <ziy@nvidia.com>
> ---
> mm/migrate.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 365c6daa8d1b..9db26f5527a8 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -44,6 +44,7 @@
> #include <linux/sched/sysctl.h>
> #include <linux/memory-tiers.h>
> #include <linux/pagewalk.h>
> +#include <linux/shmem_fs.h>
>
> #include <asm/tlbflush.h>
>
> @@ -524,7 +525,11 @@ static int __folio_migrate_mapping(struct address_space *mapping,
> folio_set_swapcache(newfolio);
> newfolio->private = folio_get_private(folio);
> }
> - entries = nr;
> + /* shmem uses high-order entry */
> + if (shmem_mapping(mapping))
> + entries = 1;
> + else
> + entries = nr;
LGTM functionally.
As a minor style suggestion, can we consider using a ternary operator:
entries = shmem_mapping(mapping) ? 1 : nr; /* shmem uses high-order entry */
This looks cleaner to me.
Reviewed-by: Shivank Garg <shivankg@amd.com>
> } else {
> VM_BUG_ON_FOLIO(folio_test_swapcache(folio), folio);
> entries = 1;
next prev parent reply other threads:[~2025-02-28 17:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-28 15:42 Zi Yan
2025-02-28 16:35 ` Matthew Wilcox
2025-02-28 17:05 ` Zi Yan
2025-02-28 17:02 ` Shivank Garg [this message]
2025-02-28 17:17 ` Zi Yan
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=028f5f2b-ec42-4704-b82b-2f604fd11cf8@amd.com \
--to=shivankg@amd.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=ioworker0@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liushixin2@huawei.com \
--cc=quic_charante@quicinc.com \
--cc=ryan.roberts@arm.com \
--cc=wangkefeng.wang@huawei.com \
--cc=willy@infradead.org \
--cc=ziy@nvidia.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