Skip to content

Commit c6a57e1

Browse files
hansendcLinus Torvalds
authored andcommitted
[PATCH] memory hotplug prep: fixup bad_range()
When doing memory hotplug operations, the size of existing zones can obviously change. This means that zone->zone_{start_pfn,spanned_pages} can change. There are currently no locks that protect these structure members. However, they are rarely accessed at runtime. Outside of swsusp, the only place that I can find is bad_range(). So, split bad_range() up into two pieces: one that needs to be locked and anther that doesn't. Signed-off-by: Dave Hansen <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 4ca644d commit c6a57e1

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

mm/page_alloc.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,37 @@ int min_free_kbytes = 1024;
7878
unsigned long __initdata nr_kernel_pages;
7979
unsigned long __initdata nr_all_pages;
8080

81-
/*
82-
* Temporary debugging check for pages not lying within a given zone.
83-
*/
84-
static int bad_range(struct zone *zone, struct page *page)
81+
static int page_outside_zone_boundaries(struct zone *zone, struct page *page)
8582
{
8683
if (page_to_pfn(page) >= zone->zone_start_pfn + zone->spanned_pages)
8784
return 1;
8885
if (page_to_pfn(page) < zone->zone_start_pfn)
8986
return 1;
87+
88+
return 0;
89+
}
90+
91+
static int page_is_consistent(struct zone *zone, struct page *page)
92+
{
9093
#ifdef CONFIG_HOLES_IN_ZONE
9194
if (!pfn_valid(page_to_pfn(page)))
92-
return 1;
95+
return 0;
9396
#endif
9497
if (zone != page_zone(page))
98+
return 0;
99+
100+
return 1;
101+
}
102+
/*
103+
* Temporary debugging check for pages not lying within a given zone.
104+
*/
105+
static int bad_range(struct zone *zone, struct page *page)
106+
{
107+
if (page_outside_zone_boundaries(zone, page))
95108
return 1;
109+
if (!page_is_consistent(zone, page))
110+
return 1;
111+
96112
return 0;
97113
}
98114

0 commit comments

Comments
 (0)