* [RFC/Patch]Making Removable zone[1/4]
2004-10-26 2:24 [RFC/Patch]Making Removable zone[0/4] Yasunori Goto
@ 2004-10-26 2:34 ` Yasunori Goto
2004-10-26 2:35 ` [RFC/Patch]Making Removable zone[2/4] Yasunori Goto
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Yasunori Goto @ 2004-10-26 2:34 UTC (permalink / raw)
To: lhms-devel, linux-mm
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(-)
diff -puN include/linux/mmzone.h~new_zone include/linux/mmzone.h
--- hotremovable/include/linux/mmzone.h~new_zone Fri Aug 27 21:06:50 2004
+++ hotremovable-goto/include/linux/mmzone.h Fri Aug 27 21:06:50 2004
@@ -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.
diff -puN mm/page_alloc.c~new_zone mm/page_alloc.c
--- hotremovable/mm/page_alloc.c~new_zone Fri Aug 27 21:06:50 2004
+++ hotremovable-goto/mm/page_alloc.c Fri Aug 27 21:06:50 2004
@@ -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;
_
--
Yasunori Goto <ygoto at us.fujitsu.com>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread* [RFC/Patch]Making Removable zone[3/4]
2004-10-26 2:24 [RFC/Patch]Making Removable zone[0/4] Yasunori Goto
2004-10-26 2:34 ` [RFC/Patch]Making Removable zone[1/4] Yasunori Goto
2004-10-26 2:35 ` [RFC/Patch]Making Removable zone[2/4] Yasunori Goto
@ 2004-10-26 2:36 ` Yasunori Goto
2004-10-26 2:38 ` [RFC/Patch]Making Removable zone[4/4] Yasunori Goto
3 siblings, 0 replies; 5+ messages in thread
From: Yasunori Goto @ 2004-10-26 2:36 UTC (permalink / raw)
To: lhms-devel, linux-mm
This 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(-)
diff -puN include/linux/mmzone.h~zones_order include/linux/mmzone.h
--- hotremovable/include/linux/mmzone.h~zones_order Fri Aug 27 21:07:01 2004
+++ hotremovable-goto/include/linux/mmzone.h Fri Aug 27 21:07:01 2004
@@ -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
diff -puN mm/page_alloc.c~zones_order mm/page_alloc.c
--- hotremovable/mm/page_alloc.c~zones_order Fri Aug 27 21:07:01 2004
+++ hotremovable-goto/mm/page_alloc.c Fri Aug 27 21:07:01 2004
@@ -47,6 +47,18 @@ long nr_swap_pages;
int numnodes = 1;
int sysctl_lower_zone_protection = 0;
+const struct zonelist_order zorder[GFP_ZONETYPES] = {
+ {{ ZONE_NORMAL, ZONE_DMA, -1, -1, -1, -1, -1}}, /* __GFP_NORMAL */
+ {{ ZONE_DMA, -1, -1, -1, -1, -1, -1}}, /* __GFP_DMA */
+ {{ ZONE_HIGHMEM, ZONE_NORMAL, ZONE_DMA, -1, -1, -1, -1}}, /* __GFP_HIGHMEM */
+ {{ -1, -1, -1, -1, -1, -1, -1}}, /* reserve */
+ {{ ZONE_NORMAL_RMV, ZONE_NORMAL, ZONE_DMA_RMV,
+ ZONE_DMA, -1, -1, -1}}, /* __GFP_NORMAL | __GFP_REMOVABLE */
+ {{ ZONE_DMA_RMV, ZONE_DMA, -1, -1, -1, -1, -1}}, /* __GFP_DMA | __GFP_REMOVABLE */
+ {{ZONE_HIGHMEM_RMV, ZONE_HIGHMEM, ZONE_NORMAL_RMV,
+ ZONE_NORMAL, ZONE_DMA_RMV, ZONE_DMA, -1}} /* __GFP_HIGHMEM | __GFP_REMOVABLE */
+};
+
EXPORT_SYMBOL(totalram_pages);
EXPORT_SYMBOL(nr_swap_pages);
@@ -1452,27 +1464,17 @@ void show_free_areas(void)
*/
static int __init build_zonelists_node(pg_data_t *pgdat, struct zonelist *zonelist, int j, int k)
{
- switch (k) {
- struct zone *zone;
- default:
- BUG();
- case ZONE_HIGHMEM:
- zone = pgdat->node_zones + ZONE_HIGHMEM;
- if (zone->present_pages) {
-#ifndef CONFIG_HIGHMEM
- BUG();
-#endif
- zonelist->zones[j++] = zone;
- }
- case ZONE_NORMAL:
- zone = pgdat->node_zones + ZONE_NORMAL;
- if (zone->present_pages)
- zonelist->zones[j++] = zone;
- case ZONE_DMA:
- zone = pgdat->node_zones + ZONE_DMA;
- if (zone->present_pages)
- zonelist->zones[j++] = zone;
- }
+ struct zone *zone;
+ int i = 0,index;
+
+ index = zorder[k].zone_order[i];
+
+ while(index != -1){
+ zone = pgdat->node_zones + index;
+ zonelist->zones[j++] = zone;
+ i++;
+ index = zorder[k].zone_order[i];
+ };
return j;
}
@@ -1537,7 +1539,7 @@ static int __init find_next_best_node(in
static void __init build_zonelists(pg_data_t *pgdat)
{
- int i, j, k, node, local_node;
+ int i, j, node, local_node;
int prev_node, load;
struct zonelist *zonelist;
DECLARE_BITMAP(used_mask, MAX_NUMNODES);
@@ -1569,13 +1571,7 @@ static void __init build_zonelists(pg_da
zonelist = pgdat->node_zonelists + i;
for (j = 0; zonelist->zones[j] != NULL; j++);
- k = ZONE_NORMAL;
- if (i & __GFP_HIGHMEM)
- k = ZONE_HIGHMEM;
- if (i & __GFP_DMA)
- k = ZONE_DMA;
-
- j = build_zonelists_node(NODE_DATA(node), zonelist, j, k);
+ j = build_zonelists_node(NODE_DATA(node), zonelist, j, i);
zonelist->zones[j] = NULL;
}
}
@@ -1585,7 +1581,7 @@ static void __init build_zonelists(pg_da
static void __init build_zonelists(pg_data_t *pgdat)
{
- int i, j, k, node, local_node;
+ int i, j, node, local_node;
local_node = pgdat->node_id;
for (i = 0; i < GFP_ZONETYPES; i++) {
@@ -1595,13 +1591,8 @@ static void __init build_zonelists(pg_da
memset(zonelist, 0, sizeof(*zonelist));
j = 0;
- k = ZONE_NORMAL;
- if (i & __GFP_HIGHMEM)
- k = ZONE_HIGHMEM;
- if (i & __GFP_DMA)
- k = ZONE_DMA;
- j = build_zonelists_node(pgdat, zonelist, j, k);
+ j = build_zonelists_node(pgdat, zonelist, j, i);
/*
* Now we build the zonelist so that it contains the zones
* of all the other nodes.
@@ -1611,9 +1602,9 @@ static void __init build_zonelists(pg_da
* node N+1 (modulo N)
*/
for (node = local_node + 1; node < numnodes; node++)
- j = build_zonelists_node(NODE_DATA(node), zonelist, j, k);
+ j = build_zonelists_node(NODE_DATA(node), zonelist, j, i);
for (node = 0; node < local_node; node++)
- j = build_zonelists_node(NODE_DATA(node), zonelist, j, k);
+ j = build_zonelists_node(NODE_DATA(node), zonelist, j, i);
zonelist->zones[j] = NULL;
}
_
--
Yasunori Goto <ygoto at us.fujitsu.com>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread