Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

smaps: fix defined but not used smaps_shmem_walk_ops

When !CONFIG_SHMEM smaps_shmem_walk_ops is defined but not used,
triggering a compiler warning. To avoid the warning remove the #ifdef
around the usage. This has no effect because shmem_mapping() is a stub
returning false when !CONFIG_SHMEM so the code will be compiled out,
however we now need to also provide a stub for shmem_swap_usage().

Link: https://lkml.kernel.org/r/20230405103819.151246-1-steven.price@arm.com
Fixes: 7b86ac3371b7 ("pagewalk: separate function pointers from iterator data")
Signed-off-by: Steven Price <steven.price@arm.com>
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/oe-kbuild-all/202304031749.UiyJpxzF-lkp@intel.com/
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Steven Price and committed by
Andrew Morton
b4aca547 8666925c

+8 -2
+1 -2
fs/proc/task_mmu.c
··· 782 782 if (start >= vma->vm_end) 783 783 return; 784 784 785 - #ifdef CONFIG_SHMEM 786 785 if (vma->vm_file && shmem_mapping(vma->vm_file->f_mapping)) { 787 786 /* 788 787 * For shared or readonly shmem mappings we know that all ··· 802 803 ops = &smaps_shmem_walk_ops; 803 804 } 804 805 } 805 - #endif 806 + 806 807 /* mmap_lock is held in m_start */ 807 808 if (!start) 808 809 walk_page_vma(vma, ops, mss);
+7
include/linux/shmem_fs.h
··· 96 96 97 97 extern bool shmem_is_huge(struct inode *inode, pgoff_t index, bool shmem_huge_force, 98 98 struct mm_struct *mm, unsigned long vm_flags); 99 + #ifdef CONFIG_SHMEM 99 100 extern unsigned long shmem_swap_usage(struct vm_area_struct *vma); 101 + #else 102 + static inline unsigned long shmem_swap_usage(struct vm_area_struct *vma) 103 + { 104 + return 0; 105 + } 106 + #endif 100 107 extern unsigned long shmem_partial_swap_usage(struct address_space *mapping, 101 108 pgoff_t start, pgoff_t end); 102 109