Making Removable zone[0/4]
Subsystems (4)
Hello.
This patch set is to make new zone (Hotremovable) for memory hotplug to create area which is removed relatively easily. I made this patch set 2 month ago,
but I thought this patch set has many problem,
so I was worried whether it should be posted for a long time.
However I'm feeling its time become too long.
So, I post this to ask which is better way.
If you have any suggestions, please tell me.
This patches make Hotremovable attribute as orthogonal against DMA/Normal/Highmem. So, there will be six zones (DMA/Normal/Highmem/ Removable DMA/ Removable Normal/
Removable Highmem).
However, this orthogonal attribute is cause of problems like followings....
1) Zone Id bits in page->flags must be extended from 2 to 3 to make 6 zones. However, there is not enough space in it.
2) Array size of zonelist for 6 zones might be too big. (Especially, when there are a lot of numbers of nodes)
3) Index of zonelist array is decided by __GFP_xxx bit. So, index must be power of 2. But, GFP_Removable can be set with GFP_HIGHMEM or GFP_DMA. (not power of 2).
4) Some of kernel codes assume that order of Zone's index is DMA -> Normal -> Highmem.
But removable attribute will break its order.
5) Zonelist order must be also changed.
Which is better zonelist order?
a) Removable Highmem -> Removable Normal -> Removable DMA
-> Highmem -> Normal -> DMA
b) Removable Highmem -> Highmem -> Removable Normal -> Normal
-> Removable DMA -> DMAIf the kind of zone is just 4 types like DMA/Normal/Highmem/Removable (Not orthogonal), some of these problems become easy.
And I suppose 4) and 5) imply more codes like mem_molicy must be changed.
But 6 zones code has an advantage for hotplug of kernel memory. If an component of kernel can become hot-removable, probably it would like to use "Horemovable DMA" or "Hotremovable Normal".
So, I also worried which type of removable zone is better.
These patch set is old, but they can be applied against 2.6.9-mm1. Please comment.
Bye.
Signature · 8 lines
Yasunori Goto <ygoto at us.fujitsu.com> -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
[RFC/Patch]Making Removable zone[1/4]
This patch makes new zones (Hot-removable DMA/ Hotremovable-Normal/ Hotremovable-Highmem).
hotremovable-goto/include/linux/mmzone.h | 40 +++++++------------------------ hotremovable-goto/mm/page_alloc.c | 3 +- 2 files changed, 12 insertions(+), 31 deletions(-)
include/linux/mmzone.h renamed from include/linux/mmzone.h~new_zone +10 -30
@@ -73,37 +73,17 @@ struct per_cpu_pageset {#define ZONE_NORMAL 1#define ZONE_HIGHMEM 2 -#define MAX_NR_ZONES 3/* Sync this with ZONES_SHIFT */ -#define ZONES_SHIFT 2/* ceil(log2(MAX_NR_ZONES)) */ +#define ZONE_REMOVABLE 3 +#define ZONE_DMA_RMV (ZONE_DMA + ZONE_REMOVABLE)/* Hot-Removable DMA zone */ +#define ZONE_NORMAL_RMV (ZONE_NORMAL + ZONE_REMOVABLE)/* Hot-Removable DMA zone */ +#define ZONE_HIGHMEM_RMV (ZONE_HIGHMEM + ZONE_REMOVABLE)/* Hot-Removable DMA zone */ +#define MAX_NR_ZONES 6/* Sync this with ZONES_SHIFT */ +#define ZONES_SHIFT 3/* ceil(log2(MAX_NR_ZONES)) */ -/* -* When a memory allocation must conform to specific limitations (such -* as being suitable for DMA) the caller will pass in hints to the -* allocator in the gfp_mask, in the zone modifier bits. These bits -* are used to select a priority ordered list of memory zones which -* match the requested limits. GFP_ZONEMASK defines which bits within -* the gfp_mask should be considered as zone modifiers. Each valid -* combination of the zone modifier bits has a corresponding list -* of zones (in node_zonelists). Thus for two zone modifiers there -* will be a maximum of 4 (2 ** 2) zonelists, for 3 modifiers there will -* be 8 (2 ** 3) zonelists. GFP_ZONETYPES defines the number of possible -* combinations of zone modifiers in "zone modifier space". -*/ -#define GFP_ZONEMASK 0x03 -/* -* As an optimisation any zone modifier bits which are only valid when -* no other zone modifier bits are set (loners) should be placed in -* the highest order bits of this field. This allows us to reduce the -* extent of the zonelists thus saving space. For example in the case -* of three zone modifier bits, we could require up to eight zonelists. -* If the left most zone modifier is a "loner" then the highest valid -* zonelist would be four allowing us to allocate only five zonelists. -* Use the first form when the left most bit is not a "loner", otherwise -* use the second. -*/ -/* #define GFP_ZONETYPES (GFP_ZONEMASK + 1) */ /* Non-loner */ -#define GFP_ZONETYPES ((GFP_ZONEMASK + 1) / 2 + 1)/* Loner */ +#define GFP_ZONEMASK 0x07 + +#define GFP_ZONETYPES (MAX_NR_ZONES + 1)/* * On machines where it is needed (eg PCs) we divide physical memory
@@ -414,7 +394,7 @@ extern struct pglist_data contig_page_da* with 32 bit page->flags field, we reserve 8 bits for node/zone info. * there are 3 zones (2 bits) and this leaves 8-2=6 bits for nodes. */ -#define MAX_NODES_SHIFT 6 +#define MAX_NODES_SHIFT 5#elif BITS_PER_LONG ==64 /* * with 64 bit flags field, there's plenty of room.
mm/page_alloc.c renamed from mm/page_alloc.c~new_zone +2 -1
@@ -57,7 +57,8 @@ EXPORT_SYMBOL(nr_swap_pages);struct zone *zone_table[1 << (ZONES_SHIFT +NODES_SHIFT )];EXPORT_SYMBOL (zone_table); -static char *zone_names[MAX_NR_ZONES ] = {"DMA" ,"Normal" ,"HighMem" }; +static char *zone_names[MAX_NR_ZONES ] = {"DMA" ,"Normal" ,"HighMem" , +"DMA-Removable" ,"Normal-Removable" ,"Highmem-Removable" };int min_free_kbytes =1024 ;unsigned long __initdata nr_kernel_pages;
_
Signature · 8 lines
Yasunori Goto <ygoto at us.fujitsu.com> -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
[RFC/Patch]Making Removable zone[2/4]
In reply to Yasunori GotoUser processes and page cache can use removable area by this patch.
hotremovable-goto/include/linux/gfp.h | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
include/linux/gfp.h renamed from include/linux/gfp.h~gfp_removable +3 -2
@@ -11,9 +11,10 @@ struct vm_area_struct;/* * GFP bitmasks.. */ -/* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low two bits) */ +/* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low three bits) */ #define __GFP_DMA 0x01#define __GFP_HIGHMEM 0x02 +#define __GFP_REMOVABLE 0x04/* * Action modifiers - doesn't change the zoning
@@ -51,7 +52,7 @@ struct vm_area_struct;#define GFP_NOFS (__GFP_WAIT | __GFP_IO)#define GFP_KERNEL (__GFP_WAIT | __GFP_IO | __GFP_FS)#define GFP_USER (__GFP_WAIT | __GFP_IO | __GFP_FS) -#define GFP_HIGHUSER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HIGHMEM) +#define GFP_HIGHUSER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HIGHMEM | __GFP_REMOVABLE)/* Flag - indicates that the buffer will be suitable for DMA. Ignored on some platforms, used as appropriate on others */
_
Signature · 8 lines
Yasunori Goto <ygoto at us.fujitsu.com> -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
[RFC/Patch]Making Removable zone[3/4]
In reply to Yasunori GotoThis patch is to make new order of zone index and zonelist.
hotremovable-goto/include/linux/mmzone.h | 10 +++- hotremovable-goto/mm/page_alloc.c | 67 +++++++++++++------------------ 2 files changed, 37 insertions(+), 40 deletions(-)
include/linux/mmzone.h renamed from include/linux/mmzone.h~zones_order +8 -2
@@ -234,6 +234,11 @@ struct zonelist {struct zone *zones[MAX_NUMNODES *MAX_NR_ZONES +1 ];// NULL delimited }; +/* zonelist is decided by zone_order */ +struct zonelist_order { +char zone_order[MAX_NR_ZONES +1 ];/* -1 delimited */ +}; +extern const struct zonelist_order zorder[];/* * The pg_data_t structure is used in machines with CONFIG_DISCONTIGMEM
@@ -408,8 +413,9 @@ extern struct pglist_data contig_page_da#error NODES_SHIFT > MAX_NODES_SHIFT#endif -/* There are currently 3 zones: DMA, Normal & Highmem, thus we need 2 bits */ -#define MAX_ZONES_SHIFT 2 +/* There are currently 6 zones: {DMA, Normal , Highmem} x +{hot-Removable or Un-Removable} thus we need 3 bits */ +#define MAX_ZONES_SHIFT 3#if ZONES_SHIFT >MAX_ZONES_SHIFT #error ZONES_SHIFT > MAX_ZONES_SHIFT
mm/page_alloc.c renamed from mm/page_alloc.c~zones_order +29 -38
111 lines not on this page · raw message
_
Signature · 8 lines
Yasunori Goto <ygoto at us.fujitsu.com> -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
[RFC/Patch]Making Removable zone[4/4]
In reply to Yasunori GotoThis patch is just for test to make removable zones.
--
hotremovable-goto/arch/i386/mm/init.c | 22 +++++++++++++++++++--- 1 files changed, 19 insertions(+), 3 deletions(-)
arch/i386/mm/init.c renamed from arch/i386/mm/init.c~removable +19 -3
@@ -512,22 +512,38 @@ void zap_low_mappings (void) }#ifndef CONFIG_DISCONTIGMEM + +unsigned int __init check_max_unremovable (void ) +{ +/* XXX : Hardware information might be necessary. +Now is just for test */ +return (highend_pfn + max_low_pfn) /2 ; +} +void __init zone_sizes_init (void ) { -unsigned long zones_size[MAX_NR_ZONES ] = {0 ,0 ,0 }; -unsigned int max_dma, high, low; +unsigned long zones_size[MAX_NR_ZONES ] = {0 ,0 ,0 ,0 ,0 ,0 }; +unsigned int max_dma, high, low, max_unremovable; max_dma =virt_to_phys ((char *)MAX_DMA_ADDRESS ) >>PAGE_SHIFT ; low = max_low_pfn; high = highend_pfn; + max_unremovable =check_max_unremovable (); +if (low < max_dma) zones_size[ZONE_DMA ] = low;else { zones_size[ZONE_DMA ] = max_dma; zones_size[ZONE_NORMAL ] = low - max_dma;#ifdef CONFIG_HIGHMEM - zones_size[ZONE_HIGHMEM ] = high - low; +if ( low >= max_unremovable ) + zones_size[ZONE_HIGHMEM_RMV ] = high - low; +else if ( high > max_unremovable ){ + zones_size[ZONE_HIGHMEM_RMV ] = high - max_unremovable; + zones_size[ZONE_HIGHMEM ] = max_unremovable - low; + }else + zones_size[ZONE_HIGHMEM ] = high - low;#endif }free_area_init (zones_size);
_
Signature · 8 lines
Yasunori Goto <ygoto at us.fujitsu.com> -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>