2010-04-19 23:28:11

by Marcelo Roberto Jimenez

[permalink] [raw]
Subject: Suspicious compilation warning

Hi,

I get this warning while compiling for ARM/SA1100:

mm/sparse.c: In function '__section_nr':
mm/sparse.c:135: warning: 'root' is used uninitialized in this function

With a small patch in fs/proc/meminfo.c, I find that NR_SECTION_ROOTS
is zero, which certainly explains the warning.

# cat /proc/meminfo
NR_SECTION_ROOTS=0
NR_MEM_SECTIONS=32
SECTIONS_PER_ROOT=512
SECTIONS_SHIFT=5
MAX_PHYSMEM_BITS=32
SECTION_SIZE_BITS=27
MemTotal: 28848 kB
MemFree: 15516 kB
Buffers: 112 kB
Cached: 2312 kB
SwapCached: 0 kB
Active: 984 kB
Inactive: 1628 kB
Active(anon): 188 kB
Inactive(anon): 0 kB
Active(file): 796 kB
Inactive(file): 1628 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 24 kB
Writeback: 0 kB
AnonPages: 208 kB
Mapped: 292 kB
Shmem: 0 kB
Slab: 1472 kB
SReclaimable: 744 kB
SUnreclaim: 728 kB
KernelStack: 200 kB
PageTables: 32 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 14424 kB
Committed_AS: 772 kB
VmallocTotal: 614400 kB
VmallocUsed: 33316 kB
VmallocChunk: 573436 kB

Regards,
Marcelo.


2010-04-20 22:52:39

by Andrew Morton

[permalink] [raw]
Subject: Re: Suspicious compilation warning

On Mon, 19 Apr 2010 20:27:43 -0300
Marcelo Jimenez <[email protected]> wrote:

> I get this warning while compiling for ARM/SA1100:
>
> mm/sparse.c: In function '__section_nr':
> mm/sparse.c:135: warning: 'root' is used uninitialized in this function
>
> With a small patch in fs/proc/meminfo.c, I find that NR_SECTION_ROOTS
> is zero, which certainly explains the warning.
>
> # cat /proc/meminfo
> NR_SECTION_ROOTS=0
> NR_MEM_SECTIONS=32
> SECTIONS_PER_ROOT=512
> SECTIONS_SHIFT=5
> MAX_PHYSMEM_BITS=32

hm, who owns sparsemem nowadays? Nobody identifiable.

Does it make physical sense to have SECTIONS_PER_ROOT > NR_MEM_SECTIONS?

2010-04-20 23:08:22

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: Suspicious compilation warning

On Tue, Apr 20, 2010 at 03:51:22PM -0700, Andrew Morton wrote:
> On Mon, 19 Apr 2010 20:27:43 -0300
> Marcelo Jimenez <[email protected]> wrote:
>
> > I get this warning while compiling for ARM/SA1100:
> >
> > mm/sparse.c: In function '__section_nr':
> > mm/sparse.c:135: warning: 'root' is used uninitialized in this function
> >
> > With a small patch in fs/proc/meminfo.c, I find that NR_SECTION_ROOTS
> > is zero, which certainly explains the warning.
> >
> > # cat /proc/meminfo
> > NR_SECTION_ROOTS=0
> > NR_MEM_SECTIONS=32
> > SECTIONS_PER_ROOT=512
> > SECTIONS_SHIFT=5
> > MAX_PHYSMEM_BITS=32
>
> hm, who owns sparsemem nowadays? Nobody identifiable.
>
> Does it make physical sense to have SECTIONS_PER_ROOT > NR_MEM_SECTIONS?

Well, it'll be about this number on everything using sparsemem extreme:

#define SECTIONS_PER_ROOT (PAGE_SIZE / sizeof (struct mem_section))

and with only 32 sections, this is going to give a NR_SECTION_ROOTS value
of zero. I think the calculation of NR_SECTIONS_ROOTS is wrong.

#define NR_SECTION_ROOTS (NR_MEM_SECTIONS / SECTIONS_PER_ROOT)

Clearly if we have 1 mem section, we want to have one section root, so
I think this division should round up any fractional part, thusly:

#define NR_SECTION_ROOTS ((NR_MEM_SECTIONS + SECTIONS_PER_ROOT - 1) / SECTIONS_PER_ROOT)