mm: avoid shadowing global mem_map in sparse_init_one_section()
Subsystems (2)
PATCH 1/1 mm: avoid shadowing global mem_map in sparse_init_one_section()
With W=2, sparse_init_one_section() warns because its mem_map parameter shadows the global mem_map declaration in linux/mmzone.h.
Rename it to section_mem_map to make that scope explicit and avoid the shadowing warning.
No functional change.
--- mm/internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/internal.h +2 -2
@@ -957,7 +957,7 @@ void sparse_init(void);int sparse_index_init (unsigned long section_nr,int nid);static inline void sparse_init_one_section (struct mem_section *ms, -unsigned long pnum,struct page *mem_map, +unsigned long pnum,struct page *section_mem_map,struct mem_section_usage *usage,unsigned long flags) {unsigned long coded_mem_map;
@@ -969,7 +969,7 @@ static inline void sparse_init_one_section(struct mem_section *ms,* page_to_pfn() on !CONFIG_SPARSEMEM_VMEMMAP can simply subtract it * from the page pointer to obtain the PFN. */ - coded_mem_map = (unsigned long )(mem_map -section_nr_to_pfn (pnum)); + coded_mem_map = (unsigned long )(section_mem_map -section_nr_to_pfn (pnum));VM_WARN_ON_ONCE (coded_mem_map & ~SECTION_MAP_MASK ); ms->section_mem_map &= ~SECTION_MAP_MASK ;
Signature · 1 line
2.53.0
Mike Rapoport
reviewerQuoted 5 lines · Anuradha Weeraman
With W=2,
sparse_init_one_section()warns because itsmem_mapparameter shadows the globalmem_mapdeclaration inlinux/mmzone.h.Rename it to
section_mem_mapto make that scope explicit and avoid the shadowing warning.
I suspect that the comment in mmzone.h saying that mem_map is must be declared for SPARSEMEM is stale and it can be guarded by #ifdef CONFIG_FLATMEM which will be a more correct fix.
Quoted 33 lines
No functional change.
Signed-off-by Anuradha Weeraman <[email protected]>--- mm/internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)mm/internal.h +2
-2@@ -957,7 +957,7 @@ void sparse_init(void);int sparse_index_init (unsigned long section_nr,int nid);static inline void sparse_init_one_section (struct mem_section *ms, -unsigned long pnum,struct page *mem_map, +unsigned long pnum,struct page *section_mem_map,struct mem_section_usage *usage,unsigned long flags) {unsigned long coded_mem_map;@@ -969,7 +969,7 @@ static inline void sparse_init_one_section(struct mem_section *ms,* page_to_pfn() on !CONFIG_SPARSEMEM_VMEMMAP can simply subtract it * from the page pointer to obtain the PFN. */ - coded_mem_map = (unsigned long )(mem_map -section_nr_to_pfn (pnum)); + coded_mem_map = (unsigned long )(section_mem_map -section_nr_to_pfn (pnum));VM_WARN_ON_ONCE (coded_mem_map & ~SECTION_MAP_MASK ); ms->section_mem_map &= ~SECTION_MAP_MASK ;Signature · 1 line
2.53.0
Signature · 2 lines
Sincerely yours, Mike.
David Hildenbrand (Arm)
maintainerQuoted 11 lines · Mike Rapoport
Quoted 5 lines · Anuradha Weeraman
With W=2,
sparse_init_one_section()warns because itsmem_mapparameter shadows the globalmem_mapdeclaration inlinux/mmzone.h.Rename it to
section_mem_mapto make that scope explicit and avoid the shadowing warning.I suspect that the comment in
mmzone.hsaying thatmem_mapis must be declared for SPARSEMEM is stale and it can be guarded by #ifdefCONFIG_FLATMEMwhich will be a more correct fix.
Unrelated to that, I thought we don't particularly care about W=2 stuff unless it uncovers a real bug?
Signature · 3 lines
Cheers, David