From: Shivank Garg <shivankg@amd.com>
To: David Hildenbrand <david@redhat.com>,
shaggy@kernel.org, akpm@linux-foundation.org
Cc: willy@infradead.org, wangkefeng.wang@huawei.com,
jane.chu@oracle.com, ziy@nvidia.com, donettom@linux.ibm.com,
apopple@nvidia.com, jfs-discussion@lists.sourceforge.net,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
syzbot+8bb6fd945af4e0ad9299@syzkaller.appspotmail.com
Subject: Re: [PATCH V3 1/2] mm: export folio_expected_refs for JFS migration handler
Date: Tue, 22 Apr 2025 16:58:51 +0530 [thread overview]
Message-ID: <03495e46-234a-4c0d-bec7-f7325789a160@amd.com> (raw)
In-Reply-To: <75dc1299-8a83-4ce8-a715-cf1a8d43e0f9@redhat.com>
On 4/17/2025 2:10 PM, David Hildenbrand wrote:
> On 17.04.25 08:06, Shivank Garg wrote:
>> Export folio_expected_refs() to allow filesystem-specific migration
>> handlers like JFS metapage_migrate_folio to properly verify reference
>> counts before migration.
>>
>> Signed-off-by: Shivank Garg <shivankg@amd.com>
>> ---
>> include/linux/migrate.h | 1 +
>> mm/migrate.c | 3 ++-
>> 2 files changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/linux/migrate.h b/include/linux/migrate.h
>> index aaa2114498d6..cb31c5b1eb6a 100644
>> --- a/include/linux/migrate.h
>> +++ b/include/linux/migrate.h
>> @@ -60,6 +60,7 @@ struct movable_operations {
>> /* Defined in mm/debug.c: */
>> extern const char *migrate_reason_names[MR_TYPES];
>> +int folio_expected_refs(struct address_space *mapping, struct folio *folio);
>> #ifdef CONFIG_MIGRATION
>> void putback_movable_pages(struct list_head *l);
>> diff --git a/mm/migrate.c b/mm/migrate.c
>> index 6e2488e5dbe4..0f01b8a87dec 100644
>> --- a/mm/migrate.c
>> +++ b/mm/migrate.c
>> @@ -445,7 +445,7 @@ void pmd_migration_entry_wait(struct mm_struct *mm, pmd_t *pmd)
>> }
>> #endif
>> -static int folio_expected_refs(struct address_space *mapping,
>> +int folio_expected_refs(struct address_space *mapping,
>> struct folio *folio)
>> {
>> int refs = 1;
>> @@ -458,6 +458,7 @@ static int folio_expected_refs(struct address_space *mapping,
>> return refs;
>> }
>> +EXPORT_SYMBOL_GPL(folio_expected_refs);
>> /*
>> * Replace the folio in the mapping.
>
> Can we make that an inline function instead, and add some documentation?
>
> This function is only suitable if we know the folio is unmapped from page tables (no references from page table mappings: !folio_mapped()).
>
> So when exporting this function we either
>
> a) Need a clearer name
>
> b) Should generalize it to consider folio_mapcount() etc, and lookup the
> mapping from the folio.
>
> For your use case, a) might be easier. Maybe call it something like "folio_migration_expected_refs" ?
>
Thank you David for the review. I'll make it a static inline function in the header file
with proper documentation. I don't need to EXPORT it then, since it will be an inline function.
Best Regards,
Shivank
next prev parent reply other threads:[~2025-04-22 11:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-17 6:06 [PATCH V3 0/2] JFS: Implement migrate_folio for jfs_metapage_aops Shivank Garg
2025-04-17 6:06 ` [PATCH V3 1/2] mm: export folio_expected_refs for JFS migration handler Shivank Garg
2025-04-17 8:40 ` David Hildenbrand
2025-04-22 11:28 ` Shivank Garg [this message]
2025-04-17 6:06 ` [PATCH V3 2/2] jfs: implement migrate_folio for jfs_metapage_aops Shivank Garg
2025-04-17 8:47 ` [syzbot] [mm?] WARNING in move_to_new_folio syzbot
2025-04-17 9:06 ` Shivank Garg
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=03495e46-234a-4c0d-bec7-f7325789a160@amd.com \
--to=shivankg@amd.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=david@redhat.com \
--cc=donettom@linux.ibm.com \
--cc=jane.chu@oracle.com \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shaggy@kernel.org \
--cc=syzbot+8bb6fd945af4e0ad9299@syzkaller.appspotmail.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