Skip to contentSkip to conversation

mm/shmem.c: make shmem_mapping() inline

PATCH Superseded Hui Su 3 participants 4 messages Nov 13, 2020 – Nov 14, 2020

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Hui Su

author
#0 lore raw

PATCH 1/1 mm/shmem.c: make shmem_mapping() inline

inline the shmem_mapping(), and use shmem_mapping() instead of 'inode->i_mapping->a_ops == &shmem_aops' in shmem_evict_inode().

---
 include/linux/shmem_fs.h | 2 +-
 mm/shmem.c               | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
include/linux/shmem_fs.h +1 -1
index a5a5d1d4d7b1..154a16fe7fd5 100644
@@ -67,7 +67,7 @@ extern unsigned long shmem_get_unmapped_area(struct file *, unsigned long addr,
 		unsigned long len, unsigned long pgoff, unsigned long flags);
 extern int shmem_lock(struct file *file, int lock, struct user_struct *user);
 #ifdef CONFIG_SHMEM
-extern bool shmem_mapping(struct address_space *mapping);
+extern inline bool shmem_mapping(struct address_space *mapping);
 #else
 static inline bool shmem_mapping(struct address_space *mapping)
 {
mm/shmem.c +2 -2
index 537c137698f8..7395d8e8226a 100644
@@ -1152,7 +1152,7 @@ static void shmem_evict_inode(struct inode *inode)
 	struct shmem_inode_info *info = SHMEM_I(inode);
 	struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
 
-	if (inode->i_mapping->a_ops == &shmem_aops) {
+	if (shmem_mapping(inode->i_mapping)) {
 		shmem_unacct_size(info->flags, inode->i_size);
 		inode->i_size = 0;
 		shmem_truncate_range(inode, 0, (loff_t)-1);
@@ -2352,7 +2352,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode
 	return inode;
 }
 
-bool shmem_mapping(struct address_space *mapping)
+inline bool shmem_mapping(struct address_space *mapping)
 {
 	return mapping->a_ops == &shmem_aops;
 }
Signature · 1 line
2.29.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 37 lines

inline the shmem_mapping(), and use shmem_mapping() instead of 'inode->i_mapping->a_ops == &shmem_aops' in shmem_evict_inode().

---
 include/linux/shmem_fs.h | 2 +-
 mm/shmem.c               | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
include/linux/shmem_fs.h +1 -1
index a5a5d1d4d7b1..154a16fe7fd5 100644
@@ -67,7 +67,7 @@ extern unsigned long shmem_get_unmapped_area(struct file *, unsigned long addr,
                unsigned long len, unsigned long pgoff, unsigned long flags);
 extern int shmem_lock(struct file *file, int lock, struct user_struct *user);
 #ifdef CONFIG_SHMEM
-extern bool shmem_mapping(struct address_space *mapping);
+extern inline bool shmem_mapping(struct address_space *mapping);
 #else
 static inline bool shmem_mapping(struct address_space *mapping)
 {
mm/shmem.c +1 -1
index 537c137698f8..7395d8e8226a 100644
@@ -1152,7 +1152,7 @@ static void shmem_evict_inode(struct inode *inode)
        struct shmem_inode_info *info = SHMEM_I(inode);
        struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
 
-       if (inode->i_mapping->a_ops == &shmem_aops) {
+       if (shmem_mapping(inode->i_mapping)) {
                shmem_unacct_size(info->flags, inode->i_size);
                inode->i_size = 0;
                shmem_truncate_range(inode, 0, (loff_t)-1);

mm/shmem.c static struct inode *shmem_get_inode(struct super_block *sb, const struct inode · line 2358

Quoted 8 lines
mm/shmem.c +1 -1
@@ -2352,7 +2352,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode
        return inode;
 }
 
-bool shmem_mapping(struct address_space *mapping)
+inline bool shmem_mapping(struct address_space *mapping)
 {
        return mapping->a_ops == &shmem_aops;
 }
#2 lore raw
In reply to Hui Su
Thank you for the patch! Perhaps something to improve:

Hi Hui,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on mmotm/master]

url:    https://github.com/0day-ci/linux/commits/Hui-Su/mm-shmem-c-make-shmem_mapping-inline/20201113-215549
base:   git://git.cmpxchg.org/linux-mmotm.git master
config: arm-randconfig-s032-20201113 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-107-gaf3512a6-dirty
# https://github.com/0day-ci/linux/commit/0434762d5523a3d702cd589a7f8e3771fee7b3b2
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Hui-Su/mm-shmem-c-make-shmem_mapping-inline/20201113-215549
git checkout 0434762d5523a3d702cd589a7f8e3771fee7b3b2
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=arm

If you fix the issue, kindly add following tag as appropriate

"sparse warnings: (new ones prefixed by >>)"
mm/filemap.c: note: in included file:

>> include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without a definition
>> include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without a definition
>> include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without a definition
--
   mm/truncate.c: note: in included file:
>> include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without a definition
>> include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without a definition
>> include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without a definition
--
   mm/memfd.c: note: in included file:
>> include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without a definition

vim +66 include/linux/shmem_fs.h

    48	
    49	/*
    50	 * Functions in mm/shmem.c called directly from elsewhere:
    51	 */
    52	extern const struct fs_parameter_description shmem_fs_parameters;
    53	extern int shmem_init(void);
    54	extern int shmem_init_fs_context(struct fs_context *fc);
    55	extern struct file *shmem_file_setup(const char *name,
    56						loff_t size, unsigned long flags);
    57	extern struct file *shmem_kernel_file_setup(const char *name, loff_t size,
    58						    unsigned long flags);
    59	extern struct file *shmem_file_setup_with_mnt(struct vfsmount *mnt,
    60			const char *name, loff_t size, unsigned long flags);
    61	extern int shmem_zero_setup(struct vm_area_struct *);
    62	extern unsigned long shmem_get_unmapped_area(struct file *, unsigned long addr,
    63			unsigned long len, unsigned long pgoff, unsigned long flags);
    64	extern int shmem_lock(struct file *file, int lock, struct user_struct *user);
    65	#ifdef CONFIG_SHMEM
  > 66	extern inline bool shmem_mapping(struct address_space *mapping);
    67	#else
    68	static inline bool shmem_mapping(struct address_space *mapping)
    69	{
    70		return false;
    71	}
    72	#endif /* CONFIG_SHMEM */
    73	extern void shmem_unlock_mapping(struct address_space *mapping);
    74	extern struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
    75						pgoff_t index, gfp_t gfp_mask);
    76	extern void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end);
    77	extern int shmem_unuse(unsigned int type, bool frontswap,
    78			       unsigned long *fs_pages_to_unuse);
    79	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

author
#3 lore raw
Quoted 75 lines · kernel test robot

Hi Hui,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on mmotm/master]

url:    https://github.com/0day-ci/linux/commits/Hui-Su/mm-shmem-c-make-shmem_mapping-inline/20201113-215549
base:   git://git.cmpxchg.org/linux-mmotm.git master
config: arm-randconfig-s032-20201113 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-107-gaf3512a6-dirty
# https://github.com/0day-ci/linux/commit/0434762d5523a3d702cd589a7f8e3771fee7b3b2
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Hui-Su/mm-shmem-c-make-shmem_mapping-inline/20201113-215549
git checkout 0434762d5523a3d702cd589a7f8e3771fee7b3b2
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=arm

If you fix the issue, kindly add following tag as appropriate

"sparse warnings: (new ones prefixed by >>)"
mm/filemap.c: note: in included file:

Quoted 3 lines
Quoted 3 lines

include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without a definition include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without a definition include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without a definition

--
mm/truncate.c: note: in included file:

Quoted 3 lines
Quoted 3 lines

include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without a definition include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without a definition include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without a definition

--
mm/memfd.c: note: in included file:

Quoted 1 line
Quoted 1 line

include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without a definition

vim +66 include/linux/shmem_fs.h

    48	
    49	/*
    50	 * Functions in mm/shmem.c called directly from elsewhere:
    51	 */
    52	extern const struct fs_parameter_description shmem_fs_parameters;
    53	extern int shmem_init(void);
    54	extern int shmem_init_fs_context(struct fs_context *fc);
    55	extern struct file *shmem_file_setup(const char *name,
    56						loff_t size, unsigned long flags);
    57	extern struct file *shmem_kernel_file_setup(const char *name, loff_t size,
    58						    unsigned long flags);
    59	extern struct file *shmem_file_setup_with_mnt(struct vfsmount *mnt,
    60			const char *name, loff_t size, unsigned long flags);
    61	extern int shmem_zero_setup(struct vm_area_struct *);
    62	extern unsigned long shmem_get_unmapped_area(struct file *, unsigned long addr,
    63			unsigned long len, unsigned long pgoff, unsigned long flags);
    64	extern int shmem_lock(struct file *file, int lock, struct user_struct *user);
    65	#ifdef CONFIG_SHMEM
Quoted 1 line

66 extern inline bool shmem_mapping(struct address_space *mapping);

    67	#else
    68	static inline bool shmem_mapping(struct address_space *mapping)
    69	{
    70		return false;
    71	}
    72	#endif /* CONFIG_SHMEM */
    73	extern void shmem_unlock_mapping(struct address_space *mapping);
    74	extern struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
    75						pgoff_t index, gfp_t gfp_mask);
    76	extern void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end);
    77	extern int shmem_unuse(unsigned int type, bool frontswap,
    78			       unsigned long *fs_pages_to_unuse);
    79	
Quoted 3 lines

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

Thanks for your test.

I will resend a PATCH V2 later.