Skip to contentSkip to conversation

Cleanups for shmem

PATCH Applied Miaohe Lin 1 participant 5 messages Aug 12, 2021

Subsystems (2)
lore
Share & tools
lore

Miaohe Lin

author
#0 lore raw

cover Cleanups for shmem

Hi all,
This series contains cleanups to remove unneeded variable, header file, function forward declaration and so on. More details can be found in the respective changelogs. Thanks!

Miaohe Lin (4):
shmem: remove unneeded variable ret
shmem: remove unneeded header file
shmem: remove unneeded function forward declaration
shmem: include header file to declare swap_info

 mm/shmem.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
Signature · 1 line
2.23.0
author
#1 lore raw

PATCH 1/4 shmem: remove unneeded variable ret

The local variable ret is always equal to -ENOMEM and never touched. So remove it and return -ENOMEM directly to simplify the code.

---
 mm/shmem.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
mm/shmem.c +1 -2
index 96f05f6af8bb..bf4a47419521 100644
@@ -3631,7 +3631,6 @@ static int shmem_fill_super(struct super_block *sb, struct fs_context *fc)
 	struct shmem_options *ctx = fc->fs_private;
 	struct inode *inode;
 	struct shmem_sb_info *sbinfo;
-	int err = -ENOMEM;
 
 	/* Round up to L1_CACHE_BYTES to resist false sharing */
 	sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
@@ -3709,7 +3708,7 @@ static int shmem_fill_super(struct super_block *sb, struct fs_context *fc)
 
 failed:
 	shmem_put_super(sb);
-	return err;
+	return -ENOMEM;
 }
 
 static int shmem_get_tree(struct fs_context *fc)
Signature · 1 line
2.23.0
author
#2 lore raw

PATCH 2/4 shmem: remove unneeded header file

In reply to Miaohe Lin

mfill_atomic_install_pte() is introduced to install pte and update mmu cache since commit bf6ebd97aba0 ("userfaultfd/shmem: modify shmem_mfill_atomic_pte to use install_pte()"). So we should remove tlbflush.h as update_mmu_cache() is not called here now.

---
 mm/shmem.c | 2 --
 1 file changed, 2 deletions(-)
mm/shmem.c +0 -2
index bf4a47419521..41d2900153d9 100644
@@ -39,8 +39,6 @@
 #include <linux/frontswap.h>
 #include <linux/fs_parser.h>
 
-#include <asm/tlbflush.h> /* for arch/microblaze update_mmu_cache() */
-
 static struct vfsmount *shm_mnt;
 
 #ifdef CONFIG_SHMEM
Signature · 1 line
2.23.0
author
#3 lore raw

PATCH 3/4 shmem: remove unneeded function forward declaration

In reply to Miaohe Lin

The forward declaration for shmem_should_replace_page() and shmem_replace_page() is unnecessary. Remove them.

---
 mm/shmem.c | 3 ---
 1 file changed, 3 deletions(-)
mm/shmem.c +0 -3
index 41d2900153d9..ccef5fad0049 100644
@@ -135,9 +135,6 @@ static unsigned long shmem_default_max_inodes(void)
 }
 #endif
 
-static bool shmem_should_replace_page(struct page *page, gfp_t gfp);
-static int shmem_replace_page(struct page **pagep, gfp_t gfp,
-				struct shmem_inode_info *info, pgoff_t index);
 static int shmem_swapin_page(struct inode *inode, pgoff_t index,
 			     struct page **pagep, enum sgp_type sgp,
 			     gfp_t gfp, struct vm_area_struct *vma,
Signature · 1 line
2.23.0
author
#4 lore raw

PATCH 4/4 shmem: include header file to declare swap_info

In reply to Miaohe Lin

It's bad to extern swap_info[] in .c. Include corresponding header file instead.

---
 mm/shmem.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
mm/shmem.c +1 -2
index ccef5fad0049..b9cebf074367 100644
@@ -38,6 +38,7 @@
 #include <linux/hugetlb.h>
 #include <linux/frontswap.h>
 #include <linux/fs_parser.h>
+#include <linux/swapfile.h>
 
 static struct vfsmount *shm_mnt;
 
@@ -1152,8 +1153,6 @@ static void shmem_evict_inode(struct inode *inode)
 	clear_inode(inode);
 }
 
-extern struct swap_info_struct *swap_info[];
-
 static int shmem_find_swap_entries(struct address_space *mapping,
 				   pgoff_t start, unsigned int nr_entries,
 				   struct page **entries, pgoff_t *indices,
Signature · 1 line
2.23.0