lkml.org 
[lkml]   [2014]   [Feb]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 4/6] mm: add set_pageblock_migratetype_nolock() for calls outside zone->lock
Date
To prevent races, set_pageblock_migratetype() should be called with zone->lock
held. This patch adds a debugging assertion and introduces a _nolock variant
for zone init functions.

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
---
mm/page_alloc.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index de5b419..fd6a64c 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -232,7 +232,7 @@ EXPORT_SYMBOL(nr_online_nodes);

int page_group_by_mobility_disabled __read_mostly;

-void set_pageblock_migratetype(struct page *page, int migratetype)
+static void set_pageblock_migratetype_nolock(struct page *page, int migratetype)
{
if (unlikely(page_group_by_mobility_disabled &&
migratetype < MIGRATE_PCPTYPES))
@@ -242,6 +242,13 @@ void set_pageblock_migratetype(struct page *page, int migratetype)
PB_migrate, PB_migrate_end);
}

+void set_pageblock_migratetype(struct page *page, int migratetype)
+{
+ VM_BUG_ON(!spin_is_locked(&page_zone(page)->lock));
+
+ set_pageblock_migratetype_nolock(page, migratetype);
+}
+
bool oom_killer_disabled __read_mostly;

#ifdef CONFIG_DEBUG_VM
@@ -803,7 +810,7 @@ void __init init_cma_reserved_pageblock(struct page *page)
} while (++p, --i);

set_page_refcounted(page);
- set_pageblock_migratetype(page, MIGRATE_CMA);
+ set_pageblock_migratetype_nolock(page, MIGRATE_CMA);
__free_pages(page, pageblock_order);
adjust_managed_page_count(page, pageblock_nr_pages);
}
@@ -4100,7 +4107,7 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone,
if ((z->zone_start_pfn <= pfn)
&& (pfn < zone_end_pfn(z))
&& !(pfn & (pageblock_nr_pages - 1)))
- set_pageblock_migratetype(page, MIGRATE_MOVABLE);
+ set_pageblock_migratetype_nolock(page, MIGRATE_MOVABLE);

INIT_LIST_HEAD(&page->lru);
#ifdef WANT_PAGE_VIRTUAL
--
1.8.4.5


\
 
 \ /
  Last update: 2014-02-28 16:01    [W:0.094 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site