[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <AB942ABF-EC14-4CF3-AA74-D38738A21B22@nvidia.com>
Date: Fri, 28 Feb 2025 12:17:41 -0500
From: Zi Yan <ziy@...dia.com>
To: Shivank Garg <shivankg@....com>
Cc: Liu Shixin <liushixin2@...wei.com>,
Baolin Wang <baolin.wang@...ux.alibaba.com>, linux-mm@...ck.org,
Andrew Morton <akpm@...ux-foundation.org>, Barry Song <baohua@...nel.org>,
David Hildenbrand <david@...hat.com>,
Kefeng Wang <wangkefeng.wang@...wei.com>, Lance Yang <ioworker0@...il.com>,
Ryan Roberts <ryan.roberts@....com>, Matthew Wilcox <willy@...radead.org>,
Hugh Dickins <hughd@...gle.com>,
Charan Teja Kalla <quic_charante@...cinc.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/migrate: fix shmem xarray update during migration
On 28 Feb 2025, at 12:02, Shivank Garg wrote:
> 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@...wei.com>
>> Closes: https://lore.kernel.org/all/28546fb4-5210-bf75-16d6-43e1f8646080@huawei.com/
>> Signed-off-by: Zi Yan <ziy@...dia.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@....com>
Thanks.
Best Regards,
Yan, Zi
Powered by blists - more mailing lists