Skip to contentSkip to conversation

Use correct page frame number to grab page zone lock

PATCH In review Nathan Fontenot 1 participant 2 messages Oct 29, 2008

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

PATCH 1/1 Use correct page frame number to grab page zone lock

There are situations in which the 'pfn' variable used to calculate the page zone can be invalid. One case is in the hotplug memory remove path where we are trying to remove memory the last valid page frame for the system. Passing an invalid page frame number to the pfn_to_page() macro will cause the system to oops.

Additionally I think this also solves an issue where we may be grabbing the wrong zone->lock. This would occur when 'pfn' refers to a page frame beyond what we are examining and lies in a different zone.

Using the starting page frame number passed in appears to resolve both of these issues. This patch also removes the redundant initialization of 'pfn', it is set explicitly and then again in the for loop.

---

mm/page_isolation.c +0 -0
Index: linux-2.6/mm/page_isolation.c
===================================================================
@@ -119,7 +119,6 @@
	struct zone *zone;
	int ret;

- pfn = start_pfn;
/*
* Note: pageblock_nr_page != MAX_ORDER. Then, chunks of free page
* is not aligned to pageblock_nr_pages.
@@ -133,7 +132,7 @@

	if (pfn < end_pfn)
		return -EBUSY;
	/* Check all pages are free or Marked as ISOLATED */
-	zone = page_zone(pfn_to_page(pfn));
+	zone = page_zone(pfn_to_page(start_pfn));
	spin_lock_irqsave(&zone->lock, flags);
	ret = __test_page_isolated_in_pageblock(start_pfn, end_pfn);
	spin_unlock_irqrestore(&zone->lock, flags);
#1 lore raw

Disregard. It appears that Gerald Schaefer submitted a patch to fix this already.

http://lkml.org/lkml/2008/10/29/142

-Nathan

Quoted 45 lines · Nathan Fontenot

There are situations in which the 'pfn' variable used to calculate the page zone can be invalid. One case is in the hotplug memory remove path where we are trying to remove memory the last valid page frame for the system. Passing an invalid page frame number to the pfn_to_page() macro will cause the system to oops.

Additionally I think this also solves an issue where we may be grabbing the wrong zone->lock. This would occur when 'pfn' refers to a page frame beyond what we are examining and lies in a different zone.

Using the starting page frame number passed in appears to resolve both of these issues. This patch also removes the redundant initialization of 'pfn', it is set explicitly and then again in the for loop.

---

Index: linux-2.6/mm/page_isolation.c
===================================================================
--- linux-2.6.orig/mm/page_isolation.c 2008-10-13 12:00:46.000000000
-0500
+++ linux-2.6/mm/page_isolation.c 2008-10-29 11:18:39.000000000 -0500

(quoted diff) +1 -2
@@ -119,7 +119,6 @@
    struct zone *zone;
    int ret;
 
-    pfn = start_pfn;
    /*
     * Note: pageblock_nr_page != MAX_ORDER. Then, chunks of free page
     * is not aligned to pageblock_nr_pages.
@@ -133,7 +132,7 @@
    if (pfn < end_pfn)
        return -EBUSY;
    /* Check all pages are free or Marked as ISOLATED */
-    zone = page_zone(pfn_to_page(pfn));
+    zone = page_zone(pfn_to_page(start_pfn));
    spin_lock_irqsave(&zone->lock, flags);
    ret = __test_page_isolated_in_pageblock(start_pfn, end_pfn);
    spin_unlock_irqrestore(&zone->lock, flags);
Signature · 4 lines
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/