On 11/20/25 14:42, Balbir Singh wrote:
Code refactoring of __folio_split() via helper
__folio_freeze_and_split_unmapped() caused a regression with clang-20
with CONFIG_SHMEM=n, the compiler was not able to optimize away the
call to shmem_uncharge() due to changes in nr_shmem_dropped.
Fix this by adding a stub function for shmem_uncharge when
CONFIG_SHMEM is not defined.

smatch also complained about parameter end being used without
initialization, which is a false positive, but keep the tool happy
by sending in initialized parameters. end is initialized to 0.
smatch still complains about mapping being NULL and nr_shmem_dropped
may not be 0, but that is not true prior to or after the changes.

Add detailed documentation comments for folio_split_unmapped()

Cc: Andrew Morton <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Zi Yan <[email protected]>
Cc: Joshua Hahn <[email protected]>
Cc: Rakie Kim <[email protected]>
Cc: Byungchul Park <[email protected]>
Cc: Gregory Price <[email protected]>
Cc: Ying Huang <[email protected]>
Cc: Alistair Popple <[email protected]>
Cc: Oscar Salvador <[email protected]>
Cc: Lorenzo Stoakes <[email protected]>
Cc: Baolin Wang <[email protected]>
Cc: "Liam R. Howlett" <[email protected]>
Cc: Nico Pache <[email protected]>
Cc: Ryan Roberts <[email protected]>
Cc: Dev Jain <[email protected]>
Cc: Barry Song <[email protected]>
Cc: Lyude Paul <[email protected]>
Cc: Danilo Krummrich <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Ralph Campbell <[email protected]>
Cc: Mika Penttilä <[email protected]>
Cc: Matthew Brost <[email protected]>
Cc: Francois Dugast <[email protected]>

Suggested-by: David Hildenbrand <[email protected]>
Signed-off-by: Balbir Singh <[email protected]>
---
This fixup should be squashed into the patch "mm/huge_memory.c:
introduce folio_split_unmapped" in mm/mm-unstable

  include/linux/shmem_fs.h |  6 +++++-
  mm/huge_memory.c         | 30 +++++++++++++++++++++---------
  2 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index 5b368f9549d6..7a412dd6eb4f 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -136,11 +136,16 @@ static inline bool shmem_hpage_pmd_enabled(void)
#ifdef CONFIG_SHMEM
  extern unsigned long shmem_swap_usage(struct vm_area_struct *vma);
+extern void shmem_uncharge(struct inode *inode, long pages);

I forgot to add, we drop the "extern" on functions whenever we move them.

  #else
  static inline unsigned long shmem_swap_usage(struct vm_area_struct *vma)
  {
        return 0;
  }
+
+static void shmem_uncharge(struct inode *inode, long pages)

"static inline void" should resolve the compilation issue.



--
Cheers

David

Reply via email to