Skip to contentSkip to conversation

New zone ZONE_EASY_RECLAIM take 3. (change build_zonelists)[3/5]

PATCH In review Yasunori Goto 2 participants 3 messages Dec 10, 2005 – Dec 16, 2005

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 New zone ZONE_EASY_RECLAIM take 3. (change build_zonelists)[3/5]

This is changing build_zonelists for new zone.

__GFP_xxxs are flag for requires of page allocation which zone is prefered. But, it is used as an index number for zonelists[] too. But after my patch, __GFP_xxx might be set at same time. So, last set bit number of __GFP is recognized for zonelists' index by this patch.

Note:
This patch is modified take 3 to avoid panic on i386. __GFP_DMA32 is 0 for i386. So, ZONE_DMA32 is selected if zone_bits is 0 which means Zone_normal. Zone_DMA32 is not allocated on i386, so kernel paniced by no normal memory.
In this patch, even if zone_bits is 0 adn __GFP_DMA32 is 0, Zone_Normal is selected.

mm/page_alloc.c +12 -4
Index: zone_reclaim/mm/page_alloc.c
===================================================================
@@ -1574,6 +1574,10 @@ static int __init build_zonelists_node(p
 		struct zone *zone;
 	default:
 		BUG();
+	case ZONE_EASY_RECLAIM:
+		zone = pgdat->node_zones + ZONE_EASY_RECLAIM;
+		if (zone->present_pages)
+			zonelist->zones[j++] = zone;
 	case ZONE_HIGHMEM:
 		zone = pgdat->node_zones + ZONE_HIGHMEM;
 		if (populated_zone(zone)) {
@@ -1602,12 +1606,16 @@ static int __init build_zonelists_node(p
 static inline int highest_zone(int zone_bits)
 {
 	int res = ZONE_NORMAL;
-	if (zone_bits & (__force int)__GFP_HIGHMEM)
-		res = ZONE_HIGHMEM;
-	if (zone_bits & (__force int)__GFP_DMA32)
-		res = ZONE_DMA32;
+
 	if (zone_bits & (__force int)__GFP_DMA)
 		res = ZONE_DMA;
+	if (zone_bits & (__force int)__GFP_DMA32)
+		res = ZONE_DMA32;
+	if (zone_bits & (__force int)__GFP_HIGHMEM)
+		res = ZONE_HIGHMEM;
+	if (zone_bits & (__force int)__GFP_EASY_RECLAIM)
+		res = ZONE_EASY_RECLAIM;
+
 	return res;
 }
 
include/linux/gfp.h +1 -1
Index: zone_reclaim/include/linux/gfp.h
===================================================================
@@ -80,7 +80,7 @@ struct vm_area_struct;
 
 static inline int gfp_zone(gfp_t gfp)
 {
-	int zone = GFP_ZONEMASK & (__force int) gfp;
+	int zone = fls(GFP_ZONEMASK & (__force int) gfp);
 	BUG_ON(zone >= GFP_ZONETYPES);
 	return zone;
 }
Signature · 8 lines
Yasunori Goto 


--
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>
#1 lore raw
Quoted 11 lines
mm/page_alloc.c +1 -4
@@ -1602,12 +1606,16 @@ static int __init build_zonelists_node(p
 static inline int highest_zone(int zone_bits)
 {
 	int res = ZONE_NORMAL;
-	if (zone_bits & (__force int)__GFP_HIGHMEM)
-		res = ZONE_HIGHMEM;
-	if (zone_bits & (__force int)__GFP_DMA32)
-		res = ZONE_DMA32;
+
 	if (zone_bits & (__force int)__GFP_DMA)
 		res = ZONE_DMA;

mm/page_alloc.c static int __init build_zonelists_node(p · line 1621

Quoted 10 lines
mm/page_alloc.c +7 -0
+	if (zone_bits & (__force int)__GFP_DMA32)
+		res = ZONE_DMA32;
+	if (zone_bits & (__force int)__GFP_HIGHMEM)
+		res = ZONE_HIGHMEM;
+	if (zone_bits & (__force int)__GFP_EASY_RECLAIM)
+		res = ZONE_EASY_RECLAIM;
+
 	return res;
 }
 

These look to come in the wrong order here. You want ZONE_EASY_RECLAIM to be the highest zone, but this puts HIGHMEM, DMA32, and DMA ahead of it. It in fact seems to get the order exactly backward.

Quoted 6 lines

Index: zone_reclaim/include/linux/gfp.h
===================================================================

include/linux/gfp.h struct vm_area_struct; · line 86

Quoted 8 lines
include/linux/gfp.h +1 -1
@@ -80,7 +80,7 @@ struct vm_area_struct;
 
 static inline int gfp_zone(gfp_t gfp)
 {
-	int zone = GFP_ZONEMASK & (__force int) gfp;
+	int zone = fls(GFP_ZONEMASK & (__force int) gfp);
 	BUG_ON(zone >= GFP_ZONETYPES);
 	return zone;
 }

Does this have endian issues? I'm not too familiar with it.

--
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>

#2 lore raw
Quoted 17 lines
Quoted 17 lines
mm/page_alloc.c +7 -4
@@ -1602,12 +1606,16 @@ static int __init build_zonelists_node(p
 static inline int highest_zone(int zone_bits)
 {
 	int res = ZONE_NORMAL;
-	if (zone_bits & (__force int)__GFP_HIGHMEM)
-		res = ZONE_HIGHMEM;
-	if (zone_bits & (__force int)__GFP_DMA32)
-		res = ZONE_DMA32;
+
 	if (zone_bits & (__force int)__GFP_DMA)
 		res = ZONE_DMA;
+	if (zone_bits & (__force int)__GFP_DMA32)
+		res = ZONE_DMA32;
+	if (zone_bits & (__force int)__GFP_HIGHMEM)
+		res = ZONE_HIGHMEM;
+	if (zone_bits & (__force int)__GFP_EASY_RECLAIM)
+		res = ZONE_EASY_RECLAIM;
Quoted 8 lines

mm/page_alloc.c static int __init build_zonelists_node(p · line 1621

Quoted 4 lines
mm/page_alloc.c +1 -0
+
 	return res;
 }
 

These look to come in the wrong order here. You want ZONE_EASY_RECLAIM to be the highest zone, but this puts HIGHMEM, DMA32, and DMA ahead of it. It in fact seems to get the order exactly backward.

I think this is correct about it.

If these are used "else if", you are correct.
But, if zone_bits is __GFP_EASY_RECLAIM, then it fall through to last line.

Quoted 7 lines
Quoted 7 lines

Index: zone_reclaim/include/linux/gfp.h
===================================================================

include/linux/gfp.h +0 -0
@@ -80,7 +80,7 @@ struct vm_area_struct;
 
Quoted 10 lines

include/linux/gfp.h struct vm_area_struct; · line 86

Quoted 8 lines
include/linux/gfp.h +1 -1
 static inline int gfp_zone(gfp_t gfp)
 {
-	int zone = GFP_ZONEMASK & (__force int) gfp;
+	int zone = fls(GFP_ZONEMASK & (__force int) gfp);
 	BUG_ON(zone >= GFP_ZONETYPES);
 	return zone;
 }

Does this have endian issues? I'm not too familiar with it.

I'm also not too familiar with it. But, if there is a difference. I suppose generic_ffs() and generic_fls() is not generic. :-P

However, Kame-san tells me this patch is still wrong. __GFP_EASY_RECLAIM is 0x04 on i386, so fls(__GFP_EASY_RECLAIM) is 3. zone 3 is ZONE_HIGHMEM, not ZONE_EASY_RECLAIM. This patch should be more considered. Ah....

Bye.

Signature · 8 lines
Yasunori Goto 


--
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>