public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re : sparsemem usage
@ 2006-08-10 14:46 moreau francis
  2006-08-10 15:05 ` KAMEZAWA Hiroyuki
  2006-08-10 15:21 ` Andy Whitcroft
  0 siblings, 2 replies; 15+ messages in thread
From: moreau francis @ 2006-08-10 14:46 UTC (permalink / raw)
  To: KAMEZAWA Hiroyuki; +Cc: apw, alan, linux-kernel

KAMEZAWA Hiroyuki wrote:
> On Thu, 10 Aug 2006 14:40:52 +0200 (CEST)
> moreau francis <francis_moreau2000@yahoo.fr> wrote: 
>>> BTW, ioresouce information (see kernel/resouce.c)
>>>
>>> [kamezawa@aworks Development]$ cat /proc/iomem | grep RAM
>>> 00000000-0009fbff : System RAM
>>> 000a0000-000bffff : Video RAM area
>>> 00100000-2dfeffff : System RAM
>>>
>>> is not enough ?
>>>
>> well actually you show that to get a really simple information, ie does
>> a page exist ?, we need to parse some kernel data structures like 
>> ioresource (which is, IMHO, hackish) or duplicate in each architecture
>> some data to keep track of existing pages.
>>
> 
> becasue memory map from e820(x86) or efi(ia64) are registered to iomem_resource,
> we should avoid duplicates that information. kdump and memory hotplug uses
> this information. (memory hotplug updates this iomem_resource.)
> 
> Implementing "page_is_exist" function based on ioresouce is one of generic
> and rubust way to go, I think.
> (if performance of list walking is problem, enhancing ioresouce code is
>  better.)
>  

Why not implementing page_exist() by simply using mem_map[] ? When
allocating mem_map[], we can just fill it with a special value. And
then when registering memory area, we clear this special value with
the "reserved" value. Hence for flatmem model, we can have:

#define page_exist(pfn)        (mem_map[pfn] != SPECIAL_VALUE)

and it should work for sparsemem too and other models that will use
mem_map[].

Another point, is page_exist() going to replace page_valid() ?
I mean page_exist() is going to be something more accurate than
page_valid(). All tests on page_valid() _only_ will be fine to test
page_exist(). But all tests such:

    if (page_valid(x) && page_is_ram(x))

can be replaced by

    if (page_exist(x))

So, again, why not simply improving page_valid() definition rather
than introduce a new service ?

Francis





^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: Re : Re : Re : Re : sparsemem usage
@ 2006-08-10  4:46 KAMEZAWA Hiroyuki
  2006-08-10 12:40 ` moreau francis
  0 siblings, 1 reply; 15+ messages in thread
From: KAMEZAWA Hiroyuki @ 2006-08-10  4:46 UTC (permalink / raw)
  To: moreau francis; +Cc: apw, alan, linux-kernel

On Wed, 9 Aug 2006 14:19:01 +0000 (GMT)
moreau francis <francis_moreau2000@yahoo.fr> wrote:

> Not all arch have page_is_ram(). OK it should be easy to have but we will
> need create new data structures to keep this info. The point is that it's
> really easy for memory model such sparsemem to keep this info.
> 
> > Do you have a usage model in which we really care about the number of
> > pages in the system to that level of accuracy?
> > 
> 
> show_mem(), which is arch specific, needs to report them. And some
> implementations use only pfn_valid().
> 

BTW, ioresouce information (see kernel/resouce.c)

[kamezawa@aworks Development]$ cat /proc/iomem | grep RAM
00000000-0009fbff : System RAM
000a0000-000bffff : Video RAM area
00100000-2dfeffff : System RAM

is not enough ?

I think kdump depends on this resouce information to determine 
where should be dumped.

-Kame



^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: sparsemem usage
@ 2006-08-02 15:24 Alan Cox
  2006-08-02 15:33 ` Re : " moreau francis
  0 siblings, 1 reply; 15+ messages in thread
From: Alan Cox @ 2006-08-02 15:24 UTC (permalink / raw)
  To: moreau francis; +Cc: linux-kernel, apw

Ar Mer, 2006-08-02 am 13:44 +0000, ysgrifennodd moreau francis:
> #if (MAX_ORDER - 1 + PAGE_SHIFT) > SECTION_SIZE_BITS
> #error Allocator MAX_ORDER exceeds SECTION_SIZE
> #endif
> 
> I'm not sure to understand why there's such check. To fix this
> I should change MAX_ORDER to 6.
> 
> Is it the only way to fix that ?

The kernel allocates memory out using groups of blocks in a buddy
system. 128K is smaller than one of the blocks so the kernel cannot
handle this. You need 2MB (if I remember right) granularity for your
sections but nothing stops you marking most of the 2Mb section except
the 128K that exists as "in use"

Alan


^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: sparsemem usage
@ 2006-08-02 14:25 Andy Whitcroft
  2006-08-02 15:12 ` Re : " moreau francis
  0 siblings, 1 reply; 15+ messages in thread
From: Andy Whitcroft @ 2006-08-02 14:25 UTC (permalink / raw)
  To: moreau francis; +Cc: linux-kernel

moreau francis wrote:
> My board has a really weird mem mapping.
> 
> MEM1: 0xc000 0000 - 32 Mo
> MEM2: 0xd000 0000 - 8 Mo
> MEM3: 0xd800 0000 - 128 Ko
> 
> MEM3 has interesting properties, such as speed and security,
> and I really need to use it.
> 
> I think that sparsemem can deal with such mapping. But I
> encounter an issue when choosing the section bit size. I choose
> SECTION_SIZE_BITS = 17. Therefore the section size is
> equal to the smallest size of my memories. But I get a
> compilation error which is due to this:
> 
> #if (MAX_ORDER - 1 + PAGE_SHIFT) > SECTION_SIZE_BITS
> #error Allocator MAX_ORDER exceeds SECTION_SIZE
> #endif
> 
> I'm not sure to understand why there's such check. To fix this
> I should change MAX_ORDER to 6.
> 
> Is it the only way to fix that ?

The memory allocator buddy location algorithm has an implicit assumption 
that the memory map will be contigious and valid out to MAX_ORDER.  ie 
that we can do relative arithmetic on a page* for a page to find its 
buddy at all times.  The allocator never looks outside a MAX_ORDER 
block, aligned to MAX_ORDER in physical pages.  SPARSEMEM's 
implementation by it nature breaks up the mem_map at the section size. 
Thus for the buddy to work a section must be >= MAX_ORDER in size to 
maintain the contiguity constraint.

However, just because you have a small memory block in your memory map 
doesn't mean that the sparsemem section size needs to be that small to 
match.  If there is any valid memory in any section that section will be 
instantiated and the valid memory marked within it, any invalid memory 
is marked reserved.  The section size bounds the amount of internal 
fragmentation we can have in the mem_map.  SPARSEMEM as its name 
suggests wins biggest when memory is very sparsly populate.  If I am 
reading correctly your memory is actually contigious.

-apw


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2006-08-16 12:56 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-10 14:46 Re : sparsemem usage moreau francis
2006-08-10 15:05 ` KAMEZAWA Hiroyuki
2006-08-10 15:23   ` Re : " moreau francis
2006-08-10 15:21 ` Andy Whitcroft
2006-08-10 15:37   ` Re : " moreau francis
2006-08-11  8:26     ` Andy Whitcroft
2006-08-11 12:46       ` Re : " moreau francis
2006-08-11 12:52         ` Andy Whitcroft
2006-08-16 12:56           ` Re : " moreau francis
  -- strict thread matches above, loose matches on Subject: below --
2006-08-10  4:46 KAMEZAWA Hiroyuki
2006-08-10 12:40 ` moreau francis
2006-08-10 12:49   ` KAMEZAWA Hiroyuki
2006-08-02 15:24 Alan Cox
2006-08-02 15:33 ` Re : " moreau francis
2006-08-02 16:33   ` Alan Cox
2006-08-02 14:25 Andy Whitcroft
2006-08-02 15:12 ` Re : " moreau francis
2006-08-02 15:36   ` Andy Whitcroft

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox