Atsushi Nemoto wrote:
> With SPARSEMEM, the single node can contains some holes so there might
> be many invalid pages. For example, with two 256M memory and one 256M
Does SPARSEMEM is the only memory model where we can have memory holes ?
> hole, some variables (num_physpage, totalpages, nr_kernel_pages,
> nr_all_pages, etc.) will indicate that there are 768MB on this system.
> This is not desired because, for example, alloc_large_system_hash()
> allocates too many entries.
>
> Use free_area_init_node() with counted zholes_size[] instead of
> free_area_init().
>
> For num_physpages, use number of ram pages instead of max_low_pfn.
>
> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
>
> diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
> index 802bdd3..d41dee5 100644
> --- a/arch/mips/mm/init.c
> +++ b/arch/mips/mm/init.c
[snip]
>
> @@ -174,29 +200,17 @@ #ifdef CONFIG_HIGHMEM
> zones_size[ZONE_HIGHMEM] = high - low;
> #endif
>
> +#ifdef CONFIG_SPARSEMEM
> + pfn = 0;
> + for (i = 0; i < MAX_NR_ZONES; i++)
> + for (j = 0; j < zones_size[i]; j++, pfn++)
> + if (!page_is_ram(pfn))
> + zholes_size[i]++;
> + free_area_init_node(0, NODE_DATA(0), zones_size,
> + __pa(PAGE_OFFSET), zholes_size);
Does this code really need the ifdef CONFIG_SPARSEMEM ? Can't we make
it generic instead. Only zholes_size[] initialisation really depends
on the memory model. Of course FLATMEM will let zholes_size as is...
If I remember correctly free_area_init_node() takes a pfn number as
fourth parameter: __pa(PAGE_OFFSET) results in a physical address...
BTW why using __pa(OFFSET) ? isn't it going to yield always into 0 ?
At least on MIPS, it's defined as
#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
why not using ARCH_PFN_OFFSET instead ?
thanks
Franck
|