Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-12 Thread Simon Jeons
On Thu, 2012-12-13 at 09:48 +0800, Tang Chen wrote:
> On 12/13/2012 08:28 AM, Simon Jeons wrote:
> > On Wed, 2012-12-12 at 18:32 +0800, Tang Chen wrote:
> >> Hi Simon,
> >>
> >> On 12/12/2012 05:29 PM, Simon Jeons wrote:
> >>>
> >>> Thanks for your clarify.
> >>>
> >>> Enable PAE on x86 32bit kernel, 8G memory, movablecore=6.5G
> >>
> >> Could you please provide more info ?
> >>
> >> Such as the whole kernel commondline. And did this happen after
> >> you applied these patches ? What is the output without these
> >> patches ?
> >
> > This result is without the patches, I didn't add more kernel
> > commandline, just movablecore=6.5G, but output as you see is strange, so
> > what happened?
> 
> Hi Simon,
> 
> For now, I'm not quite sure what happened. Could you please provide the
> output without the movablecore=6.5G option ?
> 
> Seeing from your output, your totalpages=2051391, which is about 8G. But
> the memory mapped for your node 0 is obviously not enough.
> 
> When we have high memory, ZONE_MOVABLE is taken from ZONE_HIGH. So the
> first line, 8304MB HIGHMEM available is also strange.
> 
> So I think we need more info to find out the problem. :)
> 

[0.00] 8304MB HIGHMEM available.
[0.00] 885MB LOWMEM available.
[0.00]   mapped low ram: 0 - 375fe000
[0.00]   low ram: 0 - 375fe000
[0.00] Zone ranges:
[0.00]   DMA  [mem 0x0001-0x00ff]
[0.00]   Normal   [mem 0x0100-0x375fdfff]
[0.00]   HighMem  [mem 0x375fe000-0x3e5f]
[0.00] Movable zone start for each node
[0.00] Early memory node ranges
[0.00]   node   0: [mem 0x0001-0x0009cfff]
[0.00]   node   0: [mem 0x0010-0x1fff]
[0.00]   node   0: [mem 0x2020-0x3fff]
[0.00]   node   0: [mem 0x4020-0xb69cbfff]
[0.00]   node   0: [mem 0xb6a46000-0xb6a47fff]
[0.00]   node   0: [mem 0xb6b1c000-0xb6cf]
[0.00]   node   0: [mem 0x-0x3e5f]
[0.00] On node 0 totalpages: 2051391
[0.00] free_area_init_node: node 0, pgdat c0c2cc00, node_mem_map
f19c2200
[0.00]   DMA zone: 32 pages used for memmap
[0.00]   DMA zone: 0 pages reserved
[0.00]   DMA zone: 3949 pages, LIFO batch:0
[0.00]   Normal zone: 1740 pages used for memmap
[0.00]   Normal zone: 220466 pages, LIFO batch:31
[0.00]   HighMem zone: 16609 pages used for memmap
[0.00]   HighMem zone: 1808595 pages, LIFO batch:31


menuentry 'Fedora (3.7.0+)' --class fedora --class gnu-linux --class gnu
--class os $menuentry_id_option
'gnulinux-simple-7ed9528d-006f-4d9e-93d9-f68b0967ca99' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1
--hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'
eba9dfce-d7f1-4b5c-9199-f2abf80e5dc6
else
  search --no-floppy --fs-uuid --set=root
eba9dfce-d7f1-4b5c-9199-f2abf80e5dc6
fi
echo 'Loading Fedora (3.7.0+)'
linux   /vmlinuz-3.7.0+ root=/dev/mapper/vg_kernel-lv_root ro
rd.md=0 rd.dm=0 rd.lvm.lv=vg_kernel/lv_root SYSFONT=True  KEYTABLE=us
rd.luks=0 LANG=en_US.UTF-8 rd.lvm.lv=vg_kernel/lv_swap rhgb quiet
echo 'Loading initial ramdisk ...'
initrd /initramfs-3.7.0+.img
}


> Thank. :)
> 
> >
> >>
> >> Thanks. :)
> >>
> 
>  [0.00] 8304MB HIGHMEM available.
>  [0.00] 885MB LOWMEM available.
>  [0.00]   mapped low ram: 0 - 375fe000
>  [0.00]   low ram: 0 - 375fe000
>  [0.00] Zone ranges:
>  [0.00]   DMA  [mem 0x0001-0x00ff]
>  [0.00]   Normal   [mem 0x0100-0x375fdfff]
>  [0.00]   HighMem  [mem 0x375fe000-0x3e5f]
>  [0.00] Movable zone start for each node
>  [0.00] Early memory node ranges
>  [0.00]   node   0: [mem 0x0001-0x0009cfff]
>  [0.00]   node   0: [mem 0x0010-0x1fff]
>  [0.00]   node   0: [mem 0x2020-0x3fff]
>  [0.00]   node   0: [mem 0x4020-0xb69cbfff]
>  [0.00]   node   0: [mem 0xb6a46000-0xb6a47fff]
>  [0.00]   node   0: [mem 0xb6b1c000-0xb6cf]
>  [0.00]   node   0: [mem 0x-0x3e5f]
>  [0.00] On node 0 totalpages: 2051391
>  [0.00] free_area_init_node: node 0, pgdat c0c26a80,
>  node_mem_map
>  f19de200
>  [0.00]   DMA zone: 32 pages used for memmap
>  [0.00]   DMA zone: 0 pages reserved
>  [0.00]   DMA zone: 3949 pages, LIFO batch:0
>  [0.00]   Normal zone: 1740 pages used for memmap
>  [0.00]   Normal zone: 220466 pages, LIFO batch:31
>  [0.00]   HighMem zone: 16609 pages 

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-12 Thread Tang Chen

On 12/13/2012 08:28 AM, Simon Jeons wrote:

On Wed, 2012-12-12 at 18:32 +0800, Tang Chen wrote:

Hi Simon,

On 12/12/2012 05:29 PM, Simon Jeons wrote:


Thanks for your clarify.

Enable PAE on x86 32bit kernel, 8G memory, movablecore=6.5G


Could you please provide more info ?

Such as the whole kernel commondline. And did this happen after
you applied these patches ? What is the output without these
patches ?


This result is without the patches, I didn't add more kernel
commandline, just movablecore=6.5G, but output as you see is strange, so
what happened?


Hi Simon,

For now, I'm not quite sure what happened. Could you please provide the
output without the movablecore=6.5G option ?

Seeing from your output, your totalpages=2051391, which is about 8G. But
the memory mapped for your node 0 is obviously not enough.

When we have high memory, ZONE_MOVABLE is taken from ZONE_HIGH. So the
first line, 8304MB HIGHMEM available is also strange.

So I think we need more info to find out the problem. :)

Thank. :)





Thanks. :)



[0.00] 8304MB HIGHMEM available.
[0.00] 885MB LOWMEM available.
[0.00]   mapped low ram: 0 - 375fe000
[0.00]   low ram: 0 - 375fe000
[0.00] Zone ranges:
[0.00]   DMA  [mem 0x0001-0x00ff]
[0.00]   Normal   [mem 0x0100-0x375fdfff]
[0.00]   HighMem  [mem 0x375fe000-0x3e5f]
[0.00] Movable zone start for each node
[0.00] Early memory node ranges
[0.00]   node   0: [mem 0x0001-0x0009cfff]
[0.00]   node   0: [mem 0x0010-0x1fff]
[0.00]   node   0: [mem 0x2020-0x3fff]
[0.00]   node   0: [mem 0x4020-0xb69cbfff]
[0.00]   node   0: [mem 0xb6a46000-0xb6a47fff]
[0.00]   node   0: [mem 0xb6b1c000-0xb6cf]
[0.00]   node   0: [mem 0x-0x3e5f]
[0.00] On node 0 totalpages: 2051391
[0.00] free_area_init_node: node 0, pgdat c0c26a80,
node_mem_map
f19de200
[0.00]   DMA zone: 32 pages used for memmap
[0.00]   DMA zone: 0 pages reserved
[0.00]   DMA zone: 3949 pages, LIFO batch:0
[0.00]   Normal zone: 1740 pages used for memmap
[0.00]   Normal zone: 220466 pages, LIFO batch:31
[0.00]   HighMem zone: 16609 pages used for memmap
[0.00]   HighMem zone: 1808595 pages, LIFO batch:31


Why zone movable disappear?












--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-12 Thread Simon Jeons
On Wed, 2012-12-12 at 18:32 +0800, Tang Chen wrote:
> Hi Simon,
> 
> On 12/12/2012 05:29 PM, Simon Jeons wrote:
> >
> > Thanks for your clarify.
> >
> > Enable PAE on x86 32bit kernel, 8G memory, movablecore=6.5G
> 
> Could you please provide more info ?
> 
> Such as the whole kernel commondline. And did this happen after
> you applied these patches ? What is the output without these
> patches ?

This result is without the patches, I didn't add more kernel
commandline, just movablecore=6.5G, but output as you see is strange, so
what happened? 

> 
> Thanks. :)
> 
> >>
> >> [0.00] 8304MB HIGHMEM available.
> >> [0.00] 885MB LOWMEM available.
> >> [0.00]   mapped low ram: 0 - 375fe000
> >> [0.00]   low ram: 0 - 375fe000
> >> [0.00] Zone ranges:
> >> [0.00]   DMA  [mem 0x0001-0x00ff]
> >> [0.00]   Normal   [mem 0x0100-0x375fdfff]
> >> [0.00]   HighMem  [mem 0x375fe000-0x3e5f]
> >> [0.00] Movable zone start for each node
> >> [0.00] Early memory node ranges
> >> [0.00]   node   0: [mem 0x0001-0x0009cfff]
> >> [0.00]   node   0: [mem 0x0010-0x1fff]
> >> [0.00]   node   0: [mem 0x2020-0x3fff]
> >> [0.00]   node   0: [mem 0x4020-0xb69cbfff]
> >> [0.00]   node   0: [mem 0xb6a46000-0xb6a47fff]
> >> [0.00]   node   0: [mem 0xb6b1c000-0xb6cf]
> >> [0.00]   node   0: [mem 0x-0x3e5f]
> >> [0.00] On node 0 totalpages: 2051391
> >> [0.00] free_area_init_node: node 0, pgdat c0c26a80,
> >> node_mem_map
> >> f19de200
> >> [0.00]   DMA zone: 32 pages used for memmap
> >> [0.00]   DMA zone: 0 pages reserved
> >> [0.00]   DMA zone: 3949 pages, LIFO batch:0
> >> [0.00]   Normal zone: 1740 pages used for memmap
> >> [0.00]   Normal zone: 220466 pages, LIFO batch:31
> >> [0.00]   HighMem zone: 16609 pages used for memmap
> >> [0.00]   HighMem zone: 1808595 pages, LIFO batch:31
> >
> > Why zone movable disappear?
> >
> >
> >
> >
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-12 Thread Tang Chen

Hi Simon,

On 12/12/2012 05:29 PM, Simon Jeons wrote:


Thanks for your clarify.

Enable PAE on x86 32bit kernel, 8G memory, movablecore=6.5G


Could you please provide more info ?

Such as the whole kernel commondline. And did this happen after
you applied these patches ? What is the output without these
patches ?

Thanks. :)



[0.00] 8304MB HIGHMEM available.
[0.00] 885MB LOWMEM available.
[0.00]   mapped low ram: 0 - 375fe000
[0.00]   low ram: 0 - 375fe000
[0.00] Zone ranges:
[0.00]   DMA  [mem 0x0001-0x00ff]
[0.00]   Normal   [mem 0x0100-0x375fdfff]
[0.00]   HighMem  [mem 0x375fe000-0x3e5f]
[0.00] Movable zone start for each node
[0.00] Early memory node ranges
[0.00]   node   0: [mem 0x0001-0x0009cfff]
[0.00]   node   0: [mem 0x0010-0x1fff]
[0.00]   node   0: [mem 0x2020-0x3fff]
[0.00]   node   0: [mem 0x4020-0xb69cbfff]
[0.00]   node   0: [mem 0xb6a46000-0xb6a47fff]
[0.00]   node   0: [mem 0xb6b1c000-0xb6cf]
[0.00]   node   0: [mem 0x-0x3e5f]
[0.00] On node 0 totalpages: 2051391
[0.00] free_area_init_node: node 0, pgdat c0c26a80,
node_mem_map
f19de200
[0.00]   DMA zone: 32 pages used for memmap
[0.00]   DMA zone: 0 pages reserved
[0.00]   DMA zone: 3949 pages, LIFO batch:0
[0.00]   Normal zone: 1740 pages used for memmap
[0.00]   Normal zone: 220466 pages, LIFO batch:31
[0.00]   HighMem zone: 16609 pages used for memmap
[0.00]   HighMem zone: 1808595 pages, LIFO batch:31


Why zone movable disappear?






--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-12 Thread Simon Jeons
On Wed, 2012-12-12 at 17:09 +0800, Tang Chen wrote:
> On 12/12/2012 08:49 AM, Jiang Liu wrote:
> > This patch introduces a new array zone_movable_limit[] to store the
> > ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
> > The function sanitize_zone_movable_limit() will find out to which
> > node the ranges in movable_map.map[] belongs, and calculates the
> > low boundary of ZONE_MOVABLE for each node.
> >>
> >> What's the difference between zone_movable_limit[nid] and
> >> zone_movable_pfn[nid]?
> > zone_movable_limit[] is a temporary storage for zone_moveable_pfn[].
> > It's used to handle a special case if user specifies both movablecore_map
> > and movablecore/kernelcore on the kernel command line.
> >
> Hi Simon, Liu,
> 
> Sorry for the late and thanks for your discussion. :)
> 
> As Liu said, zone_movable_limit[] is a temporary array for calculation.
> 
> If users specified movablecore_map option, zone_movable_limit[] holds
> the lowest pfn of ZONE_MOVABLE limited by movablecore_map option. It is 
> constant, won't change.
> 
> Please refer to find_zone_movable_pfns_for_nodes() in patch4, you will
> see that zone_moveable_pfn[] will be changed each time kernel area
> increases.
> 
> So when kernel area increases on node i, zone_moveable_pfn[i] will
> increase. And if zone_moveable_pfn[i] > zone_movable_limit[i], we should
> stop allocate memory for kernel on node i. Here, I give movablecore_map 
> higher priority than kernelcore/movablecore.
> 
> And also, I tried to use zone_moveable_pfn[] to store limits. But when
> calculating the kernel area, I still have to store the limits in
> temporary variables. I think the code was ugly. So I added an new array.
> 
> Thanks. :)

Thanks for your clarify. 

Enable PAE on x86 32bit kernel, 8G memory, movablecore=6.5G
> 
> [0.00] 8304MB HIGHMEM available.
> [0.00] 885MB LOWMEM available.
> [0.00]   mapped low ram: 0 - 375fe000
> [0.00]   low ram: 0 - 375fe000
> [0.00] Zone ranges:
> [0.00]   DMA  [mem 0x0001-0x00ff]
> [0.00]   Normal   [mem 0x0100-0x375fdfff]
> [0.00]   HighMem  [mem 0x375fe000-0x3e5f]
> [0.00] Movable zone start for each node
> [0.00] Early memory node ranges
> [0.00]   node   0: [mem 0x0001-0x0009cfff]
> [0.00]   node   0: [mem 0x0010-0x1fff]
> [0.00]   node   0: [mem 0x2020-0x3fff]
> [0.00]   node   0: [mem 0x4020-0xb69cbfff]
> [0.00]   node   0: [mem 0xb6a46000-0xb6a47fff]
> [0.00]   node   0: [mem 0xb6b1c000-0xb6cf]
> [0.00]   node   0: [mem 0x-0x3e5f]
> [0.00] On node 0 totalpages: 2051391
> [0.00] free_area_init_node: node 0, pgdat c0c26a80,
> node_mem_map
> f19de200
> [0.00]   DMA zone: 32 pages used for memmap
> [0.00]   DMA zone: 0 pages reserved
> [0.00]   DMA zone: 3949 pages, LIFO batch:0
> [0.00]   Normal zone: 1740 pages used for memmap
> [0.00]   Normal zone: 220466 pages, LIFO batch:31
> [0.00]   HighMem zone: 16609 pages used for memmap
> [0.00]   HighMem zone: 1808595 pages, LIFO batch:31

Why zone movable disappear?



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-12 Thread Tang Chen

On 12/12/2012 08:49 AM, Jiang Liu wrote:

This patch introduces a new array zone_movable_limit[] to store the
ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
The function sanitize_zone_movable_limit() will find out to which
node the ranges in movable_map.map[] belongs, and calculates the
low boundary of ZONE_MOVABLE for each node.


What's the difference between zone_movable_limit[nid] and
zone_movable_pfn[nid]?

zone_movable_limit[] is a temporary storage for zone_moveable_pfn[].
It's used to handle a special case if user specifies both movablecore_map
and movablecore/kernelcore on the kernel command line.


Hi Simon, Liu,

Sorry for the late and thanks for your discussion. :)

As Liu said, zone_movable_limit[] is a temporary array for calculation.

If users specified movablecore_map option, zone_movable_limit[] holds
the lowest pfn of ZONE_MOVABLE limited by movablecore_map option. It is 
constant, won't change.


Please refer to find_zone_movable_pfns_for_nodes() in patch4, you will
see that zone_moveable_pfn[] will be changed each time kernel area
increases.

So when kernel area increases on node i, zone_moveable_pfn[i] will
increase. And if zone_moveable_pfn[i] > zone_movable_limit[i], we should
stop allocate memory for kernel on node i. Here, I give movablecore_map 
higher priority than kernelcore/movablecore.


And also, I tried to use zone_moveable_pfn[] to store limits. But when
calculating the kernel area, I still have to store the limits in
temporary variables. I think the code was ugly. So I added an new array.

Thanks. :)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-12 Thread Tang Chen

On 12/12/2012 08:49 AM, Jiang Liu wrote:

This patch introduces a new array zone_movable_limit[] to store the
ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
The function sanitize_zone_movable_limit() will find out to which
node the ranges in movable_map.map[] belongs, and calculates the
low boundary of ZONE_MOVABLE for each node.


What's the difference between zone_movable_limit[nid] and
zone_movable_pfn[nid]?

zone_movable_limit[] is a temporary storage for zone_moveable_pfn[].
It's used to handle a special case if user specifies both movablecore_map
and movablecore/kernelcore on the kernel command line.


Hi Simon, Liu,

Sorry for the late and thanks for your discussion. :)

As Liu said, zone_movable_limit[] is a temporary array for calculation.

If users specified movablecore_map option, zone_movable_limit[] holds
the lowest pfn of ZONE_MOVABLE limited by movablecore_map option. It is 
constant, won't change.


Please refer to find_zone_movable_pfns_for_nodes() in patch4, you will
see that zone_moveable_pfn[] will be changed each time kernel area
increases.

So when kernel area increases on node i, zone_moveable_pfn[i] will
increase. And if zone_moveable_pfn[i]  zone_movable_limit[i], we should
stop allocate memory for kernel on node i. Here, I give movablecore_map 
higher priority than kernelcore/movablecore.


And also, I tried to use zone_moveable_pfn[] to store limits. But when
calculating the kernel area, I still have to store the limits in
temporary variables. I think the code was ugly. So I added an new array.

Thanks. :)
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-12 Thread Simon Jeons
On Wed, 2012-12-12 at 17:09 +0800, Tang Chen wrote:
 On 12/12/2012 08:49 AM, Jiang Liu wrote:
  This patch introduces a new array zone_movable_limit[] to store the
  ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
  The function sanitize_zone_movable_limit() will find out to which
  node the ranges in movable_map.map[] belongs, and calculates the
  low boundary of ZONE_MOVABLE for each node.
 
  What's the difference between zone_movable_limit[nid] and
  zone_movable_pfn[nid]?
  zone_movable_limit[] is a temporary storage for zone_moveable_pfn[].
  It's used to handle a special case if user specifies both movablecore_map
  and movablecore/kernelcore on the kernel command line.
 
 Hi Simon, Liu,
 
 Sorry for the late and thanks for your discussion. :)
 
 As Liu said, zone_movable_limit[] is a temporary array for calculation.
 
 If users specified movablecore_map option, zone_movable_limit[] holds
 the lowest pfn of ZONE_MOVABLE limited by movablecore_map option. It is 
 constant, won't change.
 
 Please refer to find_zone_movable_pfns_for_nodes() in patch4, you will
 see that zone_moveable_pfn[] will be changed each time kernel area
 increases.
 
 So when kernel area increases on node i, zone_moveable_pfn[i] will
 increase. And if zone_moveable_pfn[i]  zone_movable_limit[i], we should
 stop allocate memory for kernel on node i. Here, I give movablecore_map 
 higher priority than kernelcore/movablecore.
 
 And also, I tried to use zone_moveable_pfn[] to store limits. But when
 calculating the kernel area, I still have to store the limits in
 temporary variables. I think the code was ugly. So I added an new array.
 
 Thanks. :)

Thanks for your clarify. 

Enable PAE on x86 32bit kernel, 8G memory, movablecore=6.5G
 
 [0.00] 8304MB HIGHMEM available.
 [0.00] 885MB LOWMEM available.
 [0.00]   mapped low ram: 0 - 375fe000
 [0.00]   low ram: 0 - 375fe000
 [0.00] Zone ranges:
 [0.00]   DMA  [mem 0x0001-0x00ff]
 [0.00]   Normal   [mem 0x0100-0x375fdfff]
 [0.00]   HighMem  [mem 0x375fe000-0x3e5f]
 [0.00] Movable zone start for each node
 [0.00] Early memory node ranges
 [0.00]   node   0: [mem 0x0001-0x0009cfff]
 [0.00]   node   0: [mem 0x0010-0x1fff]
 [0.00]   node   0: [mem 0x2020-0x3fff]
 [0.00]   node   0: [mem 0x4020-0xb69cbfff]
 [0.00]   node   0: [mem 0xb6a46000-0xb6a47fff]
 [0.00]   node   0: [mem 0xb6b1c000-0xb6cf]
 [0.00]   node   0: [mem 0x-0x3e5f]
 [0.00] On node 0 totalpages: 2051391
 [0.00] free_area_init_node: node 0, pgdat c0c26a80,
 node_mem_map
 f19de200
 [0.00]   DMA zone: 32 pages used for memmap
 [0.00]   DMA zone: 0 pages reserved
 [0.00]   DMA zone: 3949 pages, LIFO batch:0
 [0.00]   Normal zone: 1740 pages used for memmap
 [0.00]   Normal zone: 220466 pages, LIFO batch:31
 [0.00]   HighMem zone: 16609 pages used for memmap
 [0.00]   HighMem zone: 1808595 pages, LIFO batch:31

Why zone movable disappear?



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-12 Thread Tang Chen

Hi Simon,

On 12/12/2012 05:29 PM, Simon Jeons wrote:


Thanks for your clarify.

Enable PAE on x86 32bit kernel, 8G memory, movablecore=6.5G


Could you please provide more info ?

Such as the whole kernel commondline. And did this happen after
you applied these patches ? What is the output without these
patches ?

Thanks. :)



[0.00] 8304MB HIGHMEM available.
[0.00] 885MB LOWMEM available.
[0.00]   mapped low ram: 0 - 375fe000
[0.00]   low ram: 0 - 375fe000
[0.00] Zone ranges:
[0.00]   DMA  [mem 0x0001-0x00ff]
[0.00]   Normal   [mem 0x0100-0x375fdfff]
[0.00]   HighMem  [mem 0x375fe000-0x3e5f]
[0.00] Movable zone start for each node
[0.00] Early memory node ranges
[0.00]   node   0: [mem 0x0001-0x0009cfff]
[0.00]   node   0: [mem 0x0010-0x1fff]
[0.00]   node   0: [mem 0x2020-0x3fff]
[0.00]   node   0: [mem 0x4020-0xb69cbfff]
[0.00]   node   0: [mem 0xb6a46000-0xb6a47fff]
[0.00]   node   0: [mem 0xb6b1c000-0xb6cf]
[0.00]   node   0: [mem 0x-0x3e5f]
[0.00] On node 0 totalpages: 2051391
[0.00] free_area_init_node: node 0, pgdat c0c26a80,
node_mem_map
f19de200
[0.00]   DMA zone: 32 pages used for memmap
[0.00]   DMA zone: 0 pages reserved
[0.00]   DMA zone: 3949 pages, LIFO batch:0
[0.00]   Normal zone: 1740 pages used for memmap
[0.00]   Normal zone: 220466 pages, LIFO batch:31
[0.00]   HighMem zone: 16609 pages used for memmap
[0.00]   HighMem zone: 1808595 pages, LIFO batch:31


Why zone movable disappear?






--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-12 Thread Simon Jeons
On Wed, 2012-12-12 at 18:32 +0800, Tang Chen wrote:
 Hi Simon,
 
 On 12/12/2012 05:29 PM, Simon Jeons wrote:
 
  Thanks for your clarify.
 
  Enable PAE on x86 32bit kernel, 8G memory, movablecore=6.5G
 
 Could you please provide more info ?
 
 Such as the whole kernel commondline. And did this happen after
 you applied these patches ? What is the output without these
 patches ?

This result is without the patches, I didn't add more kernel
commandline, just movablecore=6.5G, but output as you see is strange, so
what happened? 

 
 Thanks. :)
 
 
  [0.00] 8304MB HIGHMEM available.
  [0.00] 885MB LOWMEM available.
  [0.00]   mapped low ram: 0 - 375fe000
  [0.00]   low ram: 0 - 375fe000
  [0.00] Zone ranges:
  [0.00]   DMA  [mem 0x0001-0x00ff]
  [0.00]   Normal   [mem 0x0100-0x375fdfff]
  [0.00]   HighMem  [mem 0x375fe000-0x3e5f]
  [0.00] Movable zone start for each node
  [0.00] Early memory node ranges
  [0.00]   node   0: [mem 0x0001-0x0009cfff]
  [0.00]   node   0: [mem 0x0010-0x1fff]
  [0.00]   node   0: [mem 0x2020-0x3fff]
  [0.00]   node   0: [mem 0x4020-0xb69cbfff]
  [0.00]   node   0: [mem 0xb6a46000-0xb6a47fff]
  [0.00]   node   0: [mem 0xb6b1c000-0xb6cf]
  [0.00]   node   0: [mem 0x-0x3e5f]
  [0.00] On node 0 totalpages: 2051391
  [0.00] free_area_init_node: node 0, pgdat c0c26a80,
  node_mem_map
  f19de200
  [0.00]   DMA zone: 32 pages used for memmap
  [0.00]   DMA zone: 0 pages reserved
  [0.00]   DMA zone: 3949 pages, LIFO batch:0
  [0.00]   Normal zone: 1740 pages used for memmap
  [0.00]   Normal zone: 220466 pages, LIFO batch:31
  [0.00]   HighMem zone: 16609 pages used for memmap
  [0.00]   HighMem zone: 1808595 pages, LIFO batch:31
 
  Why zone movable disappear?
 
 
 
 
 


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-12 Thread Tang Chen

On 12/13/2012 08:28 AM, Simon Jeons wrote:

On Wed, 2012-12-12 at 18:32 +0800, Tang Chen wrote:

Hi Simon,

On 12/12/2012 05:29 PM, Simon Jeons wrote:


Thanks for your clarify.

Enable PAE on x86 32bit kernel, 8G memory, movablecore=6.5G


Could you please provide more info ?

Such as the whole kernel commondline. And did this happen after
you applied these patches ? What is the output without these
patches ?


This result is without the patches, I didn't add more kernel
commandline, just movablecore=6.5G, but output as you see is strange, so
what happened?


Hi Simon,

For now, I'm not quite sure what happened. Could you please provide the
output without the movablecore=6.5G option ?

Seeing from your output, your totalpages=2051391, which is about 8G. But
the memory mapped for your node 0 is obviously not enough.

When we have high memory, ZONE_MOVABLE is taken from ZONE_HIGH. So the
first line, 8304MB HIGHMEM available is also strange.

So I think we need more info to find out the problem. :)

Thank. :)





Thanks. :)



[0.00] 8304MB HIGHMEM available.
[0.00] 885MB LOWMEM available.
[0.00]   mapped low ram: 0 - 375fe000
[0.00]   low ram: 0 - 375fe000
[0.00] Zone ranges:
[0.00]   DMA  [mem 0x0001-0x00ff]
[0.00]   Normal   [mem 0x0100-0x375fdfff]
[0.00]   HighMem  [mem 0x375fe000-0x3e5f]
[0.00] Movable zone start for each node
[0.00] Early memory node ranges
[0.00]   node   0: [mem 0x0001-0x0009cfff]
[0.00]   node   0: [mem 0x0010-0x1fff]
[0.00]   node   0: [mem 0x2020-0x3fff]
[0.00]   node   0: [mem 0x4020-0xb69cbfff]
[0.00]   node   0: [mem 0xb6a46000-0xb6a47fff]
[0.00]   node   0: [mem 0xb6b1c000-0xb6cf]
[0.00]   node   0: [mem 0x-0x3e5f]
[0.00] On node 0 totalpages: 2051391
[0.00] free_area_init_node: node 0, pgdat c0c26a80,
node_mem_map
f19de200
[0.00]   DMA zone: 32 pages used for memmap
[0.00]   DMA zone: 0 pages reserved
[0.00]   DMA zone: 3949 pages, LIFO batch:0
[0.00]   Normal zone: 1740 pages used for memmap
[0.00]   Normal zone: 220466 pages, LIFO batch:31
[0.00]   HighMem zone: 16609 pages used for memmap
[0.00]   HighMem zone: 1808595 pages, LIFO batch:31


Why zone movable disappear?












--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-12 Thread Simon Jeons
On Thu, 2012-12-13 at 09:48 +0800, Tang Chen wrote:
 On 12/13/2012 08:28 AM, Simon Jeons wrote:
  On Wed, 2012-12-12 at 18:32 +0800, Tang Chen wrote:
  Hi Simon,
 
  On 12/12/2012 05:29 PM, Simon Jeons wrote:
 
  Thanks for your clarify.
 
  Enable PAE on x86 32bit kernel, 8G memory, movablecore=6.5G
 
  Could you please provide more info ?
 
  Such as the whole kernel commondline. And did this happen after
  you applied these patches ? What is the output without these
  patches ?
 
  This result is without the patches, I didn't add more kernel
  commandline, just movablecore=6.5G, but output as you see is strange, so
  what happened?
 
 Hi Simon,
 
 For now, I'm not quite sure what happened. Could you please provide the
 output without the movablecore=6.5G option ?
 
 Seeing from your output, your totalpages=2051391, which is about 8G. But
 the memory mapped for your node 0 is obviously not enough.
 
 When we have high memory, ZONE_MOVABLE is taken from ZONE_HIGH. So the
 first line, 8304MB HIGHMEM available is also strange.
 
 So I think we need more info to find out the problem. :)
 

[0.00] 8304MB HIGHMEM available.
[0.00] 885MB LOWMEM available.
[0.00]   mapped low ram: 0 - 375fe000
[0.00]   low ram: 0 - 375fe000
[0.00] Zone ranges:
[0.00]   DMA  [mem 0x0001-0x00ff]
[0.00]   Normal   [mem 0x0100-0x375fdfff]
[0.00]   HighMem  [mem 0x375fe000-0x3e5f]
[0.00] Movable zone start for each node
[0.00] Early memory node ranges
[0.00]   node   0: [mem 0x0001-0x0009cfff]
[0.00]   node   0: [mem 0x0010-0x1fff]
[0.00]   node   0: [mem 0x2020-0x3fff]
[0.00]   node   0: [mem 0x4020-0xb69cbfff]
[0.00]   node   0: [mem 0xb6a46000-0xb6a47fff]
[0.00]   node   0: [mem 0xb6b1c000-0xb6cf]
[0.00]   node   0: [mem 0x-0x3e5f]
[0.00] On node 0 totalpages: 2051391
[0.00] free_area_init_node: node 0, pgdat c0c2cc00, node_mem_map
f19c2200
[0.00]   DMA zone: 32 pages used for memmap
[0.00]   DMA zone: 0 pages reserved
[0.00]   DMA zone: 3949 pages, LIFO batch:0
[0.00]   Normal zone: 1740 pages used for memmap
[0.00]   Normal zone: 220466 pages, LIFO batch:31
[0.00]   HighMem zone: 16609 pages used for memmap
[0.00]   HighMem zone: 1808595 pages, LIFO batch:31


menuentry 'Fedora (3.7.0+)' --class fedora --class gnu-linux --class gnu
--class os $menuentry_id_option
'gnulinux-simple-7ed9528d-006f-4d9e-93d9-f68b0967ca99' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1
--hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'
eba9dfce-d7f1-4b5c-9199-f2abf80e5dc6
else
  search --no-floppy --fs-uuid --set=root
eba9dfce-d7f1-4b5c-9199-f2abf80e5dc6
fi
echo 'Loading Fedora (3.7.0+)'
linux   /vmlinuz-3.7.0+ root=/dev/mapper/vg_kernel-lv_root ro
rd.md=0 rd.dm=0 rd.lvm.lv=vg_kernel/lv_root SYSFONT=True  KEYTABLE=us
rd.luks=0 LANG=en_US.UTF-8 rd.lvm.lv=vg_kernel/lv_swap rhgb quiet
echo 'Loading initial ramdisk ...'
initrd /initramfs-3.7.0+.img
}


 Thank. :)
 
 
 
  Thanks. :)
 
 
  [0.00] 8304MB HIGHMEM available.
  [0.00] 885MB LOWMEM available.
  [0.00]   mapped low ram: 0 - 375fe000
  [0.00]   low ram: 0 - 375fe000
  [0.00] Zone ranges:
  [0.00]   DMA  [mem 0x0001-0x00ff]
  [0.00]   Normal   [mem 0x0100-0x375fdfff]
  [0.00]   HighMem  [mem 0x375fe000-0x3e5f]
  [0.00] Movable zone start for each node
  [0.00] Early memory node ranges
  [0.00]   node   0: [mem 0x0001-0x0009cfff]
  [0.00]   node   0: [mem 0x0010-0x1fff]
  [0.00]   node   0: [mem 0x2020-0x3fff]
  [0.00]   node   0: [mem 0x4020-0xb69cbfff]
  [0.00]   node   0: [mem 0xb6a46000-0xb6a47fff]
  [0.00]   node   0: [mem 0xb6b1c000-0xb6cf]
  [0.00]   node   0: [mem 0x-0x3e5f]
  [0.00] On node 0 totalpages: 2051391
  [0.00] free_area_init_node: node 0, pgdat c0c26a80,
  node_mem_map
  f19de200
  [0.00]   DMA zone: 32 pages used for memmap
  [0.00]   DMA zone: 0 pages reserved
  [0.00]   DMA zone: 3949 pages, LIFO batch:0
  [0.00]   Normal zone: 1740 pages used for memmap
  [0.00]   Normal zone: 220466 pages, LIFO batch:31
  [0.00]   HighMem zone: 16609 pages used for memmap
  [0.00]   HighMem zone: 1808595 pages, LIFO batch:31
 
  Why zone movable disappear?
 
 
 
 
 
 
 
 
 


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a 

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-11 Thread Simon Jeons
On Wed, 2012-12-12 at 09:57 +0800, Jianguo Wu wrote:
> On 2012/12/11 21:20, Simon Jeons wrote:
> 
> > On Tue, 2012-12-11 at 20:41 +0800, Jianguo Wu wrote:
> >> On 2012/12/11 20:24, Simon Jeons wrote:
> >>
> >>> On Tue, 2012-12-11 at 11:07 +0800, Jianguo Wu wrote:
>  On 2012/12/11 10:33, Tang Chen wrote:
> 
> > This patch introduces a new array zone_movable_limit[] to store the
> > ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
> > The function sanitize_zone_movable_limit() will find out to which
> > node the ranges in movable_map.map[] belongs, and calculates the
> > low boundary of ZONE_MOVABLE for each node.
> >
> > Signed-off-by: Tang Chen 
> > Signed-off-by: Jiang Liu 
> > Reviewed-by: Wen Congyang 
> > Reviewed-by: Lai Jiangshan 
> > Tested-by: Lin Feng 
> > ---
> >  mm/page_alloc.c |   77 
> > +++
> >  1 files changed, 77 insertions(+), 0 deletions(-)
> >
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index 1c91d16..4853619 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -206,6 +206,7 @@ static unsigned long __meminitdata 
> > arch_zone_highest_possible_pfn[MAX_NR_ZONES];
> >  static unsigned long __initdata required_kernelcore;
> >  static unsigned long __initdata required_movablecore;
> >  static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
> > +static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];
> >  
> >  /* movable_zone is the "real" zone pages in ZONE_MOVABLE are taken 
> > from */
> >  int movable_zone;
> > @@ -4340,6 +4341,77 @@ static unsigned long __meminit 
> > zone_absent_pages_in_node(int nid,
> > return __absent_pages_in_range(nid, zone_start_pfn, 
> > zone_end_pfn);
> >  }
> >  
> > +/**
> > + * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
> > + *
> > + * zone_movable_limit is initialized as 0. This function will try to 
> > get
> > + * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
> > + * assigne them to zone_movable_limit.
> > + * zone_movable_limit[nid] == 0 means no limit for the node.
> > + *
> > + * Note: Each range is represented as [start_pfn, end_pfn)
> > + */
> > +static void __meminit sanitize_zone_movable_limit(void)
> > +{
> > +   int map_pos = 0, i, nid;
> > +   unsigned long start_pfn, end_pfn;
> > +
> > +   if (!movablecore_map.nr_map)
> > +   return;
> > +
> > +   /* Iterate all ranges from minimum to maximum */
> > +   for_each_mem_pfn_range(i, MAX_NUMNODES, _pfn, _pfn, 
> > ) {
> > +   /*
> > +* If we have found lowest pfn of ZONE_MOVABLE of the 
> > node
> > +* specified by user, just go on to check next range.
> > +*/
> > +   if (zone_movable_limit[nid])
> > +   continue;
> > +
> > +#ifdef CONFIG_ZONE_DMA
> > +   /* Skip DMA memory. */
> > +   if (start_pfn < 
> > arch_zone_highest_possible_pfn[ZONE_DMA])
> > +   start_pfn = 
> > arch_zone_highest_possible_pfn[ZONE_DMA];
> > +#endif
> > +
> > +#ifdef CONFIG_ZONE_DMA32
> > +   /* Skip DMA32 memory. */
> > +   if (start_pfn < 
> > arch_zone_highest_possible_pfn[ZONE_DMA32])
> > +   start_pfn = 
> > arch_zone_highest_possible_pfn[ZONE_DMA32];
> > +#endif
> > +
> > +#ifdef CONFIG_HIGHMEM
> > +   /* Skip lowmem if ZONE_MOVABLE is highmem. */
> > +   if (zone_movable_is_highmem() &&
> 
>  Hi Tang,
> 
>  I think zone_movable_is_highmem() is not work correctly here.
>   sanitize_zone_movable_limit
>   zone_movable_is_highmem  <--using movable_zone here
>   find_zone_movable_pfns_for_nodes
>   find_usable_zone_for_movable <--movable_zone is specified here
> 
> >>>
> >>> Hi Jiangguo and Chen,
> >>>
> >>> - What's the meaning of zone_movable_is_highmem(), does it mean all zone
> >>> highmem pages are zone movable pages or 
> >>
> >> Hi Simon,
> >>
> >> zone_movable_is_highmem() means whether zone pages in ZONE_MOVABLE are 
> >> taken from
> >> highmem.
> >>
> >>> - dmesg 
> >>>
>  0.00] Zone ranges:
>  [0.00]   DMA  [mem 0x0001-0x00ff]
>  [0.00]   Normal   [mem 0x0100-0x373fdfff]
>  [0.00]   HighMem  [mem 0x373fe000-0xb6cf]
>  [0.00] Movable zone start for each node
>  [0.00]   Node 0: 0x9780
> >>>
> >>> Why the start of zone movable is in the range of zone highmem, if all
> >>> the pages of zone movable are from zone 

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-11 Thread Lin Feng


On 12/11/2012 09:20 PM, Simon Jeons wrote:
> On Tue, 2012-12-11 at 20:41 +0800, Jianguo Wu wrote:
>> On 2012/12/11 20:24, Simon Jeons wrote:
>>
>>> On Tue, 2012-12-11 at 11:07 +0800, Jianguo Wu wrote:
 On 2012/12/11 10:33, Tang Chen wrote:

> This patch introduces a new array zone_movable_limit[] to store the
> ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
> The function sanitize_zone_movable_limit() will find out to which
> node the ranges in movable_map.map[] belongs, and calculates the
> low boundary of ZONE_MOVABLE for each node.
>
> Signed-off-by: Tang Chen 
> Signed-off-by: Jiang Liu 
> Reviewed-by: Wen Congyang 
> Reviewed-by: Lai Jiangshan 
> Tested-by: Lin Feng 
> ---
>  mm/page_alloc.c |   77 
> +++
>  1 files changed, 77 insertions(+), 0 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 1c91d16..4853619 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -206,6 +206,7 @@ static unsigned long __meminitdata 
> arch_zone_highest_possible_pfn[MAX_NR_ZONES];
>  static unsigned long __initdata required_kernelcore;
>  static unsigned long __initdata required_movablecore;
>  static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
> +static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];
>  
>  /* movable_zone is the "real" zone pages in ZONE_MOVABLE are taken from 
> */
>  int movable_zone;
> @@ -4340,6 +4341,77 @@ static unsigned long __meminit 
> zone_absent_pages_in_node(int nid,
>   return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
>  }
>  
> +/**
> + * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
> + *
> + * zone_movable_limit is initialized as 0. This function will try to get
> + * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
> + * assigne them to zone_movable_limit.
> + * zone_movable_limit[nid] == 0 means no limit for the node.
> + *
> + * Note: Each range is represented as [start_pfn, end_pfn)
> + */
> +static void __meminit sanitize_zone_movable_limit(void)
> +{
> + int map_pos = 0, i, nid;
> + unsigned long start_pfn, end_pfn;
> +
> + if (!movablecore_map.nr_map)
> + return;
> +
> + /* Iterate all ranges from minimum to maximum */
> + for_each_mem_pfn_range(i, MAX_NUMNODES, _pfn, _pfn, ) {
> + /*
> +  * If we have found lowest pfn of ZONE_MOVABLE of the node
> +  * specified by user, just go on to check next range.
> +  */
> + if (zone_movable_limit[nid])
> + continue;
> +
> +#ifdef CONFIG_ZONE_DMA
> + /* Skip DMA memory. */
> + if (start_pfn < arch_zone_highest_possible_pfn[ZONE_DMA])
> + start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA];
> +#endif
> +
> +#ifdef CONFIG_ZONE_DMA32
> + /* Skip DMA32 memory. */
> + if (start_pfn < arch_zone_highest_possible_pfn[ZONE_DMA32])
> + start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA32];
> +#endif
> +
> +#ifdef CONFIG_HIGHMEM
> + /* Skip lowmem if ZONE_MOVABLE is highmem. */
> + if (zone_movable_is_highmem() &&

 Hi Tang,

 I think zone_movable_is_highmem() is not work correctly here.
sanitize_zone_movable_limit
zone_movable_is_highmem  <--using movable_zone here
find_zone_movable_pfns_for_nodes
find_usable_zone_for_movable <--movable_zone is specified here

>>>
>>> Hi Jiangguo and Chen,
>>>
>>> - What's the meaning of zone_movable_is_highmem(), does it mean all zone
>>> highmem pages are zone movable pages or 
>>
>> Hi Simon,
>>
>> zone_movable_is_highmem() means whether zone pages in ZONE_MOVABLE are taken 
>> from
>> highmem.
>>
>>> - dmesg 
>>>
 0.00] Zone ranges:
 [0.00]   DMA  [mem 0x0001-0x00ff]
 [0.00]   Normal   [mem 0x0100-0x373fdfff]
 [0.00]   HighMem  [mem 0x373fe000-0xb6cf]
 [0.00] Movable zone start for each node
 [0.00]   Node 0: 0x9780
>>>
>>> Why the start of zone movable is in the range of zone highmem, if all
>>> the pages of zone movable are from zone highmem? If the answer is yes, 
>>
>>> zone movable and zone highmem are in the equal status or not?
>>
>> The pages of zone_movable can be taken from zone_movalbe or zone_normal,
>> if we have highmem, then zone_movable will be taken from zone_highmem,
>> otherwise zone_movable will be taken from zone_normal.
>>
>> you can refer to find_usable_zone_for_movable().
> 
> Hi Jiangguo,
> 
> I have 8G memory, movablecore=5G, but dmesg looks strange, what
> happended to me?
Hi 

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-11 Thread Jianguo Wu
On 2012/12/11 21:20, Simon Jeons wrote:

> On Tue, 2012-12-11 at 20:41 +0800, Jianguo Wu wrote:
>> On 2012/12/11 20:24, Simon Jeons wrote:
>>
>>> On Tue, 2012-12-11 at 11:07 +0800, Jianguo Wu wrote:
 On 2012/12/11 10:33, Tang Chen wrote:

> This patch introduces a new array zone_movable_limit[] to store the
> ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
> The function sanitize_zone_movable_limit() will find out to which
> node the ranges in movable_map.map[] belongs, and calculates the
> low boundary of ZONE_MOVABLE for each node.
>
> Signed-off-by: Tang Chen 
> Signed-off-by: Jiang Liu 
> Reviewed-by: Wen Congyang 
> Reviewed-by: Lai Jiangshan 
> Tested-by: Lin Feng 
> ---
>  mm/page_alloc.c |   77 
> +++
>  1 files changed, 77 insertions(+), 0 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 1c91d16..4853619 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -206,6 +206,7 @@ static unsigned long __meminitdata 
> arch_zone_highest_possible_pfn[MAX_NR_ZONES];
>  static unsigned long __initdata required_kernelcore;
>  static unsigned long __initdata required_movablecore;
>  static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
> +static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];
>  
>  /* movable_zone is the "real" zone pages in ZONE_MOVABLE are taken from 
> */
>  int movable_zone;
> @@ -4340,6 +4341,77 @@ static unsigned long __meminit 
> zone_absent_pages_in_node(int nid,
>   return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
>  }
>  
> +/**
> + * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
> + *
> + * zone_movable_limit is initialized as 0. This function will try to get
> + * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
> + * assigne them to zone_movable_limit.
> + * zone_movable_limit[nid] == 0 means no limit for the node.
> + *
> + * Note: Each range is represented as [start_pfn, end_pfn)
> + */
> +static void __meminit sanitize_zone_movable_limit(void)
> +{
> + int map_pos = 0, i, nid;
> + unsigned long start_pfn, end_pfn;
> +
> + if (!movablecore_map.nr_map)
> + return;
> +
> + /* Iterate all ranges from minimum to maximum */
> + for_each_mem_pfn_range(i, MAX_NUMNODES, _pfn, _pfn, ) {
> + /*
> +  * If we have found lowest pfn of ZONE_MOVABLE of the node
> +  * specified by user, just go on to check next range.
> +  */
> + if (zone_movable_limit[nid])
> + continue;
> +
> +#ifdef CONFIG_ZONE_DMA
> + /* Skip DMA memory. */
> + if (start_pfn < arch_zone_highest_possible_pfn[ZONE_DMA])
> + start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA];
> +#endif
> +
> +#ifdef CONFIG_ZONE_DMA32
> + /* Skip DMA32 memory. */
> + if (start_pfn < arch_zone_highest_possible_pfn[ZONE_DMA32])
> + start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA32];
> +#endif
> +
> +#ifdef CONFIG_HIGHMEM
> + /* Skip lowmem if ZONE_MOVABLE is highmem. */
> + if (zone_movable_is_highmem() &&

 Hi Tang,

 I think zone_movable_is_highmem() is not work correctly here.
sanitize_zone_movable_limit
zone_movable_is_highmem  <--using movable_zone here
find_zone_movable_pfns_for_nodes
find_usable_zone_for_movable <--movable_zone is specified here

>>>
>>> Hi Jiangguo and Chen,
>>>
>>> - What's the meaning of zone_movable_is_highmem(), does it mean all zone
>>> highmem pages are zone movable pages or 
>>
>> Hi Simon,
>>
>> zone_movable_is_highmem() means whether zone pages in ZONE_MOVABLE are taken 
>> from
>> highmem.
>>
>>> - dmesg 
>>>
 0.00] Zone ranges:
 [0.00]   DMA  [mem 0x0001-0x00ff]
 [0.00]   Normal   [mem 0x0100-0x373fdfff]
 [0.00]   HighMem  [mem 0x373fe000-0xb6cf]
 [0.00] Movable zone start for each node
 [0.00]   Node 0: 0x9780
>>>
>>> Why the start of zone movable is in the range of zone highmem, if all
>>> the pages of zone movable are from zone highmem? If the answer is yes, 
>>
>>> zone movable and zone highmem are in the equal status or not?
>>
>> The pages of zone_movable can be taken from zone_movalbe or zone_normal,
>> if we have highmem, then zone_movable will be taken from zone_highmem,
>> otherwise zone_movable will be taken from zone_normal.
>>
>> you can refer to find_usable_zone_for_movable().
> 
> Hi Jiangguo,
> 
> I have 8G memory, movablecore=5G, but dmesg looks strange, what
> happended to me?
> 

Hi 

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-11 Thread Jiang Liu
On 2012-12-11 19:28, Simon Jeons wrote:
> On Tue, 2012-12-11 at 11:32 +0800, Tang Chen wrote:
>> On 12/11/2012 11:07 AM, Jianguo Wu wrote:
>>> On 2012/12/11 10:33, Tang Chen wrote:
>>>
 This patch introduces a new array zone_movable_limit[] to store the
 ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
 The function sanitize_zone_movable_limit() will find out to which
 node the ranges in movable_map.map[] belongs, and calculates the
 low boundary of ZONE_MOVABLE for each node.
> 
> What's the difference between zone_movable_limit[nid] and
> zone_movable_pfn[nid]?
zone_movable_limit[] is a temporary storage for zone_moveable_pfn[].
It's used to handle a special case if user specifies both movablecore_map
and movablecore/kernelcore on the kernel command line. 

> 

 Signed-off-by: Tang Chen
 Signed-off-by: Jiang Liu
 Reviewed-by: Wen Congyang
 Reviewed-by: Lai Jiangshan
 Tested-by: Lin Feng
 ---
   mm/page_alloc.c |   77 
 +++
   1 files changed, 77 insertions(+), 0 deletions(-)

 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
 index 1c91d16..4853619 100644
 --- a/mm/page_alloc.c
 +++ b/mm/page_alloc.c
 @@ -206,6 +206,7 @@ static unsigned long __meminitdata 
 arch_zone_highest_possible_pfn[MAX_NR_ZONES];
   static unsigned long __initdata required_kernelcore;
   static unsigned long __initdata required_movablecore;
   static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
 +static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];

   /* movable_zone is the "real" zone pages in ZONE_MOVABLE are taken from 
 */
   int movable_zone;
 @@ -4340,6 +4341,77 @@ static unsigned long __meminit 
 zone_absent_pages_in_node(int nid,
return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
   }

 +/**
 + * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
 + *
 + * zone_movable_limit is initialized as 0. This function will try to get
 + * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
 + * assigne them to zone_movable_limit.
 + * zone_movable_limit[nid] == 0 means no limit for the node.
 + *
 + * Note: Each range is represented as [start_pfn, end_pfn)
 + */
 +static void __meminit sanitize_zone_movable_limit(void)
 +{
 +  int map_pos = 0, i, nid;
 +  unsigned long start_pfn, end_pfn;
 +
 +  if (!movablecore_map.nr_map)
 +  return;
 +
 +  /* Iterate all ranges from minimum to maximum */
 +  for_each_mem_pfn_range(i, MAX_NUMNODES,_pfn,_pfn,) {
 +  /*
 +   * If we have found lowest pfn of ZONE_MOVABLE of the node
 +   * specified by user, just go on to check next range.
 +   */
 +  if (zone_movable_limit[nid])
 +  continue;
 +
 +#ifdef CONFIG_ZONE_DMA
 +  /* Skip DMA memory. */
 +  if (start_pfn<  arch_zone_highest_possible_pfn[ZONE_DMA])
 +  start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA];
 +#endif
 +
 +#ifdef CONFIG_ZONE_DMA32
 +  /* Skip DMA32 memory. */
 +  if (start_pfn<  arch_zone_highest_possible_pfn[ZONE_DMA32])
 +  start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA32];
 +#endif
 +
 +#ifdef CONFIG_HIGHMEM
 +  /* Skip lowmem if ZONE_MOVABLE is highmem. */
 +  if (zone_movable_is_highmem()&&
>>>
>>> Hi Tang,
>>>
>>> I think zone_movable_is_highmem() is not work correctly here.
>>> sanitize_zone_movable_limit
>>> zone_movable_is_highmem<--using movable_zone here
>>> find_zone_movable_pfns_for_nodes
>>> find_usable_zone_for_movable<--movable_zone is specified here
>>>
>>> I think Jiang Liu's patch works fine for highmem, please refer to:
>>> http://marc.info/?l=linux-mm=135476085816087=2
>>
>> Hi Wu,
>>
>> Yes, I forgot movable_zone think. Thanks for reminding me. :)
>>
>> But Liu's patch you just mentioned, I didn't use it because I
>> don't think we should skip kernelcore when movablecore_map is specified.
>> If these 2 options are not conflict, we should satisfy them both. :)
>>
>> Of course, I also think Liu's suggestion is wonderful. But I think we
>> need more discussion on it. :)
>>
>> I'll fix it soon.
>> Thanks. :)
>>
>>>
>>> Thanks,
>>> Jianguo Wu
>>>
 +  start_pfn<  arch_zone_lowest_possible_pfn[ZONE_HIGHMEM])
 +  start_pfn = arch_zone_lowest_possible_pfn[ZONE_HIGHMEM];
 +#endif
 +
 +  if (start_pfn>= end_pfn)
 +  continue;
 +
 +  while (map_pos<  movablecore_map.nr_map) {
 +  if (end_pfn<= movablecore_map.map[map_pos].start_pfn)
 +  break;
 +

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-11 Thread Simon Jeons
On Tue, 2012-12-11 at 20:41 +0800, Jianguo Wu wrote:
> On 2012/12/11 20:24, Simon Jeons wrote:
> 
> > On Tue, 2012-12-11 at 11:07 +0800, Jianguo Wu wrote:
> >> On 2012/12/11 10:33, Tang Chen wrote:
> >>
> >>> This patch introduces a new array zone_movable_limit[] to store the
> >>> ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
> >>> The function sanitize_zone_movable_limit() will find out to which
> >>> node the ranges in movable_map.map[] belongs, and calculates the
> >>> low boundary of ZONE_MOVABLE for each node.
> >>>
> >>> Signed-off-by: Tang Chen 
> >>> Signed-off-by: Jiang Liu 
> >>> Reviewed-by: Wen Congyang 
> >>> Reviewed-by: Lai Jiangshan 
> >>> Tested-by: Lin Feng 
> >>> ---
> >>>  mm/page_alloc.c |   77 
> >>> +++
> >>>  1 files changed, 77 insertions(+), 0 deletions(-)
> >>>
> >>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> >>> index 1c91d16..4853619 100644
> >>> --- a/mm/page_alloc.c
> >>> +++ b/mm/page_alloc.c
> >>> @@ -206,6 +206,7 @@ static unsigned long __meminitdata 
> >>> arch_zone_highest_possible_pfn[MAX_NR_ZONES];
> >>>  static unsigned long __initdata required_kernelcore;
> >>>  static unsigned long __initdata required_movablecore;
> >>>  static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
> >>> +static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];
> >>>  
> >>>  /* movable_zone is the "real" zone pages in ZONE_MOVABLE are taken from 
> >>> */
> >>>  int movable_zone;
> >>> @@ -4340,6 +4341,77 @@ static unsigned long __meminit 
> >>> zone_absent_pages_in_node(int nid,
> >>>   return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
> >>>  }
> >>>  
> >>> +/**
> >>> + * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
> >>> + *
> >>> + * zone_movable_limit is initialized as 0. This function will try to get
> >>> + * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
> >>> + * assigne them to zone_movable_limit.
> >>> + * zone_movable_limit[nid] == 0 means no limit for the node.
> >>> + *
> >>> + * Note: Each range is represented as [start_pfn, end_pfn)
> >>> + */
> >>> +static void __meminit sanitize_zone_movable_limit(void)
> >>> +{
> >>> + int map_pos = 0, i, nid;
> >>> + unsigned long start_pfn, end_pfn;
> >>> +
> >>> + if (!movablecore_map.nr_map)
> >>> + return;
> >>> +
> >>> + /* Iterate all ranges from minimum to maximum */
> >>> + for_each_mem_pfn_range(i, MAX_NUMNODES, _pfn, _pfn, ) {
> >>> + /*
> >>> +  * If we have found lowest pfn of ZONE_MOVABLE of the node
> >>> +  * specified by user, just go on to check next range.
> >>> +  */
> >>> + if (zone_movable_limit[nid])
> >>> + continue;
> >>> +
> >>> +#ifdef CONFIG_ZONE_DMA
> >>> + /* Skip DMA memory. */
> >>> + if (start_pfn < arch_zone_highest_possible_pfn[ZONE_DMA])
> >>> + start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA];
> >>> +#endif
> >>> +
> >>> +#ifdef CONFIG_ZONE_DMA32
> >>> + /* Skip DMA32 memory. */
> >>> + if (start_pfn < arch_zone_highest_possible_pfn[ZONE_DMA32])
> >>> + start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA32];
> >>> +#endif
> >>> +
> >>> +#ifdef CONFIG_HIGHMEM
> >>> + /* Skip lowmem if ZONE_MOVABLE is highmem. */
> >>> + if (zone_movable_is_highmem() &&
> >>
> >> Hi Tang,
> >>
> >> I think zone_movable_is_highmem() is not work correctly here.
> >>sanitize_zone_movable_limit
> >>zone_movable_is_highmem  <--using movable_zone here
> >>find_zone_movable_pfns_for_nodes
> >>find_usable_zone_for_movable <--movable_zone is specified here
> >>
> > 
> > Hi Jiangguo and Chen,
> > 
> > - What's the meaning of zone_movable_is_highmem(), does it mean all zone
> > highmem pages are zone movable pages or 
> 
> Hi Simon,
> 
> zone_movable_is_highmem() means whether zone pages in ZONE_MOVABLE are taken 
> from
> highmem.
> 
> > - dmesg 
> > 
> >> 0.00] Zone ranges:
> >> [0.00]   DMA  [mem 0x0001-0x00ff]
> >> [0.00]   Normal   [mem 0x0100-0x373fdfff]
> >> [0.00]   HighMem  [mem 0x373fe000-0xb6cf]
> >> [0.00] Movable zone start for each node
> >> [0.00]   Node 0: 0x9780
> > 
> > Why the start of zone movable is in the range of zone highmem, if all
> > the pages of zone movable are from zone highmem? If the answer is yes, 
> 
> > zone movable and zone highmem are in the equal status or not?
> 
> The pages of zone_movable can be taken from zone_movalbe or zone_normal,
> if we have highmem, then zone_movable will be taken from zone_highmem,
> otherwise zone_movable will be taken from zone_normal.
> 
> you can refer to find_usable_zone_for_movable().

Hi Jiangguo,

I have 8G memory, movablecore=5G, but dmesg looks strange, what
happended to me?

> [0.00] Zone ranges:
> [0.00]   DMA  [mem 

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-11 Thread Jianguo Wu
On 2012/12/11 20:24, Simon Jeons wrote:

> On Tue, 2012-12-11 at 11:07 +0800, Jianguo Wu wrote:
>> On 2012/12/11 10:33, Tang Chen wrote:
>>
>>> This patch introduces a new array zone_movable_limit[] to store the
>>> ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
>>> The function sanitize_zone_movable_limit() will find out to which
>>> node the ranges in movable_map.map[] belongs, and calculates the
>>> low boundary of ZONE_MOVABLE for each node.
>>>
>>> Signed-off-by: Tang Chen 
>>> Signed-off-by: Jiang Liu 
>>> Reviewed-by: Wen Congyang 
>>> Reviewed-by: Lai Jiangshan 
>>> Tested-by: Lin Feng 
>>> ---
>>>  mm/page_alloc.c |   77 
>>> +++
>>>  1 files changed, 77 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>>> index 1c91d16..4853619 100644
>>> --- a/mm/page_alloc.c
>>> +++ b/mm/page_alloc.c
>>> @@ -206,6 +206,7 @@ static unsigned long __meminitdata 
>>> arch_zone_highest_possible_pfn[MAX_NR_ZONES];
>>>  static unsigned long __initdata required_kernelcore;
>>>  static unsigned long __initdata required_movablecore;
>>>  static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
>>> +static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];
>>>  
>>>  /* movable_zone is the "real" zone pages in ZONE_MOVABLE are taken from */
>>>  int movable_zone;
>>> @@ -4340,6 +4341,77 @@ static unsigned long __meminit 
>>> zone_absent_pages_in_node(int nid,
>>> return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
>>>  }
>>>  
>>> +/**
>>> + * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
>>> + *
>>> + * zone_movable_limit is initialized as 0. This function will try to get
>>> + * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
>>> + * assigne them to zone_movable_limit.
>>> + * zone_movable_limit[nid] == 0 means no limit for the node.
>>> + *
>>> + * Note: Each range is represented as [start_pfn, end_pfn)
>>> + */
>>> +static void __meminit sanitize_zone_movable_limit(void)
>>> +{
>>> +   int map_pos = 0, i, nid;
>>> +   unsigned long start_pfn, end_pfn;
>>> +
>>> +   if (!movablecore_map.nr_map)
>>> +   return;
>>> +
>>> +   /* Iterate all ranges from minimum to maximum */
>>> +   for_each_mem_pfn_range(i, MAX_NUMNODES, _pfn, _pfn, ) {
>>> +   /*
>>> +* If we have found lowest pfn of ZONE_MOVABLE of the node
>>> +* specified by user, just go on to check next range.
>>> +*/
>>> +   if (zone_movable_limit[nid])
>>> +   continue;
>>> +
>>> +#ifdef CONFIG_ZONE_DMA
>>> +   /* Skip DMA memory. */
>>> +   if (start_pfn < arch_zone_highest_possible_pfn[ZONE_DMA])
>>> +   start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA];
>>> +#endif
>>> +
>>> +#ifdef CONFIG_ZONE_DMA32
>>> +   /* Skip DMA32 memory. */
>>> +   if (start_pfn < arch_zone_highest_possible_pfn[ZONE_DMA32])
>>> +   start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA32];
>>> +#endif
>>> +
>>> +#ifdef CONFIG_HIGHMEM
>>> +   /* Skip lowmem if ZONE_MOVABLE is highmem. */
>>> +   if (zone_movable_is_highmem() &&
>>
>> Hi Tang,
>>
>> I think zone_movable_is_highmem() is not work correctly here.
>>  sanitize_zone_movable_limit
>>  zone_movable_is_highmem  <--using movable_zone here
>>  find_zone_movable_pfns_for_nodes
>>  find_usable_zone_for_movable <--movable_zone is specified here
>>
> 
> Hi Jiangguo and Chen,
> 
> - What's the meaning of zone_movable_is_highmem(), does it mean all zone
> highmem pages are zone movable pages or 

Hi Simon,

zone_movable_is_highmem() means whether zone pages in ZONE_MOVABLE are taken 
from
highmem.

> - dmesg 
> 
>> 0.00] Zone ranges:
>> [0.00]   DMA  [mem 0x0001-0x00ff]
>> [0.00]   Normal   [mem 0x0100-0x373fdfff]
>> [0.00]   HighMem  [mem 0x373fe000-0xb6cf]
>> [0.00] Movable zone start for each node
>> [0.00]   Node 0: 0x9780
> 
> Why the start of zone movable is in the range of zone highmem, if all
> the pages of zone movable are from zone highmem? If the answer is yes, 

> zone movable and zone highmem are in the equal status or not?

The pages of zone_movable can be taken from zone_movalbe or zone_normal,
if we have highmem, then zone_movable will be taken from zone_highmem,
otherwise zone_movable will be taken from zone_normal.

you can refer to find_usable_zone_for_movable().

Thanks,
Jianguo Wu

> 
>> I think Jiang Liu's patch works fine for highmem, please refer to:
>> http://marc.info/?l=linux-mm=135476085816087=2
>>
>> Thanks,
>> Jianguo Wu
>>
>>> +   start_pfn < arch_zone_lowest_possible_pfn[ZONE_HIGHMEM])
>>> +   start_pfn = arch_zone_lowest_possible_pfn[ZONE_HIGHMEM];
>>> +#endif
>>> +
>>> +   if (start_pfn >= end_pfn)
>>> +   

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-11 Thread Simon Jeons
On Tue, 2012-12-11 at 11:07 +0800, Jianguo Wu wrote:
> On 2012/12/11 10:33, Tang Chen wrote:
> 
> > This patch introduces a new array zone_movable_limit[] to store the
> > ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
> > The function sanitize_zone_movable_limit() will find out to which
> > node the ranges in movable_map.map[] belongs, and calculates the
> > low boundary of ZONE_MOVABLE for each node.
> > 
> > Signed-off-by: Tang Chen 
> > Signed-off-by: Jiang Liu 
> > Reviewed-by: Wen Congyang 
> > Reviewed-by: Lai Jiangshan 
> > Tested-by: Lin Feng 
> > ---
> >  mm/page_alloc.c |   77 
> > +++
> >  1 files changed, 77 insertions(+), 0 deletions(-)
> > 
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index 1c91d16..4853619 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -206,6 +206,7 @@ static unsigned long __meminitdata 
> > arch_zone_highest_possible_pfn[MAX_NR_ZONES];
> >  static unsigned long __initdata required_kernelcore;
> >  static unsigned long __initdata required_movablecore;
> >  static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
> > +static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];
> >  
> >  /* movable_zone is the "real" zone pages in ZONE_MOVABLE are taken from */
> >  int movable_zone;
> > @@ -4340,6 +4341,77 @@ static unsigned long __meminit 
> > zone_absent_pages_in_node(int nid,
> > return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
> >  }
> >  
> > +/**
> > + * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
> > + *
> > + * zone_movable_limit is initialized as 0. This function will try to get
> > + * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
> > + * assigne them to zone_movable_limit.
> > + * zone_movable_limit[nid] == 0 means no limit for the node.
> > + *
> > + * Note: Each range is represented as [start_pfn, end_pfn)
> > + */
> > +static void __meminit sanitize_zone_movable_limit(void)
> > +{
> > +   int map_pos = 0, i, nid;
> > +   unsigned long start_pfn, end_pfn;
> > +
> > +   if (!movablecore_map.nr_map)
> > +   return;
> > +
> > +   /* Iterate all ranges from minimum to maximum */
> > +   for_each_mem_pfn_range(i, MAX_NUMNODES, _pfn, _pfn, ) {
> > +   /*
> > +* If we have found lowest pfn of ZONE_MOVABLE of the node
> > +* specified by user, just go on to check next range.
> > +*/
> > +   if (zone_movable_limit[nid])
> > +   continue;
> > +
> > +#ifdef CONFIG_ZONE_DMA
> > +   /* Skip DMA memory. */
> > +   if (start_pfn < arch_zone_highest_possible_pfn[ZONE_DMA])
> > +   start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA];
> > +#endif
> > +
> > +#ifdef CONFIG_ZONE_DMA32
> > +   /* Skip DMA32 memory. */
> > +   if (start_pfn < arch_zone_highest_possible_pfn[ZONE_DMA32])
> > +   start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA32];
> > +#endif
> > +
> > +#ifdef CONFIG_HIGHMEM
> > +   /* Skip lowmem if ZONE_MOVABLE is highmem. */
> > +   if (zone_movable_is_highmem() &&
> 
> Hi Tang,
> 
> I think zone_movable_is_highmem() is not work correctly here.
>   sanitize_zone_movable_limit
>   zone_movable_is_highmem  <--using movable_zone here
>   find_zone_movable_pfns_for_nodes
>   find_usable_zone_for_movable <--movable_zone is specified here
> 

Hi Jiangguo and Chen,

- What's the meaning of zone_movable_is_highmem(), does it mean all zone
highmem pages are zone movable pages or 
- dmesg 

> 0.00] Zone ranges:
> [0.00]   DMA  [mem 0x0001-0x00ff]
> [0.00]   Normal   [mem 0x0100-0x373fdfff]
> [0.00]   HighMem  [mem 0x373fe000-0xb6cf]
> [0.00] Movable zone start for each node
> [0.00]   Node 0: 0x9780

Why the start of zone movable is in the range of zone highmem, if all
the pages of zone movable are from zone highmem? If the answer is yes, 
zone movable and zone highmem are in the equal status or not?

> I think Jiang Liu's patch works fine for highmem, please refer to:
> http://marc.info/?l=linux-mm=135476085816087=2
> 
> Thanks,
> Jianguo Wu
> 
> > +   start_pfn < arch_zone_lowest_possible_pfn[ZONE_HIGHMEM])
> > +   start_pfn = arch_zone_lowest_possible_pfn[ZONE_HIGHMEM];
> > +#endif
> > +
> > +   if (start_pfn >= end_pfn)
> > +   continue;
> > +
> > +   while (map_pos < movablecore_map.nr_map) {
> > +   if (end_pfn <= movablecore_map.map[map_pos].start_pfn)
> > +   break;
> > +
> > +   if (start_pfn >= movablecore_map.map[map_pos].end_pfn) {
> > +   map_pos++;
> > +   continue;
> > +   }
> > +
> > +   /*
> > +* The 

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-11 Thread Simon Jeons
On Tue, 2012-12-11 at 11:32 +0800, Tang Chen wrote:
> On 12/11/2012 11:07 AM, Jianguo Wu wrote:
> > On 2012/12/11 10:33, Tang Chen wrote:
> >
> >> This patch introduces a new array zone_movable_limit[] to store the
> >> ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
> >> The function sanitize_zone_movable_limit() will find out to which
> >> node the ranges in movable_map.map[] belongs, and calculates the
> >> low boundary of ZONE_MOVABLE for each node.

What's the difference between zone_movable_limit[nid] and
zone_movable_pfn[nid]?

> >>
> >> Signed-off-by: Tang Chen
> >> Signed-off-by: Jiang Liu
> >> Reviewed-by: Wen Congyang
> >> Reviewed-by: Lai Jiangshan
> >> Tested-by: Lin Feng
> >> ---
> >>   mm/page_alloc.c |   77 
> >> +++
> >>   1 files changed, 77 insertions(+), 0 deletions(-)
> >>
> >> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> >> index 1c91d16..4853619 100644
> >> --- a/mm/page_alloc.c
> >> +++ b/mm/page_alloc.c
> >> @@ -206,6 +206,7 @@ static unsigned long __meminitdata 
> >> arch_zone_highest_possible_pfn[MAX_NR_ZONES];
> >>   static unsigned long __initdata required_kernelcore;
> >>   static unsigned long __initdata required_movablecore;
> >>   static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
> >> +static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];
> >>
> >>   /* movable_zone is the "real" zone pages in ZONE_MOVABLE are taken from 
> >> */
> >>   int movable_zone;
> >> @@ -4340,6 +4341,77 @@ static unsigned long __meminit 
> >> zone_absent_pages_in_node(int nid,
> >>return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
> >>   }
> >>
> >> +/**
> >> + * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
> >> + *
> >> + * zone_movable_limit is initialized as 0. This function will try to get
> >> + * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
> >> + * assigne them to zone_movable_limit.
> >> + * zone_movable_limit[nid] == 0 means no limit for the node.
> >> + *
> >> + * Note: Each range is represented as [start_pfn, end_pfn)
> >> + */
> >> +static void __meminit sanitize_zone_movable_limit(void)
> >> +{
> >> +  int map_pos = 0, i, nid;
> >> +  unsigned long start_pfn, end_pfn;
> >> +
> >> +  if (!movablecore_map.nr_map)
> >> +  return;
> >> +
> >> +  /* Iterate all ranges from minimum to maximum */
> >> +  for_each_mem_pfn_range(i, MAX_NUMNODES,_pfn,_pfn,) {
> >> +  /*
> >> +   * If we have found lowest pfn of ZONE_MOVABLE of the node
> >> +   * specified by user, just go on to check next range.
> >> +   */
> >> +  if (zone_movable_limit[nid])
> >> +  continue;
> >> +
> >> +#ifdef CONFIG_ZONE_DMA
> >> +  /* Skip DMA memory. */
> >> +  if (start_pfn<  arch_zone_highest_possible_pfn[ZONE_DMA])
> >> +  start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA];
> >> +#endif
> >> +
> >> +#ifdef CONFIG_ZONE_DMA32
> >> +  /* Skip DMA32 memory. */
> >> +  if (start_pfn<  arch_zone_highest_possible_pfn[ZONE_DMA32])
> >> +  start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA32];
> >> +#endif
> >> +
> >> +#ifdef CONFIG_HIGHMEM
> >> +  /* Skip lowmem if ZONE_MOVABLE is highmem. */
> >> +  if (zone_movable_is_highmem()&&
> >
> > Hi Tang,
> >
> > I think zone_movable_is_highmem() is not work correctly here.
> > sanitize_zone_movable_limit
> > zone_movable_is_highmem<--using movable_zone here
> > find_zone_movable_pfns_for_nodes
> > find_usable_zone_for_movable<--movable_zone is specified here
> >
> > I think Jiang Liu's patch works fine for highmem, please refer to:
> > http://marc.info/?l=linux-mm=135476085816087=2
> 
> Hi Wu,
> 
> Yes, I forgot movable_zone think. Thanks for reminding me. :)
> 
> But Liu's patch you just mentioned, I didn't use it because I
> don't think we should skip kernelcore when movablecore_map is specified.
> If these 2 options are not conflict, we should satisfy them both. :)
> 
> Of course, I also think Liu's suggestion is wonderful. But I think we
> need more discussion on it. :)
> 
> I'll fix it soon.
> Thanks. :)
> 
> >
> > Thanks,
> > Jianguo Wu
> >
> >> +  start_pfn<  arch_zone_lowest_possible_pfn[ZONE_HIGHMEM])
> >> +  start_pfn = arch_zone_lowest_possible_pfn[ZONE_HIGHMEM];
> >> +#endif
> >> +
> >> +  if (start_pfn>= end_pfn)
> >> +  continue;
> >> +
> >> +  while (map_pos<  movablecore_map.nr_map) {
> >> +  if (end_pfn<= movablecore_map.map[map_pos].start_pfn)
> >> +  break;
> >> +
> >> +  if (start_pfn>= movablecore_map.map[map_pos].end_pfn) {
> >> +  map_pos++;
> >> +  continue;
> >> +  }
> >> +
> >> +  /*
> >> +   * The 

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-11 Thread Simon Jeons
On Tue, 2012-12-11 at 11:32 +0800, Tang Chen wrote:
 On 12/11/2012 11:07 AM, Jianguo Wu wrote:
  On 2012/12/11 10:33, Tang Chen wrote:
 
  This patch introduces a new array zone_movable_limit[] to store the
  ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
  The function sanitize_zone_movable_limit() will find out to which
  node the ranges in movable_map.map[] belongs, and calculates the
  low boundary of ZONE_MOVABLE for each node.

What's the difference between zone_movable_limit[nid] and
zone_movable_pfn[nid]?

 
  Signed-off-by: Tang Chentangc...@cn.fujitsu.com
  Signed-off-by: Jiang Liujiang@huawei.com
  Reviewed-by: Wen Congyangwe...@cn.fujitsu.com
  Reviewed-by: Lai Jiangshanla...@cn.fujitsu.com
  Tested-by: Lin Fenglinf...@cn.fujitsu.com
  ---
mm/page_alloc.c |   77 
  +++
1 files changed, 77 insertions(+), 0 deletions(-)
 
  diff --git a/mm/page_alloc.c b/mm/page_alloc.c
  index 1c91d16..4853619 100644
  --- a/mm/page_alloc.c
  +++ b/mm/page_alloc.c
  @@ -206,6 +206,7 @@ static unsigned long __meminitdata 
  arch_zone_highest_possible_pfn[MAX_NR_ZONES];
static unsigned long __initdata required_kernelcore;
static unsigned long __initdata required_movablecore;
static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
  +static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];
 
/* movable_zone is the real zone pages in ZONE_MOVABLE are taken from 
  */
int movable_zone;
  @@ -4340,6 +4341,77 @@ static unsigned long __meminit 
  zone_absent_pages_in_node(int nid,
 return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
}
 
  +/**
  + * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
  + *
  + * zone_movable_limit is initialized as 0. This function will try to get
  + * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
  + * assigne them to zone_movable_limit.
  + * zone_movable_limit[nid] == 0 means no limit for the node.
  + *
  + * Note: Each range is represented as [start_pfn, end_pfn)
  + */
  +static void __meminit sanitize_zone_movable_limit(void)
  +{
  +  int map_pos = 0, i, nid;
  +  unsigned long start_pfn, end_pfn;
  +
  +  if (!movablecore_map.nr_map)
  +  return;
  +
  +  /* Iterate all ranges from minimum to maximum */
  +  for_each_mem_pfn_range(i, MAX_NUMNODES,start_pfn,end_pfn,nid) {
  +  /*
  +   * If we have found lowest pfn of ZONE_MOVABLE of the node
  +   * specified by user, just go on to check next range.
  +   */
  +  if (zone_movable_limit[nid])
  +  continue;
  +
  +#ifdef CONFIG_ZONE_DMA
  +  /* Skip DMA memory. */
  +  if (start_pfn  arch_zone_highest_possible_pfn[ZONE_DMA])
  +  start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA];
  +#endif
  +
  +#ifdef CONFIG_ZONE_DMA32
  +  /* Skip DMA32 memory. */
  +  if (start_pfn  arch_zone_highest_possible_pfn[ZONE_DMA32])
  +  start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA32];
  +#endif
  +
  +#ifdef CONFIG_HIGHMEM
  +  /* Skip lowmem if ZONE_MOVABLE is highmem. */
  +  if (zone_movable_is_highmem()
 
  Hi Tang,
 
  I think zone_movable_is_highmem() is not work correctly here.
  sanitize_zone_movable_limit
  zone_movable_is_highmem--using movable_zone here
  find_zone_movable_pfns_for_nodes
  find_usable_zone_for_movable--movable_zone is specified here
 
  I think Jiang Liu's patch works fine for highmem, please refer to:
  http://marc.info/?l=linux-mmm=135476085816087w=2
 
 Hi Wu,
 
 Yes, I forgot movable_zone think. Thanks for reminding me. :)
 
 But Liu's patch you just mentioned, I didn't use it because I
 don't think we should skip kernelcore when movablecore_map is specified.
 If these 2 options are not conflict, we should satisfy them both. :)
 
 Of course, I also think Liu's suggestion is wonderful. But I think we
 need more discussion on it. :)
 
 I'll fix it soon.
 Thanks. :)
 
 
  Thanks,
  Jianguo Wu
 
  +  start_pfn  arch_zone_lowest_possible_pfn[ZONE_HIGHMEM])
  +  start_pfn = arch_zone_lowest_possible_pfn[ZONE_HIGHMEM];
  +#endif
  +
  +  if (start_pfn= end_pfn)
  +  continue;
  +
  +  while (map_pos  movablecore_map.nr_map) {
  +  if (end_pfn= movablecore_map.map[map_pos].start_pfn)
  +  break;
  +
  +  if (start_pfn= movablecore_map.map[map_pos].end_pfn) {
  +  map_pos++;
  +  continue;
  +  }
  +
  +  /*
  +   * The start_pfn of ZONE_MOVABLE is either the minimum
  +   * pfn specified by movablecore_map, or 0, which means
  +   * the node has no ZONE_MOVABLE.
  +   */
  +  

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-11 Thread Simon Jeons
On Tue, 2012-12-11 at 11:07 +0800, Jianguo Wu wrote:
 On 2012/12/11 10:33, Tang Chen wrote:
 
  This patch introduces a new array zone_movable_limit[] to store the
  ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
  The function sanitize_zone_movable_limit() will find out to which
  node the ranges in movable_map.map[] belongs, and calculates the
  low boundary of ZONE_MOVABLE for each node.
  
  Signed-off-by: Tang Chen tangc...@cn.fujitsu.com
  Signed-off-by: Jiang Liu jiang@huawei.com
  Reviewed-by: Wen Congyang we...@cn.fujitsu.com
  Reviewed-by: Lai Jiangshan la...@cn.fujitsu.com
  Tested-by: Lin Feng linf...@cn.fujitsu.com
  ---
   mm/page_alloc.c |   77 
  +++
   1 files changed, 77 insertions(+), 0 deletions(-)
  
  diff --git a/mm/page_alloc.c b/mm/page_alloc.c
  index 1c91d16..4853619 100644
  --- a/mm/page_alloc.c
  +++ b/mm/page_alloc.c
  @@ -206,6 +206,7 @@ static unsigned long __meminitdata 
  arch_zone_highest_possible_pfn[MAX_NR_ZONES];
   static unsigned long __initdata required_kernelcore;
   static unsigned long __initdata required_movablecore;
   static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
  +static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];
   
   /* movable_zone is the real zone pages in ZONE_MOVABLE are taken from */
   int movable_zone;
  @@ -4340,6 +4341,77 @@ static unsigned long __meminit 
  zone_absent_pages_in_node(int nid,
  return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
   }
   
  +/**
  + * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
  + *
  + * zone_movable_limit is initialized as 0. This function will try to get
  + * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
  + * assigne them to zone_movable_limit.
  + * zone_movable_limit[nid] == 0 means no limit for the node.
  + *
  + * Note: Each range is represented as [start_pfn, end_pfn)
  + */
  +static void __meminit sanitize_zone_movable_limit(void)
  +{
  +   int map_pos = 0, i, nid;
  +   unsigned long start_pfn, end_pfn;
  +
  +   if (!movablecore_map.nr_map)
  +   return;
  +
  +   /* Iterate all ranges from minimum to maximum */
  +   for_each_mem_pfn_range(i, MAX_NUMNODES, start_pfn, end_pfn, nid) {
  +   /*
  +* If we have found lowest pfn of ZONE_MOVABLE of the node
  +* specified by user, just go on to check next range.
  +*/
  +   if (zone_movable_limit[nid])
  +   continue;
  +
  +#ifdef CONFIG_ZONE_DMA
  +   /* Skip DMA memory. */
  +   if (start_pfn  arch_zone_highest_possible_pfn[ZONE_DMA])
  +   start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA];
  +#endif
  +
  +#ifdef CONFIG_ZONE_DMA32
  +   /* Skip DMA32 memory. */
  +   if (start_pfn  arch_zone_highest_possible_pfn[ZONE_DMA32])
  +   start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA32];
  +#endif
  +
  +#ifdef CONFIG_HIGHMEM
  +   /* Skip lowmem if ZONE_MOVABLE is highmem. */
  +   if (zone_movable_is_highmem() 
 
 Hi Tang,
 
 I think zone_movable_is_highmem() is not work correctly here.
   sanitize_zone_movable_limit
   zone_movable_is_highmem  --using movable_zone here
   find_zone_movable_pfns_for_nodes
   find_usable_zone_for_movable --movable_zone is specified here
 

Hi Jiangguo and Chen,

- What's the meaning of zone_movable_is_highmem(), does it mean all zone
highmem pages are zone movable pages or 
- dmesg 

 0.00] Zone ranges:
 [0.00]   DMA  [mem 0x0001-0x00ff]
 [0.00]   Normal   [mem 0x0100-0x373fdfff]
 [0.00]   HighMem  [mem 0x373fe000-0xb6cf]
 [0.00] Movable zone start for each node
 [0.00]   Node 0: 0x9780

Why the start of zone movable is in the range of zone highmem, if all
the pages of zone movable are from zone highmem? If the answer is yes, 
zone movable and zone highmem are in the equal status or not?

 I think Jiang Liu's patch works fine for highmem, please refer to:
 http://marc.info/?l=linux-mmm=135476085816087w=2
 
 Thanks,
 Jianguo Wu
 
  +   start_pfn  arch_zone_lowest_possible_pfn[ZONE_HIGHMEM])
  +   start_pfn = arch_zone_lowest_possible_pfn[ZONE_HIGHMEM];
  +#endif
  +
  +   if (start_pfn = end_pfn)
  +   continue;
  +
  +   while (map_pos  movablecore_map.nr_map) {
  +   if (end_pfn = movablecore_map.map[map_pos].start_pfn)
  +   break;
  +
  +   if (start_pfn = movablecore_map.map[map_pos].end_pfn) {
  +   map_pos++;
  +   continue;
  +   }
  +
  +   /*
  +* The start_pfn of ZONE_MOVABLE is either the minimum
  +* pfn specified by 

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-11 Thread Jianguo Wu
On 2012/12/11 20:24, Simon Jeons wrote:

 On Tue, 2012-12-11 at 11:07 +0800, Jianguo Wu wrote:
 On 2012/12/11 10:33, Tang Chen wrote:

 This patch introduces a new array zone_movable_limit[] to store the
 ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
 The function sanitize_zone_movable_limit() will find out to which
 node the ranges in movable_map.map[] belongs, and calculates the
 low boundary of ZONE_MOVABLE for each node.

 Signed-off-by: Tang Chen tangc...@cn.fujitsu.com
 Signed-off-by: Jiang Liu jiang@huawei.com
 Reviewed-by: Wen Congyang we...@cn.fujitsu.com
 Reviewed-by: Lai Jiangshan la...@cn.fujitsu.com
 Tested-by: Lin Feng linf...@cn.fujitsu.com
 ---
  mm/page_alloc.c |   77 
 +++
  1 files changed, 77 insertions(+), 0 deletions(-)

 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
 index 1c91d16..4853619 100644
 --- a/mm/page_alloc.c
 +++ b/mm/page_alloc.c
 @@ -206,6 +206,7 @@ static unsigned long __meminitdata 
 arch_zone_highest_possible_pfn[MAX_NR_ZONES];
  static unsigned long __initdata required_kernelcore;
  static unsigned long __initdata required_movablecore;
  static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
 +static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];
  
  /* movable_zone is the real zone pages in ZONE_MOVABLE are taken from */
  int movable_zone;
 @@ -4340,6 +4341,77 @@ static unsigned long __meminit 
 zone_absent_pages_in_node(int nid,
 return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
  }
  
 +/**
 + * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
 + *
 + * zone_movable_limit is initialized as 0. This function will try to get
 + * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
 + * assigne them to zone_movable_limit.
 + * zone_movable_limit[nid] == 0 means no limit for the node.
 + *
 + * Note: Each range is represented as [start_pfn, end_pfn)
 + */
 +static void __meminit sanitize_zone_movable_limit(void)
 +{
 +   int map_pos = 0, i, nid;
 +   unsigned long start_pfn, end_pfn;
 +
 +   if (!movablecore_map.nr_map)
 +   return;
 +
 +   /* Iterate all ranges from minimum to maximum */
 +   for_each_mem_pfn_range(i, MAX_NUMNODES, start_pfn, end_pfn, nid) {
 +   /*
 +* If we have found lowest pfn of ZONE_MOVABLE of the node
 +* specified by user, just go on to check next range.
 +*/
 +   if (zone_movable_limit[nid])
 +   continue;
 +
 +#ifdef CONFIG_ZONE_DMA
 +   /* Skip DMA memory. */
 +   if (start_pfn  arch_zone_highest_possible_pfn[ZONE_DMA])
 +   start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA];
 +#endif
 +
 +#ifdef CONFIG_ZONE_DMA32
 +   /* Skip DMA32 memory. */
 +   if (start_pfn  arch_zone_highest_possible_pfn[ZONE_DMA32])
 +   start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA32];
 +#endif
 +
 +#ifdef CONFIG_HIGHMEM
 +   /* Skip lowmem if ZONE_MOVABLE is highmem. */
 +   if (zone_movable_is_highmem() 

 Hi Tang,

 I think zone_movable_is_highmem() is not work correctly here.
  sanitize_zone_movable_limit
  zone_movable_is_highmem  --using movable_zone here
  find_zone_movable_pfns_for_nodes
  find_usable_zone_for_movable --movable_zone is specified here

 
 Hi Jiangguo and Chen,
 
 - What's the meaning of zone_movable_is_highmem(), does it mean all zone
 highmem pages are zone movable pages or 

Hi Simon,

zone_movable_is_highmem() means whether zone pages in ZONE_MOVABLE are taken 
from
highmem.

 - dmesg 
 
 0.00] Zone ranges:
 [0.00]   DMA  [mem 0x0001-0x00ff]
 [0.00]   Normal   [mem 0x0100-0x373fdfff]
 [0.00]   HighMem  [mem 0x373fe000-0xb6cf]
 [0.00] Movable zone start for each node
 [0.00]   Node 0: 0x9780
 
 Why the start of zone movable is in the range of zone highmem, if all
 the pages of zone movable are from zone highmem? If the answer is yes, 

 zone movable and zone highmem are in the equal status or not?

The pages of zone_movable can be taken from zone_movalbe or zone_normal,
if we have highmem, then zone_movable will be taken from zone_highmem,
otherwise zone_movable will be taken from zone_normal.

you can refer to find_usable_zone_for_movable().

Thanks,
Jianguo Wu

 
 I think Jiang Liu's patch works fine for highmem, please refer to:
 http://marc.info/?l=linux-mmm=135476085816087w=2

 Thanks,
 Jianguo Wu

 +   start_pfn  arch_zone_lowest_possible_pfn[ZONE_HIGHMEM])
 +   start_pfn = arch_zone_lowest_possible_pfn[ZONE_HIGHMEM];
 +#endif
 +
 +   if (start_pfn = end_pfn)
 +   continue;
 +
 +   while (map_pos  movablecore_map.nr_map) {
 +   if (end_pfn = movablecore_map.map[map_pos].start_pfn)
 +   break;
 +
 + 

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-11 Thread Simon Jeons
On Tue, 2012-12-11 at 20:41 +0800, Jianguo Wu wrote:
 On 2012/12/11 20:24, Simon Jeons wrote:
 
  On Tue, 2012-12-11 at 11:07 +0800, Jianguo Wu wrote:
  On 2012/12/11 10:33, Tang Chen wrote:
 
  This patch introduces a new array zone_movable_limit[] to store the
  ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
  The function sanitize_zone_movable_limit() will find out to which
  node the ranges in movable_map.map[] belongs, and calculates the
  low boundary of ZONE_MOVABLE for each node.
 
  Signed-off-by: Tang Chen tangc...@cn.fujitsu.com
  Signed-off-by: Jiang Liu jiang@huawei.com
  Reviewed-by: Wen Congyang we...@cn.fujitsu.com
  Reviewed-by: Lai Jiangshan la...@cn.fujitsu.com
  Tested-by: Lin Feng linf...@cn.fujitsu.com
  ---
   mm/page_alloc.c |   77 
  +++
   1 files changed, 77 insertions(+), 0 deletions(-)
 
  diff --git a/mm/page_alloc.c b/mm/page_alloc.c
  index 1c91d16..4853619 100644
  --- a/mm/page_alloc.c
  +++ b/mm/page_alloc.c
  @@ -206,6 +206,7 @@ static unsigned long __meminitdata 
  arch_zone_highest_possible_pfn[MAX_NR_ZONES];
   static unsigned long __initdata required_kernelcore;
   static unsigned long __initdata required_movablecore;
   static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
  +static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];
   
   /* movable_zone is the real zone pages in ZONE_MOVABLE are taken from 
  */
   int movable_zone;
  @@ -4340,6 +4341,77 @@ static unsigned long __meminit 
  zone_absent_pages_in_node(int nid,
return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
   }
   
  +/**
  + * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
  + *
  + * zone_movable_limit is initialized as 0. This function will try to get
  + * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
  + * assigne them to zone_movable_limit.
  + * zone_movable_limit[nid] == 0 means no limit for the node.
  + *
  + * Note: Each range is represented as [start_pfn, end_pfn)
  + */
  +static void __meminit sanitize_zone_movable_limit(void)
  +{
  + int map_pos = 0, i, nid;
  + unsigned long start_pfn, end_pfn;
  +
  + if (!movablecore_map.nr_map)
  + return;
  +
  + /* Iterate all ranges from minimum to maximum */
  + for_each_mem_pfn_range(i, MAX_NUMNODES, start_pfn, end_pfn, nid) {
  + /*
  +  * If we have found lowest pfn of ZONE_MOVABLE of the node
  +  * specified by user, just go on to check next range.
  +  */
  + if (zone_movable_limit[nid])
  + continue;
  +
  +#ifdef CONFIG_ZONE_DMA
  + /* Skip DMA memory. */
  + if (start_pfn  arch_zone_highest_possible_pfn[ZONE_DMA])
  + start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA];
  +#endif
  +
  +#ifdef CONFIG_ZONE_DMA32
  + /* Skip DMA32 memory. */
  + if (start_pfn  arch_zone_highest_possible_pfn[ZONE_DMA32])
  + start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA32];
  +#endif
  +
  +#ifdef CONFIG_HIGHMEM
  + /* Skip lowmem if ZONE_MOVABLE is highmem. */
  + if (zone_movable_is_highmem() 
 
  Hi Tang,
 
  I think zone_movable_is_highmem() is not work correctly here.
 sanitize_zone_movable_limit
 zone_movable_is_highmem  --using movable_zone here
 find_zone_movable_pfns_for_nodes
 find_usable_zone_for_movable --movable_zone is specified here
 
  
  Hi Jiangguo and Chen,
  
  - What's the meaning of zone_movable_is_highmem(), does it mean all zone
  highmem pages are zone movable pages or 
 
 Hi Simon,
 
 zone_movable_is_highmem() means whether zone pages in ZONE_MOVABLE are taken 
 from
 highmem.
 
  - dmesg 
  
  0.00] Zone ranges:
  [0.00]   DMA  [mem 0x0001-0x00ff]
  [0.00]   Normal   [mem 0x0100-0x373fdfff]
  [0.00]   HighMem  [mem 0x373fe000-0xb6cf]
  [0.00] Movable zone start for each node
  [0.00]   Node 0: 0x9780
  
  Why the start of zone movable is in the range of zone highmem, if all
  the pages of zone movable are from zone highmem? If the answer is yes, 
 
  zone movable and zone highmem are in the equal status or not?
 
 The pages of zone_movable can be taken from zone_movalbe or zone_normal,
 if we have highmem, then zone_movable will be taken from zone_highmem,
 otherwise zone_movable will be taken from zone_normal.
 
 you can refer to find_usable_zone_for_movable().

Hi Jiangguo,

I have 8G memory, movablecore=5G, but dmesg looks strange, what
happended to me?

 [0.00] Zone ranges:
 [0.00]   DMA  [mem 0x0001-0x00ff]
 [0.00]   Normal   [mem 0x0100-0x373fdfff]
 [0.00]   HighMem  [mem 0x373fe000-0xb6cf]
 [0.00] Movable zone start for each node
 [0.00]   Node 0: 0xb700
 [0.00] Early memory node ranges
 [0.00]   node   0: [mem 

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-11 Thread Jiang Liu
On 2012-12-11 19:28, Simon Jeons wrote:
 On Tue, 2012-12-11 at 11:32 +0800, Tang Chen wrote:
 On 12/11/2012 11:07 AM, Jianguo Wu wrote:
 On 2012/12/11 10:33, Tang Chen wrote:

 This patch introduces a new array zone_movable_limit[] to store the
 ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
 The function sanitize_zone_movable_limit() will find out to which
 node the ranges in movable_map.map[] belongs, and calculates the
 low boundary of ZONE_MOVABLE for each node.
 
 What's the difference between zone_movable_limit[nid] and
 zone_movable_pfn[nid]?
zone_movable_limit[] is a temporary storage for zone_moveable_pfn[].
It's used to handle a special case if user specifies both movablecore_map
and movablecore/kernelcore on the kernel command line. 

 

 Signed-off-by: Tang Chentangc...@cn.fujitsu.com
 Signed-off-by: Jiang Liujiang@huawei.com
 Reviewed-by: Wen Congyangwe...@cn.fujitsu.com
 Reviewed-by: Lai Jiangshanla...@cn.fujitsu.com
 Tested-by: Lin Fenglinf...@cn.fujitsu.com
 ---
   mm/page_alloc.c |   77 
 +++
   1 files changed, 77 insertions(+), 0 deletions(-)

 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
 index 1c91d16..4853619 100644
 --- a/mm/page_alloc.c
 +++ b/mm/page_alloc.c
 @@ -206,6 +206,7 @@ static unsigned long __meminitdata 
 arch_zone_highest_possible_pfn[MAX_NR_ZONES];
   static unsigned long __initdata required_kernelcore;
   static unsigned long __initdata required_movablecore;
   static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
 +static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];

   /* movable_zone is the real zone pages in ZONE_MOVABLE are taken from 
 */
   int movable_zone;
 @@ -4340,6 +4341,77 @@ static unsigned long __meminit 
 zone_absent_pages_in_node(int nid,
return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
   }

 +/**
 + * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
 + *
 + * zone_movable_limit is initialized as 0. This function will try to get
 + * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
 + * assigne them to zone_movable_limit.
 + * zone_movable_limit[nid] == 0 means no limit for the node.
 + *
 + * Note: Each range is represented as [start_pfn, end_pfn)
 + */
 +static void __meminit sanitize_zone_movable_limit(void)
 +{
 +  int map_pos = 0, i, nid;
 +  unsigned long start_pfn, end_pfn;
 +
 +  if (!movablecore_map.nr_map)
 +  return;
 +
 +  /* Iterate all ranges from minimum to maximum */
 +  for_each_mem_pfn_range(i, MAX_NUMNODES,start_pfn,end_pfn,nid) {
 +  /*
 +   * If we have found lowest pfn of ZONE_MOVABLE of the node
 +   * specified by user, just go on to check next range.
 +   */
 +  if (zone_movable_limit[nid])
 +  continue;
 +
 +#ifdef CONFIG_ZONE_DMA
 +  /* Skip DMA memory. */
 +  if (start_pfn  arch_zone_highest_possible_pfn[ZONE_DMA])
 +  start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA];
 +#endif
 +
 +#ifdef CONFIG_ZONE_DMA32
 +  /* Skip DMA32 memory. */
 +  if (start_pfn  arch_zone_highest_possible_pfn[ZONE_DMA32])
 +  start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA32];
 +#endif
 +
 +#ifdef CONFIG_HIGHMEM
 +  /* Skip lowmem if ZONE_MOVABLE is highmem. */
 +  if (zone_movable_is_highmem()

 Hi Tang,

 I think zone_movable_is_highmem() is not work correctly here.
 sanitize_zone_movable_limit
 zone_movable_is_highmem--using movable_zone here
 find_zone_movable_pfns_for_nodes
 find_usable_zone_for_movable--movable_zone is specified here

 I think Jiang Liu's patch works fine for highmem, please refer to:
 http://marc.info/?l=linux-mmm=135476085816087w=2

 Hi Wu,

 Yes, I forgot movable_zone think. Thanks for reminding me. :)

 But Liu's patch you just mentioned, I didn't use it because I
 don't think we should skip kernelcore when movablecore_map is specified.
 If these 2 options are not conflict, we should satisfy them both. :)

 Of course, I also think Liu's suggestion is wonderful. But I think we
 need more discussion on it. :)

 I'll fix it soon.
 Thanks. :)


 Thanks,
 Jianguo Wu

 +  start_pfn  arch_zone_lowest_possible_pfn[ZONE_HIGHMEM])
 +  start_pfn = arch_zone_lowest_possible_pfn[ZONE_HIGHMEM];
 +#endif
 +
 +  if (start_pfn= end_pfn)
 +  continue;
 +
 +  while (map_pos  movablecore_map.nr_map) {
 +  if (end_pfn= movablecore_map.map[map_pos].start_pfn)
 +  break;
 +
 +  if (start_pfn= movablecore_map.map[map_pos].end_pfn) {
 +  map_pos++;
 +  continue;
 +  }
 +
 +  /*
 +   * The start_pfn of ZONE_MOVABLE is either the minimum
 +   * pfn specified by movablecore_map, or 

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-11 Thread Jianguo Wu
On 2012/12/11 21:20, Simon Jeons wrote:

 On Tue, 2012-12-11 at 20:41 +0800, Jianguo Wu wrote:
 On 2012/12/11 20:24, Simon Jeons wrote:

 On Tue, 2012-12-11 at 11:07 +0800, Jianguo Wu wrote:
 On 2012/12/11 10:33, Tang Chen wrote:

 This patch introduces a new array zone_movable_limit[] to store the
 ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
 The function sanitize_zone_movable_limit() will find out to which
 node the ranges in movable_map.map[] belongs, and calculates the
 low boundary of ZONE_MOVABLE for each node.

 Signed-off-by: Tang Chen tangc...@cn.fujitsu.com
 Signed-off-by: Jiang Liu jiang@huawei.com
 Reviewed-by: Wen Congyang we...@cn.fujitsu.com
 Reviewed-by: Lai Jiangshan la...@cn.fujitsu.com
 Tested-by: Lin Feng linf...@cn.fujitsu.com
 ---
  mm/page_alloc.c |   77 
 +++
  1 files changed, 77 insertions(+), 0 deletions(-)

 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
 index 1c91d16..4853619 100644
 --- a/mm/page_alloc.c
 +++ b/mm/page_alloc.c
 @@ -206,6 +206,7 @@ static unsigned long __meminitdata 
 arch_zone_highest_possible_pfn[MAX_NR_ZONES];
  static unsigned long __initdata required_kernelcore;
  static unsigned long __initdata required_movablecore;
  static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
 +static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];
  
  /* movable_zone is the real zone pages in ZONE_MOVABLE are taken from 
 */
  int movable_zone;
 @@ -4340,6 +4341,77 @@ static unsigned long __meminit 
 zone_absent_pages_in_node(int nid,
   return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
  }
  
 +/**
 + * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
 + *
 + * zone_movable_limit is initialized as 0. This function will try to get
 + * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
 + * assigne them to zone_movable_limit.
 + * zone_movable_limit[nid] == 0 means no limit for the node.
 + *
 + * Note: Each range is represented as [start_pfn, end_pfn)
 + */
 +static void __meminit sanitize_zone_movable_limit(void)
 +{
 + int map_pos = 0, i, nid;
 + unsigned long start_pfn, end_pfn;
 +
 + if (!movablecore_map.nr_map)
 + return;
 +
 + /* Iterate all ranges from minimum to maximum */
 + for_each_mem_pfn_range(i, MAX_NUMNODES, start_pfn, end_pfn, nid) {
 + /*
 +  * If we have found lowest pfn of ZONE_MOVABLE of the node
 +  * specified by user, just go on to check next range.
 +  */
 + if (zone_movable_limit[nid])
 + continue;
 +
 +#ifdef CONFIG_ZONE_DMA
 + /* Skip DMA memory. */
 + if (start_pfn  arch_zone_highest_possible_pfn[ZONE_DMA])
 + start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA];
 +#endif
 +
 +#ifdef CONFIG_ZONE_DMA32
 + /* Skip DMA32 memory. */
 + if (start_pfn  arch_zone_highest_possible_pfn[ZONE_DMA32])
 + start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA32];
 +#endif
 +
 +#ifdef CONFIG_HIGHMEM
 + /* Skip lowmem if ZONE_MOVABLE is highmem. */
 + if (zone_movable_is_highmem() 

 Hi Tang,

 I think zone_movable_is_highmem() is not work correctly here.
sanitize_zone_movable_limit
zone_movable_is_highmem  --using movable_zone here
find_zone_movable_pfns_for_nodes
find_usable_zone_for_movable --movable_zone is specified here


 Hi Jiangguo and Chen,

 - What's the meaning of zone_movable_is_highmem(), does it mean all zone
 highmem pages are zone movable pages or 

 Hi Simon,

 zone_movable_is_highmem() means whether zone pages in ZONE_MOVABLE are taken 
 from
 highmem.

 - dmesg 

 0.00] Zone ranges:
 [0.00]   DMA  [mem 0x0001-0x00ff]
 [0.00]   Normal   [mem 0x0100-0x373fdfff]
 [0.00]   HighMem  [mem 0x373fe000-0xb6cf]
 [0.00] Movable zone start for each node
 [0.00]   Node 0: 0x9780

 Why the start of zone movable is in the range of zone highmem, if all
 the pages of zone movable are from zone highmem? If the answer is yes, 

 zone movable and zone highmem are in the equal status or not?

 The pages of zone_movable can be taken from zone_movalbe or zone_normal,
 if we have highmem, then zone_movable will be taken from zone_highmem,
 otherwise zone_movable will be taken from zone_normal.

 you can refer to find_usable_zone_for_movable().
 
 Hi Jiangguo,
 
 I have 8G memory, movablecore=5G, but dmesg looks strange, what
 happended to me?
 

Hi Simon,

I think you used 32bit kernel, and didn't enable CONFIG_X86_PAE, right?
So, it can only address memory below 4G.

Thanks,
Jianguo Wu

 [0.00] Zone ranges:
 [0.00]   DMA  [mem 0x0001-0x00ff]
 [0.00]   Normal   [mem 0x0100-0x373fdfff]
 [0.00]   HighMem  [mem 0x373fe000-0xb6cf]
 [0.00] Movable zone start for each node
 [0.00]   Node 0: 0xb700
 

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-11 Thread Lin Feng


On 12/11/2012 09:20 PM, Simon Jeons wrote:
 On Tue, 2012-12-11 at 20:41 +0800, Jianguo Wu wrote:
 On 2012/12/11 20:24, Simon Jeons wrote:

 On Tue, 2012-12-11 at 11:07 +0800, Jianguo Wu wrote:
 On 2012/12/11 10:33, Tang Chen wrote:

 This patch introduces a new array zone_movable_limit[] to store the
 ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
 The function sanitize_zone_movable_limit() will find out to which
 node the ranges in movable_map.map[] belongs, and calculates the
 low boundary of ZONE_MOVABLE for each node.

 Signed-off-by: Tang Chen tangc...@cn.fujitsu.com
 Signed-off-by: Jiang Liu jiang@huawei.com
 Reviewed-by: Wen Congyang we...@cn.fujitsu.com
 Reviewed-by: Lai Jiangshan la...@cn.fujitsu.com
 Tested-by: Lin Feng linf...@cn.fujitsu.com
 ---
  mm/page_alloc.c |   77 
 +++
  1 files changed, 77 insertions(+), 0 deletions(-)

 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
 index 1c91d16..4853619 100644
 --- a/mm/page_alloc.c
 +++ b/mm/page_alloc.c
 @@ -206,6 +206,7 @@ static unsigned long __meminitdata 
 arch_zone_highest_possible_pfn[MAX_NR_ZONES];
  static unsigned long __initdata required_kernelcore;
  static unsigned long __initdata required_movablecore;
  static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
 +static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];
  
  /* movable_zone is the real zone pages in ZONE_MOVABLE are taken from 
 */
  int movable_zone;
 @@ -4340,6 +4341,77 @@ static unsigned long __meminit 
 zone_absent_pages_in_node(int nid,
   return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
  }
  
 +/**
 + * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
 + *
 + * zone_movable_limit is initialized as 0. This function will try to get
 + * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
 + * assigne them to zone_movable_limit.
 + * zone_movable_limit[nid] == 0 means no limit for the node.
 + *
 + * Note: Each range is represented as [start_pfn, end_pfn)
 + */
 +static void __meminit sanitize_zone_movable_limit(void)
 +{
 + int map_pos = 0, i, nid;
 + unsigned long start_pfn, end_pfn;
 +
 + if (!movablecore_map.nr_map)
 + return;
 +
 + /* Iterate all ranges from minimum to maximum */
 + for_each_mem_pfn_range(i, MAX_NUMNODES, start_pfn, end_pfn, nid) {
 + /*
 +  * If we have found lowest pfn of ZONE_MOVABLE of the node
 +  * specified by user, just go on to check next range.
 +  */
 + if (zone_movable_limit[nid])
 + continue;
 +
 +#ifdef CONFIG_ZONE_DMA
 + /* Skip DMA memory. */
 + if (start_pfn  arch_zone_highest_possible_pfn[ZONE_DMA])
 + start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA];
 +#endif
 +
 +#ifdef CONFIG_ZONE_DMA32
 + /* Skip DMA32 memory. */
 + if (start_pfn  arch_zone_highest_possible_pfn[ZONE_DMA32])
 + start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA32];
 +#endif
 +
 +#ifdef CONFIG_HIGHMEM
 + /* Skip lowmem if ZONE_MOVABLE is highmem. */
 + if (zone_movable_is_highmem() 

 Hi Tang,

 I think zone_movable_is_highmem() is not work correctly here.
sanitize_zone_movable_limit
zone_movable_is_highmem  --using movable_zone here
find_zone_movable_pfns_for_nodes
find_usable_zone_for_movable --movable_zone is specified here


 Hi Jiangguo and Chen,

 - What's the meaning of zone_movable_is_highmem(), does it mean all zone
 highmem pages are zone movable pages or 

 Hi Simon,

 zone_movable_is_highmem() means whether zone pages in ZONE_MOVABLE are taken 
 from
 highmem.

 - dmesg 

 0.00] Zone ranges:
 [0.00]   DMA  [mem 0x0001-0x00ff]
 [0.00]   Normal   [mem 0x0100-0x373fdfff]
 [0.00]   HighMem  [mem 0x373fe000-0xb6cf]
 [0.00] Movable zone start for each node
 [0.00]   Node 0: 0x9780

 Why the start of zone movable is in the range of zone highmem, if all
 the pages of zone movable are from zone highmem? If the answer is yes, 

 zone movable and zone highmem are in the equal status or not?

 The pages of zone_movable can be taken from zone_movalbe or zone_normal,
 if we have highmem, then zone_movable will be taken from zone_highmem,
 otherwise zone_movable will be taken from zone_normal.

 you can refer to find_usable_zone_for_movable().
 
 Hi Jiangguo,
 
 I have 8G memory, movablecore=5G, but dmesg looks strange, what
 happended to me?
Hi Simon,

Is there any other boot parameters for memory taken besides 'movablecore=5G'?

thanks,
linfeng
 
 [0.00] Zone ranges:
 [0.00]   DMA  [mem 0x0001-0x00ff]
 [0.00]   Normal   [mem 0x0100-0x373fdfff]
 [0.00]   HighMem  [mem 0x373fe000-0xb6cf]
 [0.00] Movable zone start for each node
 [0.00]   Node 0: 0xb700
 [0.00] Early memory node 

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-11 Thread Simon Jeons
On Wed, 2012-12-12 at 09:57 +0800, Jianguo Wu wrote:
 On 2012/12/11 21:20, Simon Jeons wrote:
 
  On Tue, 2012-12-11 at 20:41 +0800, Jianguo Wu wrote:
  On 2012/12/11 20:24, Simon Jeons wrote:
 
  On Tue, 2012-12-11 at 11:07 +0800, Jianguo Wu wrote:
  On 2012/12/11 10:33, Tang Chen wrote:
 
  This patch introduces a new array zone_movable_limit[] to store the
  ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
  The function sanitize_zone_movable_limit() will find out to which
  node the ranges in movable_map.map[] belongs, and calculates the
  low boundary of ZONE_MOVABLE for each node.
 
  Signed-off-by: Tang Chen tangc...@cn.fujitsu.com
  Signed-off-by: Jiang Liu jiang@huawei.com
  Reviewed-by: Wen Congyang we...@cn.fujitsu.com
  Reviewed-by: Lai Jiangshan la...@cn.fujitsu.com
  Tested-by: Lin Feng linf...@cn.fujitsu.com
  ---
   mm/page_alloc.c |   77 
  +++
   1 files changed, 77 insertions(+), 0 deletions(-)
 
  diff --git a/mm/page_alloc.c b/mm/page_alloc.c
  index 1c91d16..4853619 100644
  --- a/mm/page_alloc.c
  +++ b/mm/page_alloc.c
  @@ -206,6 +206,7 @@ static unsigned long __meminitdata 
  arch_zone_highest_possible_pfn[MAX_NR_ZONES];
   static unsigned long __initdata required_kernelcore;
   static unsigned long __initdata required_movablecore;
   static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
  +static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];
   
   /* movable_zone is the real zone pages in ZONE_MOVABLE are taken 
  from */
   int movable_zone;
  @@ -4340,6 +4341,77 @@ static unsigned long __meminit 
  zone_absent_pages_in_node(int nid,
  return __absent_pages_in_range(nid, zone_start_pfn, 
  zone_end_pfn);
   }
   
  +/**
  + * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
  + *
  + * zone_movable_limit is initialized as 0. This function will try to 
  get
  + * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
  + * assigne them to zone_movable_limit.
  + * zone_movable_limit[nid] == 0 means no limit for the node.
  + *
  + * Note: Each range is represented as [start_pfn, end_pfn)
  + */
  +static void __meminit sanitize_zone_movable_limit(void)
  +{
  +   int map_pos = 0, i, nid;
  +   unsigned long start_pfn, end_pfn;
  +
  +   if (!movablecore_map.nr_map)
  +   return;
  +
  +   /* Iterate all ranges from minimum to maximum */
  +   for_each_mem_pfn_range(i, MAX_NUMNODES, start_pfn, end_pfn, 
  nid) {
  +   /*
  +* If we have found lowest pfn of ZONE_MOVABLE of the 
  node
  +* specified by user, just go on to check next range.
  +*/
  +   if (zone_movable_limit[nid])
  +   continue;
  +
  +#ifdef CONFIG_ZONE_DMA
  +   /* Skip DMA memory. */
  +   if (start_pfn  
  arch_zone_highest_possible_pfn[ZONE_DMA])
  +   start_pfn = 
  arch_zone_highest_possible_pfn[ZONE_DMA];
  +#endif
  +
  +#ifdef CONFIG_ZONE_DMA32
  +   /* Skip DMA32 memory. */
  +   if (start_pfn  
  arch_zone_highest_possible_pfn[ZONE_DMA32])
  +   start_pfn = 
  arch_zone_highest_possible_pfn[ZONE_DMA32];
  +#endif
  +
  +#ifdef CONFIG_HIGHMEM
  +   /* Skip lowmem if ZONE_MOVABLE is highmem. */
  +   if (zone_movable_is_highmem() 
 
  Hi Tang,
 
  I think zone_movable_is_highmem() is not work correctly here.
   sanitize_zone_movable_limit
   zone_movable_is_highmem  --using movable_zone here
   find_zone_movable_pfns_for_nodes
   find_usable_zone_for_movable --movable_zone is specified here
 
 
  Hi Jiangguo and Chen,
 
  - What's the meaning of zone_movable_is_highmem(), does it mean all zone
  highmem pages are zone movable pages or 
 
  Hi Simon,
 
  zone_movable_is_highmem() means whether zone pages in ZONE_MOVABLE are 
  taken from
  highmem.
 
  - dmesg 
 
  0.00] Zone ranges:
  [0.00]   DMA  [mem 0x0001-0x00ff]
  [0.00]   Normal   [mem 0x0100-0x373fdfff]
  [0.00]   HighMem  [mem 0x373fe000-0xb6cf]
  [0.00] Movable zone start for each node
  [0.00]   Node 0: 0x9780
 
  Why the start of zone movable is in the range of zone highmem, if all
  the pages of zone movable are from zone highmem? If the answer is yes, 
 
  zone movable and zone highmem are in the equal status or not?
 
  The pages of zone_movable can be taken from zone_movalbe or zone_normal,
  if we have highmem, then zone_movable will be taken from zone_highmem,
  otherwise zone_movable will be taken from zone_normal.
 
  you can refer to find_usable_zone_for_movable().
  
  Hi Jiangguo,
  
  I have 8G memory, movablecore=5G, but dmesg looks strange, what
  happended to me?
  
 
 Hi Simon,
 
 I think you used 32bit kernel, and didn't enable CONFIG_X86_PAE, right?
 So, it can 

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-10 Thread Tang Chen

On 12/11/2012 11:07 AM, Jianguo Wu wrote:

On 2012/12/11 10:33, Tang Chen wrote:


This patch introduces a new array zone_movable_limit[] to store the
ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
The function sanitize_zone_movable_limit() will find out to which
node the ranges in movable_map.map[] belongs, and calculates the
low boundary of ZONE_MOVABLE for each node.

Signed-off-by: Tang Chen
Signed-off-by: Jiang Liu
Reviewed-by: Wen Congyang
Reviewed-by: Lai Jiangshan
Tested-by: Lin Feng
---
  mm/page_alloc.c |   77 +++
  1 files changed, 77 insertions(+), 0 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 1c91d16..4853619 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -206,6 +206,7 @@ static unsigned long __meminitdata 
arch_zone_highest_possible_pfn[MAX_NR_ZONES];
  static unsigned long __initdata required_kernelcore;
  static unsigned long __initdata required_movablecore;
  static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
+static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];

  /* movable_zone is the "real" zone pages in ZONE_MOVABLE are taken from */
  int movable_zone;
@@ -4340,6 +4341,77 @@ static unsigned long __meminit 
zone_absent_pages_in_node(int nid,
return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
  }

+/**
+ * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
+ *
+ * zone_movable_limit is initialized as 0. This function will try to get
+ * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
+ * assigne them to zone_movable_limit.
+ * zone_movable_limit[nid] == 0 means no limit for the node.
+ *
+ * Note: Each range is represented as [start_pfn, end_pfn)
+ */
+static void __meminit sanitize_zone_movable_limit(void)
+{
+   int map_pos = 0, i, nid;
+   unsigned long start_pfn, end_pfn;
+
+   if (!movablecore_map.nr_map)
+   return;
+
+   /* Iterate all ranges from minimum to maximum */
+   for_each_mem_pfn_range(i, MAX_NUMNODES,_pfn,_pfn,) {
+   /*
+* If we have found lowest pfn of ZONE_MOVABLE of the node
+* specified by user, just go on to check next range.
+*/
+   if (zone_movable_limit[nid])
+   continue;
+
+#ifdef CONFIG_ZONE_DMA
+   /* Skip DMA memory. */
+   if (start_pfn<  arch_zone_highest_possible_pfn[ZONE_DMA])
+   start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA];
+#endif
+
+#ifdef CONFIG_ZONE_DMA32
+   /* Skip DMA32 memory. */
+   if (start_pfn<  arch_zone_highest_possible_pfn[ZONE_DMA32])
+   start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA32];
+#endif
+
+#ifdef CONFIG_HIGHMEM
+   /* Skip lowmem if ZONE_MOVABLE is highmem. */
+   if (zone_movable_is_highmem()&&


Hi Tang,

I think zone_movable_is_highmem() is not work correctly here.
sanitize_zone_movable_limit
zone_movable_is_highmem<--using movable_zone here
find_zone_movable_pfns_for_nodes
find_usable_zone_for_movable<--movable_zone is specified here

I think Jiang Liu's patch works fine for highmem, please refer to:
http://marc.info/?l=linux-mm=135476085816087=2


Hi Wu,

Yes, I forgot movable_zone think. Thanks for reminding me. :)

But Liu's patch you just mentioned, I didn't use it because I
don't think we should skip kernelcore when movablecore_map is specified.
If these 2 options are not conflict, we should satisfy them both. :)

Of course, I also think Liu's suggestion is wonderful. But I think we
need more discussion on it. :)

I'll fix it soon.
Thanks. :)



Thanks,
Jianguo Wu


+   start_pfn<  arch_zone_lowest_possible_pfn[ZONE_HIGHMEM])
+   start_pfn = arch_zone_lowest_possible_pfn[ZONE_HIGHMEM];
+#endif
+
+   if (start_pfn>= end_pfn)
+   continue;
+
+   while (map_pos<  movablecore_map.nr_map) {
+   if (end_pfn<= movablecore_map.map[map_pos].start_pfn)
+   break;
+
+   if (start_pfn>= movablecore_map.map[map_pos].end_pfn) {
+   map_pos++;
+   continue;
+   }
+
+   /*
+* The start_pfn of ZONE_MOVABLE is either the minimum
+* pfn specified by movablecore_map, or 0, which means
+* the node has no ZONE_MOVABLE.
+*/
+   zone_movable_limit[nid] = max(start_pfn,
+   movablecore_map.map[map_pos].start_pfn);
+
+   break;
+   }
+   }
+}
+
  #else /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
  static inline unsigned long __meminit 

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-10 Thread Jianguo Wu
On 2012/12/11 10:33, Tang Chen wrote:

> This patch introduces a new array zone_movable_limit[] to store the
> ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
> The function sanitize_zone_movable_limit() will find out to which
> node the ranges in movable_map.map[] belongs, and calculates the
> low boundary of ZONE_MOVABLE for each node.
> 
> Signed-off-by: Tang Chen 
> Signed-off-by: Jiang Liu 
> Reviewed-by: Wen Congyang 
> Reviewed-by: Lai Jiangshan 
> Tested-by: Lin Feng 
> ---
>  mm/page_alloc.c |   77 
> +++
>  1 files changed, 77 insertions(+), 0 deletions(-)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 1c91d16..4853619 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -206,6 +206,7 @@ static unsigned long __meminitdata 
> arch_zone_highest_possible_pfn[MAX_NR_ZONES];
>  static unsigned long __initdata required_kernelcore;
>  static unsigned long __initdata required_movablecore;
>  static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
> +static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];
>  
>  /* movable_zone is the "real" zone pages in ZONE_MOVABLE are taken from */
>  int movable_zone;
> @@ -4340,6 +4341,77 @@ static unsigned long __meminit 
> zone_absent_pages_in_node(int nid,
>   return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
>  }
>  
> +/**
> + * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
> + *
> + * zone_movable_limit is initialized as 0. This function will try to get
> + * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
> + * assigne them to zone_movable_limit.
> + * zone_movable_limit[nid] == 0 means no limit for the node.
> + *
> + * Note: Each range is represented as [start_pfn, end_pfn)
> + */
> +static void __meminit sanitize_zone_movable_limit(void)
> +{
> + int map_pos = 0, i, nid;
> + unsigned long start_pfn, end_pfn;
> +
> + if (!movablecore_map.nr_map)
> + return;
> +
> + /* Iterate all ranges from minimum to maximum */
> + for_each_mem_pfn_range(i, MAX_NUMNODES, _pfn, _pfn, ) {
> + /*
> +  * If we have found lowest pfn of ZONE_MOVABLE of the node
> +  * specified by user, just go on to check next range.
> +  */
> + if (zone_movable_limit[nid])
> + continue;
> +
> +#ifdef CONFIG_ZONE_DMA
> + /* Skip DMA memory. */
> + if (start_pfn < arch_zone_highest_possible_pfn[ZONE_DMA])
> + start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA];
> +#endif
> +
> +#ifdef CONFIG_ZONE_DMA32
> + /* Skip DMA32 memory. */
> + if (start_pfn < arch_zone_highest_possible_pfn[ZONE_DMA32])
> + start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA32];
> +#endif
> +
> +#ifdef CONFIG_HIGHMEM
> + /* Skip lowmem if ZONE_MOVABLE is highmem. */
> + if (zone_movable_is_highmem() &&

Hi Tang,

I think zone_movable_is_highmem() is not work correctly here.
sanitize_zone_movable_limit
zone_movable_is_highmem  <--using movable_zone here
find_zone_movable_pfns_for_nodes
find_usable_zone_for_movable <--movable_zone is specified here

I think Jiang Liu's patch works fine for highmem, please refer to:
http://marc.info/?l=linux-mm=135476085816087=2

Thanks,
Jianguo Wu

> + start_pfn < arch_zone_lowest_possible_pfn[ZONE_HIGHMEM])
> + start_pfn = arch_zone_lowest_possible_pfn[ZONE_HIGHMEM];
> +#endif
> +
> + if (start_pfn >= end_pfn)
> + continue;
> +
> + while (map_pos < movablecore_map.nr_map) {
> + if (end_pfn <= movablecore_map.map[map_pos].start_pfn)
> + break;
> +
> + if (start_pfn >= movablecore_map.map[map_pos].end_pfn) {
> + map_pos++;
> + continue;
> + }
> +
> + /*
> +  * The start_pfn of ZONE_MOVABLE is either the minimum
> +  * pfn specified by movablecore_map, or 0, which means
> +  * the node has no ZONE_MOVABLE.
> +  */
> + zone_movable_limit[nid] = max(start_pfn,
> + movablecore_map.map[map_pos].start_pfn);
> +
> + break;
> + }
> + }
> +}
> +
>  #else /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
>  static inline unsigned long __meminit zone_spanned_pages_in_node(int nid,
>   unsigned long zone_type,
> @@ -4358,6 +4430,10 @@ static inline unsigned long __meminit 
> zone_absent_pages_in_node(int nid,
>   return zholes_size[zone_type];
>  }
>  
> +static void __meminit sanitize_zone_movable_limit(void)
> +{
> +}
> 

[PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-10 Thread Tang Chen
This patch introduces a new array zone_movable_limit[] to store the
ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
The function sanitize_zone_movable_limit() will find out to which
node the ranges in movable_map.map[] belongs, and calculates the
low boundary of ZONE_MOVABLE for each node.

Signed-off-by: Tang Chen 
Signed-off-by: Jiang Liu 
Reviewed-by: Wen Congyang 
Reviewed-by: Lai Jiangshan 
Tested-by: Lin Feng 
---
 mm/page_alloc.c |   77 +++
 1 files changed, 77 insertions(+), 0 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 1c91d16..4853619 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -206,6 +206,7 @@ static unsigned long __meminitdata 
arch_zone_highest_possible_pfn[MAX_NR_ZONES];
 static unsigned long __initdata required_kernelcore;
 static unsigned long __initdata required_movablecore;
 static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
+static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];
 
 /* movable_zone is the "real" zone pages in ZONE_MOVABLE are taken from */
 int movable_zone;
@@ -4340,6 +4341,77 @@ static unsigned long __meminit 
zone_absent_pages_in_node(int nid,
return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
 }
 
+/**
+ * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
+ *
+ * zone_movable_limit is initialized as 0. This function will try to get
+ * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
+ * assigne them to zone_movable_limit.
+ * zone_movable_limit[nid] == 0 means no limit for the node.
+ *
+ * Note: Each range is represented as [start_pfn, end_pfn)
+ */
+static void __meminit sanitize_zone_movable_limit(void)
+{
+   int map_pos = 0, i, nid;
+   unsigned long start_pfn, end_pfn;
+
+   if (!movablecore_map.nr_map)
+   return;
+
+   /* Iterate all ranges from minimum to maximum */
+   for_each_mem_pfn_range(i, MAX_NUMNODES, _pfn, _pfn, ) {
+   /*
+* If we have found lowest pfn of ZONE_MOVABLE of the node
+* specified by user, just go on to check next range.
+*/
+   if (zone_movable_limit[nid])
+   continue;
+
+#ifdef CONFIG_ZONE_DMA
+   /* Skip DMA memory. */
+   if (start_pfn < arch_zone_highest_possible_pfn[ZONE_DMA])
+   start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA];
+#endif
+
+#ifdef CONFIG_ZONE_DMA32
+   /* Skip DMA32 memory. */
+   if (start_pfn < arch_zone_highest_possible_pfn[ZONE_DMA32])
+   start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA32];
+#endif
+
+#ifdef CONFIG_HIGHMEM
+   /* Skip lowmem if ZONE_MOVABLE is highmem. */
+   if (zone_movable_is_highmem() &&
+   start_pfn < arch_zone_lowest_possible_pfn[ZONE_HIGHMEM])
+   start_pfn = arch_zone_lowest_possible_pfn[ZONE_HIGHMEM];
+#endif
+
+   if (start_pfn >= end_pfn)
+   continue;
+
+   while (map_pos < movablecore_map.nr_map) {
+   if (end_pfn <= movablecore_map.map[map_pos].start_pfn)
+   break;
+
+   if (start_pfn >= movablecore_map.map[map_pos].end_pfn) {
+   map_pos++;
+   continue;
+   }
+
+   /*
+* The start_pfn of ZONE_MOVABLE is either the minimum
+* pfn specified by movablecore_map, or 0, which means
+* the node has no ZONE_MOVABLE.
+*/
+   zone_movable_limit[nid] = max(start_pfn,
+   movablecore_map.map[map_pos].start_pfn);
+
+   break;
+   }
+   }
+}
+
 #else /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
 static inline unsigned long __meminit zone_spanned_pages_in_node(int nid,
unsigned long zone_type,
@@ -4358,6 +4430,10 @@ static inline unsigned long __meminit 
zone_absent_pages_in_node(int nid,
return zholes_size[zone_type];
 }
 
+static void __meminit sanitize_zone_movable_limit(void)
+{
+}
+
 #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
 
 static void __meminit calculate_node_totalpages(struct pglist_data *pgdat,
@@ -4923,6 +4999,7 @@ void __init free_area_init_nodes(unsigned long 
*max_zone_pfn)
 
/* Find the PFNs that ZONE_MOVABLE begins at in each node */
memset(zone_movable_pfn, 0, sizeof(zone_movable_pfn));
+   sanitize_zone_movable_limit();
find_zone_movable_pfns_for_nodes();
 
/* Print out the zone ranges */
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo 

[PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-10 Thread Tang Chen
This patch introduces a new array zone_movable_limit[] to store the
ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
The function sanitize_zone_movable_limit() will find out to which
node the ranges in movable_map.map[] belongs, and calculates the
low boundary of ZONE_MOVABLE for each node.

Signed-off-by: Tang Chen tangc...@cn.fujitsu.com
Signed-off-by: Jiang Liu jiang@huawei.com
Reviewed-by: Wen Congyang we...@cn.fujitsu.com
Reviewed-by: Lai Jiangshan la...@cn.fujitsu.com
Tested-by: Lin Feng linf...@cn.fujitsu.com
---
 mm/page_alloc.c |   77 +++
 1 files changed, 77 insertions(+), 0 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 1c91d16..4853619 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -206,6 +206,7 @@ static unsigned long __meminitdata 
arch_zone_highest_possible_pfn[MAX_NR_ZONES];
 static unsigned long __initdata required_kernelcore;
 static unsigned long __initdata required_movablecore;
 static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
+static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];
 
 /* movable_zone is the real zone pages in ZONE_MOVABLE are taken from */
 int movable_zone;
@@ -4340,6 +4341,77 @@ static unsigned long __meminit 
zone_absent_pages_in_node(int nid,
return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
 }
 
+/**
+ * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
+ *
+ * zone_movable_limit is initialized as 0. This function will try to get
+ * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
+ * assigne them to zone_movable_limit.
+ * zone_movable_limit[nid] == 0 means no limit for the node.
+ *
+ * Note: Each range is represented as [start_pfn, end_pfn)
+ */
+static void __meminit sanitize_zone_movable_limit(void)
+{
+   int map_pos = 0, i, nid;
+   unsigned long start_pfn, end_pfn;
+
+   if (!movablecore_map.nr_map)
+   return;
+
+   /* Iterate all ranges from minimum to maximum */
+   for_each_mem_pfn_range(i, MAX_NUMNODES, start_pfn, end_pfn, nid) {
+   /*
+* If we have found lowest pfn of ZONE_MOVABLE of the node
+* specified by user, just go on to check next range.
+*/
+   if (zone_movable_limit[nid])
+   continue;
+
+#ifdef CONFIG_ZONE_DMA
+   /* Skip DMA memory. */
+   if (start_pfn  arch_zone_highest_possible_pfn[ZONE_DMA])
+   start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA];
+#endif
+
+#ifdef CONFIG_ZONE_DMA32
+   /* Skip DMA32 memory. */
+   if (start_pfn  arch_zone_highest_possible_pfn[ZONE_DMA32])
+   start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA32];
+#endif
+
+#ifdef CONFIG_HIGHMEM
+   /* Skip lowmem if ZONE_MOVABLE is highmem. */
+   if (zone_movable_is_highmem() 
+   start_pfn  arch_zone_lowest_possible_pfn[ZONE_HIGHMEM])
+   start_pfn = arch_zone_lowest_possible_pfn[ZONE_HIGHMEM];
+#endif
+
+   if (start_pfn = end_pfn)
+   continue;
+
+   while (map_pos  movablecore_map.nr_map) {
+   if (end_pfn = movablecore_map.map[map_pos].start_pfn)
+   break;
+
+   if (start_pfn = movablecore_map.map[map_pos].end_pfn) {
+   map_pos++;
+   continue;
+   }
+
+   /*
+* The start_pfn of ZONE_MOVABLE is either the minimum
+* pfn specified by movablecore_map, or 0, which means
+* the node has no ZONE_MOVABLE.
+*/
+   zone_movable_limit[nid] = max(start_pfn,
+   movablecore_map.map[map_pos].start_pfn);
+
+   break;
+   }
+   }
+}
+
 #else /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
 static inline unsigned long __meminit zone_spanned_pages_in_node(int nid,
unsigned long zone_type,
@@ -4358,6 +4430,10 @@ static inline unsigned long __meminit 
zone_absent_pages_in_node(int nid,
return zholes_size[zone_type];
 }
 
+static void __meminit sanitize_zone_movable_limit(void)
+{
+}
+
 #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
 
 static void __meminit calculate_node_totalpages(struct pglist_data *pgdat,
@@ -4923,6 +4999,7 @@ void __init free_area_init_nodes(unsigned long 
*max_zone_pfn)
 
/* Find the PFNs that ZONE_MOVABLE begins at in each node */
memset(zone_movable_pfn, 0, sizeof(zone_movable_pfn));
+   sanitize_zone_movable_limit();
find_zone_movable_pfns_for_nodes();
 
/* Print out the zone ranges */
-- 
1.7.1

--
To unsubscribe from this list: send 

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-10 Thread Jianguo Wu
On 2012/12/11 10:33, Tang Chen wrote:

 This patch introduces a new array zone_movable_limit[] to store the
 ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
 The function sanitize_zone_movable_limit() will find out to which
 node the ranges in movable_map.map[] belongs, and calculates the
 low boundary of ZONE_MOVABLE for each node.
 
 Signed-off-by: Tang Chen tangc...@cn.fujitsu.com
 Signed-off-by: Jiang Liu jiang@huawei.com
 Reviewed-by: Wen Congyang we...@cn.fujitsu.com
 Reviewed-by: Lai Jiangshan la...@cn.fujitsu.com
 Tested-by: Lin Feng linf...@cn.fujitsu.com
 ---
  mm/page_alloc.c |   77 
 +++
  1 files changed, 77 insertions(+), 0 deletions(-)
 
 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
 index 1c91d16..4853619 100644
 --- a/mm/page_alloc.c
 +++ b/mm/page_alloc.c
 @@ -206,6 +206,7 @@ static unsigned long __meminitdata 
 arch_zone_highest_possible_pfn[MAX_NR_ZONES];
  static unsigned long __initdata required_kernelcore;
  static unsigned long __initdata required_movablecore;
  static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
 +static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];
  
  /* movable_zone is the real zone pages in ZONE_MOVABLE are taken from */
  int movable_zone;
 @@ -4340,6 +4341,77 @@ static unsigned long __meminit 
 zone_absent_pages_in_node(int nid,
   return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
  }
  
 +/**
 + * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
 + *
 + * zone_movable_limit is initialized as 0. This function will try to get
 + * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
 + * assigne them to zone_movable_limit.
 + * zone_movable_limit[nid] == 0 means no limit for the node.
 + *
 + * Note: Each range is represented as [start_pfn, end_pfn)
 + */
 +static void __meminit sanitize_zone_movable_limit(void)
 +{
 + int map_pos = 0, i, nid;
 + unsigned long start_pfn, end_pfn;
 +
 + if (!movablecore_map.nr_map)
 + return;
 +
 + /* Iterate all ranges from minimum to maximum */
 + for_each_mem_pfn_range(i, MAX_NUMNODES, start_pfn, end_pfn, nid) {
 + /*
 +  * If we have found lowest pfn of ZONE_MOVABLE of the node
 +  * specified by user, just go on to check next range.
 +  */
 + if (zone_movable_limit[nid])
 + continue;
 +
 +#ifdef CONFIG_ZONE_DMA
 + /* Skip DMA memory. */
 + if (start_pfn  arch_zone_highest_possible_pfn[ZONE_DMA])
 + start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA];
 +#endif
 +
 +#ifdef CONFIG_ZONE_DMA32
 + /* Skip DMA32 memory. */
 + if (start_pfn  arch_zone_highest_possible_pfn[ZONE_DMA32])
 + start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA32];
 +#endif
 +
 +#ifdef CONFIG_HIGHMEM
 + /* Skip lowmem if ZONE_MOVABLE is highmem. */
 + if (zone_movable_is_highmem() 

Hi Tang,

I think zone_movable_is_highmem() is not work correctly here.
sanitize_zone_movable_limit
zone_movable_is_highmem  --using movable_zone here
find_zone_movable_pfns_for_nodes
find_usable_zone_for_movable --movable_zone is specified here

I think Jiang Liu's patch works fine for highmem, please refer to:
http://marc.info/?l=linux-mmm=135476085816087w=2

Thanks,
Jianguo Wu

 + start_pfn  arch_zone_lowest_possible_pfn[ZONE_HIGHMEM])
 + start_pfn = arch_zone_lowest_possible_pfn[ZONE_HIGHMEM];
 +#endif
 +
 + if (start_pfn = end_pfn)
 + continue;
 +
 + while (map_pos  movablecore_map.nr_map) {
 + if (end_pfn = movablecore_map.map[map_pos].start_pfn)
 + break;
 +
 + if (start_pfn = movablecore_map.map[map_pos].end_pfn) {
 + map_pos++;
 + continue;
 + }
 +
 + /*
 +  * The start_pfn of ZONE_MOVABLE is either the minimum
 +  * pfn specified by movablecore_map, or 0, which means
 +  * the node has no ZONE_MOVABLE.
 +  */
 + zone_movable_limit[nid] = max(start_pfn,
 + movablecore_map.map[map_pos].start_pfn);
 +
 + break;
 + }
 + }
 +}
 +
  #else /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
  static inline unsigned long __meminit zone_spanned_pages_in_node(int nid,
   unsigned long zone_type,
 @@ -4358,6 +4430,10 @@ static inline unsigned long __meminit 
 zone_absent_pages_in_node(int nid,
   return zholes_size[zone_type];
  }
  
 +static void __meminit sanitize_zone_movable_limit(void)
 +{
 +}
 +
  #endif 

Re: [PATCH v3 3/5] page_alloc: Introduce zone_movable_limit[] to keep movable limit for nodes

2012-12-10 Thread Tang Chen

On 12/11/2012 11:07 AM, Jianguo Wu wrote:

On 2012/12/11 10:33, Tang Chen wrote:


This patch introduces a new array zone_movable_limit[] to store the
ZONE_MOVABLE limit from movablecore_map boot option for all nodes.
The function sanitize_zone_movable_limit() will find out to which
node the ranges in movable_map.map[] belongs, and calculates the
low boundary of ZONE_MOVABLE for each node.

Signed-off-by: Tang Chentangc...@cn.fujitsu.com
Signed-off-by: Jiang Liujiang@huawei.com
Reviewed-by: Wen Congyangwe...@cn.fujitsu.com
Reviewed-by: Lai Jiangshanla...@cn.fujitsu.com
Tested-by: Lin Fenglinf...@cn.fujitsu.com
---
  mm/page_alloc.c |   77 +++
  1 files changed, 77 insertions(+), 0 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 1c91d16..4853619 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -206,6 +206,7 @@ static unsigned long __meminitdata 
arch_zone_highest_possible_pfn[MAX_NR_ZONES];
  static unsigned long __initdata required_kernelcore;
  static unsigned long __initdata required_movablecore;
  static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
+static unsigned long __meminitdata zone_movable_limit[MAX_NUMNODES];

  /* movable_zone is the real zone pages in ZONE_MOVABLE are taken from */
  int movable_zone;
@@ -4340,6 +4341,77 @@ static unsigned long __meminit 
zone_absent_pages_in_node(int nid,
return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
  }

+/**
+ * sanitize_zone_movable_limit - Sanitize the zone_movable_limit array.
+ *
+ * zone_movable_limit is initialized as 0. This function will try to get
+ * the first ZONE_MOVABLE pfn of each node from movablecore_map, and
+ * assigne them to zone_movable_limit.
+ * zone_movable_limit[nid] == 0 means no limit for the node.
+ *
+ * Note: Each range is represented as [start_pfn, end_pfn)
+ */
+static void __meminit sanitize_zone_movable_limit(void)
+{
+   int map_pos = 0, i, nid;
+   unsigned long start_pfn, end_pfn;
+
+   if (!movablecore_map.nr_map)
+   return;
+
+   /* Iterate all ranges from minimum to maximum */
+   for_each_mem_pfn_range(i, MAX_NUMNODES,start_pfn,end_pfn,nid) {
+   /*
+* If we have found lowest pfn of ZONE_MOVABLE of the node
+* specified by user, just go on to check next range.
+*/
+   if (zone_movable_limit[nid])
+   continue;
+
+#ifdef CONFIG_ZONE_DMA
+   /* Skip DMA memory. */
+   if (start_pfn  arch_zone_highest_possible_pfn[ZONE_DMA])
+   start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA];
+#endif
+
+#ifdef CONFIG_ZONE_DMA32
+   /* Skip DMA32 memory. */
+   if (start_pfn  arch_zone_highest_possible_pfn[ZONE_DMA32])
+   start_pfn = arch_zone_highest_possible_pfn[ZONE_DMA32];
+#endif
+
+#ifdef CONFIG_HIGHMEM
+   /* Skip lowmem if ZONE_MOVABLE is highmem. */
+   if (zone_movable_is_highmem()


Hi Tang,

I think zone_movable_is_highmem() is not work correctly here.
sanitize_zone_movable_limit
zone_movable_is_highmem--using movable_zone here
find_zone_movable_pfns_for_nodes
find_usable_zone_for_movable--movable_zone is specified here

I think Jiang Liu's patch works fine for highmem, please refer to:
http://marc.info/?l=linux-mmm=135476085816087w=2


Hi Wu,

Yes, I forgot movable_zone think. Thanks for reminding me. :)

But Liu's patch you just mentioned, I didn't use it because I
don't think we should skip kernelcore when movablecore_map is specified.
If these 2 options are not conflict, we should satisfy them both. :)

Of course, I also think Liu's suggestion is wonderful. But I think we
need more discussion on it. :)

I'll fix it soon.
Thanks. :)



Thanks,
Jianguo Wu


+   start_pfn  arch_zone_lowest_possible_pfn[ZONE_HIGHMEM])
+   start_pfn = arch_zone_lowest_possible_pfn[ZONE_HIGHMEM];
+#endif
+
+   if (start_pfn= end_pfn)
+   continue;
+
+   while (map_pos  movablecore_map.nr_map) {
+   if (end_pfn= movablecore_map.map[map_pos].start_pfn)
+   break;
+
+   if (start_pfn= movablecore_map.map[map_pos].end_pfn) {
+   map_pos++;
+   continue;
+   }
+
+   /*
+* The start_pfn of ZONE_MOVABLE is either the minimum
+* pfn specified by movablecore_map, or 0, which means
+* the node has no ZONE_MOVABLE.
+*/
+   zone_movable_limit[nid] = max(start_pfn,
+   movablecore_map.map[map_pos].start_pfn);
+
+   break;
+   }