mm: minor janitorial style cleanups
Subsystems (6)
cover mm: minor janitorial style cleanups
This patch series resolves various coding style issues flagged by checkpatch.pl across mmap.c, vmscan.c, and hugetlb.c. The changes include fixing spacing, adding missing blank lines, formatting block comments, and removing unnecessary braces.
No functional changes are introduced.
Christos Skarlos (3):
mm/mmap.c: fix various coding style warnings mm/vamscan: fix various coding style warnings and errors mm/hugetlb: fix various coding style warnings.
mm/hugetlb.c | 17 +++++++++++------ mm/mmap.c | 19 ++++++++++++------- mm/vmscan.c | 12 +++++++----- 3 files changed, 30 insertions(+), 18 deletions(-)
Signature · 1 line
2.55.0
PATCH 1/1 mm/huge_memory: fix various coding style warnings
Resolve coding style issues flagged by checkpatch.pl Specifically:
- Add missing blank lines after variable declarations.
- Remove unnecessary braces {} for a single statement block.
No functional changes are introduced.
--- mm/huge_memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
mm/huge_memory.c +4 -2
@@ -1104,6 +1104,7 @@ subsys_initcall(hugepage_init);static int __init setup_transparent_hugepage (char *str) {int ret =0 ; +if (!str) goto out;if (!strcmp (str,"always" )) {
@@ -1510,6 +1511,7 @@ static void set_huge_zero_folio(pgtable_t pgtable, struct mm_struct *mm, struct folio *zero_folio) {pmd_t entry; + entry =folio_mk_pmd (zero_folio, vma->vm_page_prot); entry =pmd_mkspecial (entry);pgtable_trans_huge_deposit (mm, pmd, pgtable);
@@ -2613,6 +2615,7 @@ bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr,if (pmd_move_must_withdraw (new_ptl, old_ptl, vma)) {pgtable_t pgtable; + pgtable =pgtable_trans_huge_withdraw (mm, old_pmd);pgtable_trans_huge_deposit (mm, new_pmd, pgtable); }
@@ -3901,9 +3904,8 @@ int folio_check_splittable(struct folio *folio, unsigned int new_order,* swapcache folio split. Only uniform split to order-0 can be used * here. */ -if ((split_type ==SPLIT_TYPE_NON_UNIFORM || new_order) &&folio_test_swapcache (folio)) { +if ((split_type ==SPLIT_TYPE_NON_UNIFORM || new_order) &&folio_test_swapcache (folio))return -EINVAL ; - }if (is_huge_zero_folio (folio))return -EINVAL ;
Signature · 1 line
2.55.0
Zi Yan
reviewerRe: [PATCH] mm/huge_memory: fix various coding style warnings
Quoted 11 lines · Christos Skarlos
Resolve coding style issues flagged by checkpatch.pl Specifically:
- Add missing blank lines after variable declarations.
- Remove unnecessary braces {} for a single statement block.No functional changes are introduced.
Signed-off-by Christos Skarlos <[email protected]>--- mm/huge_memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
You already sent this one out[1] and it is reviewed. I guess this is sent out by accident.
[1] https://lore.kernel.org/all/[email protected]/
Signature · 2 lines
Best Regards, Yan, Zi
PATCH 1/3 mm/mmap: fix various coding style warnings
In reply to Christos SkarlosResolve coding style warnings and errors flagged by checkpatch.pl script. Specifically:
- Remove the obsolete filename reference in the top comment.
- Replace <asm/cacheflush.h> and <asm/mmu_context.h> with <linux/...>.
- Add missing blank lines after variable declarations and replace spaces with tabs where needed.
No functional changes are introduced.
--- mm/mmap.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
mm/mmap.c +12 -7
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0-only /* -* mm/mmap.c * * Written by obz. *
@@ -50,9 +49,9 @@#include <linux/memfd.h> #include <linux/uaccess.h> -#include <asm/cacheflush.h> +#include <linux/cacheflush.h> #include <asm/tlb.h> -#include <asm/mmu_context.h> +#include <linux/mmu_context.h> #define CREATE_TRACE_POINTS #include <trace/events/mmap.h>
@@ -526,9 +525,9 @@ unsigned long do_mmap(struct file *file, unsigned long addr,* And don't attempt to combine with hugetlb for now. */ if (flags & (MAP_LOCKED |MAP_HUGETLB )) -return -EINVAL ; +return -EINVAL ;if (vma_flags_can_grow (&vma_flags)) -return -EINVAL ; +return -EINVAL ;/* * If the pages can be dropped, then it doesn't make
@@ -832,6 +831,7 @@ __get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, = NULL;unsigned long error =arch_mmap_check (addr, len, flags); +if (error)return error;
@@ -942,6 +942,7 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr, struct vm_area_struct **pprev) {struct vm_area_struct *vma; +VMA_ITERATOR (vmi, mm, addr); vma =vma_iter_load (&vmi);
@@ -1017,12 +1018,12 @@ struct vm_area_struct *find_extend_vma_locked(struct mm_struct *mm, unsigned lon#if defined(CONFIG_STACK_GROWSUP ) -#define vma_expand_up (vma,addr) expand_upwards(vma, addr) +#define vma_expand_up (vma, addr) expand_upwards(vma, addr)#define vma_expand_down (vma, addr) (-EFAULT)#else -#define vma_expand_up (vma,addr) (-EFAULT) +#define vma_expand_up (vma, addr) (-EFAULT)#define vma_expand_down (vma, addr) expand_downwards(vma, addr)#endif
@@ -1227,6 +1228,7 @@ int vm_brk_flags(unsigned long addr, unsigned long request, bool is_exec)int ret;bool populate;LIST_HEAD (uf); +VMA_ITERATOR (vmi, mm, addr); len =PAGE_ALIGN (request);
@@ -1290,6 +1292,7 @@ void exit_mmap(struct mm_struct *mm)struct mmu_gather tlb;struct vm_area_struct *vma;unsigned long nr_accounted =0 ; +VMA_ITERATOR (vmi, mm,0 );struct unmap_desc unmap;
@@ -1454,6 +1457,7 @@ static vm_fault_t special_mapping_fault(struct vm_fault *vmf)if (*pages) {struct page *page = *pages; +get_page (page); vmf->page = page;return 0 ;
@@ -1711,6 +1715,7 @@ __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)int retval;unsigned long charge =0 ;LIST_HEAD (uf); +VMA_ITERATOR (vmi, mm,0 );if (mmap_write_lock_killable (oldmm))
Signature · 1 line
2.55.0
Zi Yan
reviewerRe: [PATCH 1/3] mm/mmap: fix various coding style warnings
Quoted 17 lines · Christos Skarlos
Resolve coding style warnings and errors flagged by checkpatch.pl script. Specifically:
- Remove the obsolete filename reference in the top comment.
- Replace <asm/cacheflush.h> and <asm/mmu_context.h> with <linux/...>.
- Add missing blank lines after variable declarations and replace spaces with tabs where needed.No functional changes are introduced.
Signed-off-by Christos Skarlos <[email protected]>--- mm/mmap.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)mm/mmap.c +0
-0
mm/mmap.c line 3
Quoted 3 lines
mm/mmap.c +0
-1@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0-only /* -* mm/mmap.c
Why?
mm/mmap.c line 54
Quoted 12 lines
mm/mmap.c +2
-2* * Written by obz. * @@ -50,9 +49,9 @@#include <linux/memfd.h> #include <linux/uaccess.h> -#include <asm/cacheflush.h> +#include <linux/cacheflush.h> #include <asm/tlb.h> -#include <asm/mmu_context.h> +#include <linux/mmu_context.h>
mmap.c does not use any functions in linux versions, why replace asm versions with them? checkpatch.pl has no check for these.
<snip>
mm/mmap.c find_vma_prev(struct mm_struct *mm, unsigned long addr, · line 946
Quoted 6 lines
mm/mmap.c +1
-0@@ -942,6 +942,7 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr, struct vm_area_struct **pprev) {struct vm_area_struct *vma; +VMA_ITERATOR (vmi, mm, addr);
Have you checked the definition of VMA_ITERATOR? It declares struct vma_iterator.
Quoted 18 lines
mm/mmap.c +2
-2vma =vma_iter_load (&vmi);@@ -1017,12 +1018,12 @@ struct vm_area_struct *find_extend_vma_locked(struct mm_struct *mm, unsigned lon#if defined(CONFIG_STACK_GROWSUP ) -#define vma_expand_up (vma,addr) expand_upwards(vma, addr) +#define vma_expand_up (vma, addr) expand_upwards(vma, addr)#define vma_expand_down (vma, addr) (-EFAULT)#else -#define vma_expand_up (vma,addr) (-EFAULT) +#define vma_expand_up (vma, addr) (-EFAULT)#define vma_expand_down (vma, addr) expand_downwards(vma, addr)#endif
mm/mmap.c int vm_brk_flags(unsigned long addr, unsigned long request, bool is_exec) · line 1232
Quoted 5 lines
mm/mmap.c +1
-0@@ -1227,6 +1228,7 @@ int vm_brk_flags(unsigned long addr, unsigned long request, bool is_exec)int ret;bool populate;LIST_HEAD (uf); +VMA_ITERATOR (vmi, mm, addr);
Ditto.
mm/mmap.c void exit_mmap(struct mm_struct *mm) · line 1297
Quoted 9 lines
mm/mmap.c +1
-0len =PAGE_ALIGN (request);@@ -1290,6 +1292,7 @@ void exit_mmap(struct mm_struct *mm)struct mmu_gather tlb;struct vm_area_struct *vma;unsigned long nr_accounted =0 ; +VMA_ITERATOR (vmi, mm,0 );struct unmap_desc unmap;
Ditto.
Quoted 10 lines
mm/mmap.c +1
-0@@ -1454,6 +1457,7 @@ static vm_fault_t special_mapping_fault(struct vm_fault *vmf)if (*pages) {struct page *page = *pages; +get_page (page); vmf->page = page;return 0 ;
mm/mmap.c __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm) · line 1719
Quoted 5 lines
mm/mmap.c +1
-0@@ -1711,6 +1715,7 @@ __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)int retval;unsigned long charge =0 ;LIST_HEAD (uf); +VMA_ITERATOR (vmi, mm,0 );
Ditto.
Quoted 2 lines
mm/mmap.c +0
-0if (mmap_write_lock_killable (oldmm))
Signature · 2 lines
Best Regards, Yan, Zi
PATCH 2/3 mm/vamscan: fix various coding style warnings and errors
In reply to Christos SkarlosResolve coding style issues flagged by checkpatch.pl script. Specifically:
- Add missing blank lines after variable declarations.
- Replace "unsigned" with "unsigned int".
- Replace spaces with tabs where possible.
No functional changes are introduced.
--- mm/vmscan.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
mm/vmscan.c +7 -5
@@ -535,7 +535,7 @@ void reclaim_throttle(pg_data_t *pgdat, enum vmscan_throttle_state reason)* writeback to a slow device to excessive referenced folios at the tail * of the inactive LRU. */ -switch (reason) { +switch (reason) {case VMSCAN_THROTTLE_WRITEBACK : timeout =HZ /10 ;
@@ -1529,6 +1529,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,VM_BUG_ON_FOLIO (folio_test_active (folio), folio);if (!folio_test_mlocked (folio)) {int type =folio_is_file_lru (folio); +folio_set_active (folio); stat->nr_activate[type] += nr_pages;count_memcg_folio_events (folio,PGACTIVATE , nr_pages);
@@ -2073,8 +2074,8 @@ static void shrink_active_list(unsigned long nr_to_scan,LIST_HEAD (l_hold);/* The folios which were snipped off */ LIST_HEAD (l_active);LIST_HEAD (l_inactive); -unsigned nr_deactivate, nr_activate; -unsigned nr_rotated =0 ; +unsigned int nr_deactivate, nr_activate; +unsigned int nr_rotated =0 ;bool file =is_file_lru (lru);struct pglist_data *pgdat =lruvec_pgdat (lruvec);
@@ -2614,7 +2615,7 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,/* * If there is enough inactive page cache, we do not reclaim * anything from the anonymous working right now to make sure -* a streaming file access pattern doesn't cause swapping. +* a streaming file access pattern doesn't cause swapping. */ if (sc->cache_trim_mode) { scan_balance =SCAN_FILE ;
@@ -3416,6 +3417,7 @@ static bool get_next_vma(unsigned long mask, unsigned long size, struct mm_walk {unsigned long start =round_up (*vm_end, size);unsigned long end = (start | ~mask) +1 ; +VMA_ITERATOR (vmi, args->mm, start);VM_WARN_ON_ONCE (mask & size);
@@ -7748,7 +7750,7 @@ static int __init kswapd_init(void)int nid;for_each_node_state (nid,N_MEMORY ) -kswapd_run (nid); +kswapd_run (nid);register_sysctl_init ("vm" , vmscan_sysctl_table);return 0 ; }
Signature · 1 line
2.55.0
Zi Yan
reviewerRe: [PATCH 2/3] mm/vamscan: fix various coding style warnings and errors
Quoted 11 lines · Christos Skarlos
Resolve coding style issues flagged by checkpatch.pl script. Specifically:
- Add missing blank lines after variable declarations.
- Replace "unsigned" with "unsigned int".
- Replace spaces with tabs where possible.No functional changes are introduced.
Signed-off-by Christos Skarlos <[email protected]>--- mm/vmscan.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
Your subject has a typo: s/vamscan/vmscan
Quoted 43 lines
mm/vmscan.c +5
-4@@ -535,7 +535,7 @@ void reclaim_throttle(pg_data_t *pgdat, enum vmscan_throttle_state reason)* writeback to a slow device to excessive referenced folios at the tail * of the inactive LRU. */ -switch (reason) { +switch (reason) {case VMSCAN_THROTTLE_WRITEBACK : timeout =HZ /10 ;@@ -1529,6 +1529,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,VM_BUG_ON_FOLIO (folio_test_active (folio), folio);if (!folio_test_mlocked (folio)) {int type =folio_is_file_lru (folio); +folio_set_active (folio); stat->nr_activate[type] += nr_pages;count_memcg_folio_events (folio,PGACTIVATE , nr_pages);@@ -2073,8 +2074,8 @@ static void shrink_active_list(unsigned long nr_to_scan,LIST_HEAD (l_hold);/* The folios which were snipped off */ LIST_HEAD (l_active);LIST_HEAD (l_inactive); -unsigned nr_deactivate, nr_activate; -unsigned nr_rotated =0 ; +unsigned int nr_deactivate, nr_activate; +unsigned int nr_rotated =0 ;bool file =is_file_lru (lru);struct pglist_data *pgdat =lruvec_pgdat (lruvec);@@ -2614,7 +2615,7 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,/* * If there is enough inactive page cache, we do not reclaim * anything from the anonymous working right now to make sure -* a streaming file access pattern doesn't cause swapping. +* a streaming file access pattern doesn't cause swapping. */ if (sc->cache_trim_mode) { scan_balance =SCAN_FILE ;
mm/vmscan.c static bool get_next_vma(unsigned long mask, unsigned long size, struct mm_walk · line 3421
Quoted 5 lines
mm/vmscan.c +1
-0@@ -3416,6 +3417,7 @@ static bool get_next_vma(unsigned long mask, unsigned long size, struct mm_walk {unsigned long start =round_up (*vm_end, size);unsigned long end = (start | ~mask) +1 ; +VMA_ITERATOR (vmi, args->mm, start);
Like I said in patch 1, no new line is needed here.
Signature · 2 lines
Best Regards, Yan, Zi
PATCH 3/3 mm/hugetlb: fix various coding style warnings.
In reply to Christos SkarlosResolve coding style issues flagged by the checkpatch.pl script. Specifically:
- Fix block comment formatting to keep tailing '*/' on a separate line.
- Add missing blank lines after variable declarations.
- Remove anecessary braces {} from single statement blocks.
No functional changes where introduced.
--- mm/hugetlb.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
mm/hugetlb.c +11 -6
@@ -145,7 +145,8 @@ static inline void unlock_or_release_subpool(struct hugepage_subpool *spool,/* If no pages are used, and no other handles to the subpool * remain, give up any reservations based on minimum size and -* free the subpool */ +* free the subpool +*/ spin_unlock_irqrestore (&spool->lock, irq_flags);if (free_subpool) {
@@ -3700,6 +3701,7 @@ static void try_to_free_low(struct hstate *h, unsigned long count,for_each_node_mask (i, *nodes_allowed) {struct folio *folio, *next;struct list_head *freel = &h->hugepage_freelists[i]; +list_for_each_entry_safe (folio, next, freel, lru) {if (count >= h->nr_huge_pages) goto out;
@@ -3764,6 +3766,7 @@ static int set_max_huge_pages(struct hstate *h, unsigned long count, int nid,unsigned long allocated;struct folio *folio;LIST_HEAD (page_list); +NODEMASK_ALLOC (nodemask_t, node_alloc_noretry,GFP_KERNEL );/*
@@ -4188,9 +4191,9 @@ void __init hugetlb_add_hstate(unsigned int order)struct hstate *h;unsigned long i; -if (size_to_hstate (PAGE_SIZE << order)) { +if (size_to_hstate (PAGE_SIZE << order))return ; - } +BUG_ON (hugetlb_max_hstate >=HUGE_MAX_HSTATE );BUG_ON (order <order_base_2 (__NR_USED_SUBPAGE));WARN_ON (order >MAX_FOLIO_ORDER );
@@ -4832,11 +4835,11 @@ static pte_t make_huge_pte(struct vm_area_struct *vma, struct folio *folio,pte_t entry =folio_mk_pte (folio, vma->vm_page_prot);unsigned int shift =huge_page_shift (hstate_vma (vma)); -if (try_mkwrite && (vma->vm_flags &VM_WRITE )) { +if (try_mkwrite && (vma->vm_flags &VM_WRITE )) entry =pte_mkwrite_novma (pte_mkdirty (entry)); - }else { +else entry =pte_wrprotect (entry); - } + entry =pte_mkyoung (entry); entry =arch_make_huge_pte (entry, shift, vma->vm_flags);
@@ -4919,6 +4922,7 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src, last_addr_mask =hugetlb_mask_last_page (h);for (addr = src_vma->vm_start; addr < src_vma->vm_end; addr += sz) {spinlock_t *src_ptl, *dst_ptl; + src_pte =hugetlb_walk (src_vma, addr, sz);if (!src_pte) { addr |= last_addr_mask;
@@ -6321,6 +6325,7 @@ int hugetlb_mfill_atomic_pte(pte_t *dst_pte, folio =alloc_hugetlb_folio (dst_vma, dst_addr, false);if (IS_ERR (folio)) {pte_t *actual_pte =hugetlb_walk (dst_vma, dst_addr,PMD_SIZE ); +if (actual_pte) { ret = -EEXIST ; goto out;
Signature · 1 line
2.55.0
Zi Yan
reviewerRe: [PATCH 3/3] mm/hugetlb: fix various coding style warnings.
Quoted 12 lines · Christos Skarlos
Resolve coding style issues flagged by the checkpatch.pl script. Specifically:
- Fix block comment formatting to keep tailing '*/' on a separate line.
- Add missing blank lines after variable declarations.
- Remove anecessary braces {} from single statement blocks.No functional changes where introduced.
Signed-off-by Christos Skarlos <[email protected]>--- mm/hugetlb.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
<snip>
mm/hugetlb.c static int set_max_huge_pages(struct hstate *h, unsigned long count, int nid, · line 3770
Quoted 6 lines
mm/hugetlb.c +1
-0@@ -3764,6 +3766,7 @@ static int set_max_huge_pages(struct hstate *h, unsigned long count, int nid,unsigned long allocated;struct folio *folio;LIST_HEAD (page_list); +NODEMASK_ALLOC (nodemask_t, node_alloc_noretry,GFP_KERNEL );
Please check the definition of NODEMASK_ALLOC. No new line is needed here.
Signature · 2 lines
Best Regards, Yan, Zi