lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <75dc1299-8a83-4ce8-a715-cf1a8d43e0f9@redhat.com>
Date: Thu, 17 Apr 2025 10:40:23 +0200
From: David Hildenbrand <david@...hat.com>
To: Shivank Garg <shivankg@....com>, shaggy@...nel.org,
 akpm@...ux-foundation.org
Cc: willy@...radead.org, wangkefeng.wang@...wei.com, jane.chu@...cle.com,
 ziy@...dia.com, donettom@...ux.ibm.com, apopple@...dia.com,
 jfs-discussion@...ts.sourceforge.net, linux-kernel@...r.kernel.org,
 linux-mm@...ck.org, syzbot+8bb6fd945af4e0ad9299@...kaller.appspotmail.com
Subject: Re: [PATCH V3 1/2] mm: export folio_expected_refs for JFS migration
 handler

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@....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" ?

-- 
Cheers,

David / dhildenb


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ