* [PATCH] mm: avoid shadowing global mem_map in sparse_init_one_section()
@ 2026-07-04 18:24 Anuradha Weeraman
2026-07-05 9:17 ` Mike Rapoport
0 siblings, 1 reply; 3+ messages in thread
From: Anuradha Weeraman @ 2026-07-04 18:24 UTC (permalink / raw)
To: Andrew Morton; +Cc: David Hildenbrand, linux-mm, linux-kernel
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.
Signed-off-by: Anuradha Weeraman <anuradha@debian.org>
---
mm/internal.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/internal.h b/mm/internal.h
index 181e79f1d6a2..4943def97167 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -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;
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mm: avoid shadowing global mem_map in sparse_init_one_section()
2026-07-04 18:24 [PATCH] mm: avoid shadowing global mem_map in sparse_init_one_section() Anuradha Weeraman
@ 2026-07-05 9:17 ` Mike Rapoport
2026-07-06 9:07 ` David Hildenbrand (Arm)
0 siblings, 1 reply; 3+ messages in thread
From: Mike Rapoport @ 2026-07-05 9:17 UTC (permalink / raw)
To: Anuradha Weeraman
Cc: Andrew Morton, David Hildenbrand, linux-mm, linux-kernel
On Sat, Jul 04, 2026 at 11:54:51PM +0530, Anuradha Weeraman wrote:
> 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.
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.
> No functional change.
>
> Signed-off-by: Anuradha Weeraman <anuradha@debian.org>
> ---
> mm/internal.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/internal.h b/mm/internal.h
> index 181e79f1d6a2..4943def97167 100644
> --- a/mm/internal.h
> +++ b/mm/internal.h
> @@ -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;
> --
> 2.53.0
>
>
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm: avoid shadowing global mem_map in sparse_init_one_section()
2026-07-05 9:17 ` Mike Rapoport
@ 2026-07-06 9:07 ` David Hildenbrand (Arm)
0 siblings, 0 replies; 3+ messages in thread
From: David Hildenbrand (Arm) @ 2026-07-06 9:07 UTC (permalink / raw)
To: Mike Rapoport, Anuradha Weeraman; +Cc: Andrew Morton, linux-mm, linux-kernel
On 7/5/26 11:17, Mike Rapoport wrote:
> On Sat, Jul 04, 2026 at 11:54:51PM +0530, Anuradha Weeraman wrote:
>> 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.
>
> 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.
>
Unrelated to that, I thought we don't particularly care about W=2 stuff unless
it uncovers a real bug?
--
Cheers,
David
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-06 9:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-04 18:24 [PATCH] mm: avoid shadowing global mem_map in sparse_init_one_section() Anuradha Weeraman
2026-07-05 9:17 ` Mike Rapoport
2026-07-06 9:07 ` David Hildenbrand (Arm)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox