From: Vlastimil Babka <vbabka@suse.cz>
To: Andrew Morton <akpm@linux-foundation.org>,
Mel Gorman <mgorman@suse.de>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Rik van Riel <riel@redhat.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Minchan Kim <minchan@kernel.org>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Vlastimil Babka <vbabka@suse.cz>
Subject: [PATCH 3/6] mm: add is_migrate_isolate_page_nolock() for cases where locking is undesirable
Date: Fri, 28 Feb 2014 15:15:01 +0100 [thread overview]
Message-ID: <1393596904-16537-4-git-send-email-vbabka@suse.cz> (raw)
In-Reply-To: <1393596904-16537-1-git-send-email-vbabka@suse.cz>
This patch complements the addition of get_pageblock_migratetype_nolock() for
the case where is_migrate_isolate_page() cannot be called with zone->lock held.
A race with set_pageblock_migratetype() may be detected, in which case a caller
supplied argument is returned.
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
---
include/linux/page-isolation.h | 24 ++++++++++++++++++++++++
mm/hugetlb.c | 2 +-
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h
index 3fff8e7..f7bd491 100644
--- a/include/linux/page-isolation.h
+++ b/include/linux/page-isolation.h
@@ -2,10 +2,30 @@
#define __LINUX_PAGEISOLATION_H
#ifdef CONFIG_MEMORY_ISOLATION
+/*
+ * Should be called only with zone->lock held. In cases where locking overhead
+ * is undesirable, consider the _nolock version.
+ */
static inline bool is_migrate_isolate_page(struct page *page)
{
return get_pageblock_migratetype(page) == MIGRATE_ISOLATE;
}
+/*
+ * When called without zone->lock held, a race with set_pageblock_migratetype
+ * may result in bogus values. The race may be detected, in which case the
+ * value of race_fallback argument is returned. For details, see
+ * get_pageblock_migratetype_nolock().
+ */
+static inline bool is_migrate_isolate_page_nolock(struct page *page,
+ bool race_fallback)
+{
+ int migratetype = get_pageblock_migratetype_nolock(page, MIGRATE_TYPES);
+
+ if (unlikely(migratetype == MIGRATE_TYPES))
+ return race_fallback;
+
+ return migratetype == MIGRATE_ISOLATE;
+}
static inline bool is_migrate_isolate(int migratetype)
{
return migratetype == MIGRATE_ISOLATE;
@@ -15,6 +35,10 @@ static inline bool is_migrate_isolate_page(struct page *page)
{
return false;
}
+static inline bool is_migrate_isolate_page_nolock(struct page *page)
+{
+ return false;
+}
static inline bool is_migrate_isolate(int migratetype)
{
return false;
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 2252cac..fac4003 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -525,7 +525,7 @@ static struct page *dequeue_huge_page_node(struct hstate *h, int nid)
struct page *page;
list_for_each_entry(page, &h->hugepage_freelists[nid], lru)
- if (!is_migrate_isolate_page(page))
+ if (!is_migrate_isolate_page_nolock(page, true))
break;
/*
* if 'non-isolated free hugepage' not found on the list,
--
1.8.4.5
--
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:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2014-02-28 14:15 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-28 14:14 [PATCH 0/6] close pageblock_migratetype and pageblock_skip races Vlastimil Babka
2014-02-28 14:14 ` [PATCH 1/6] mm: call get_pageblock_migratetype() under zone->lock where possible Vlastimil Babka
2014-02-28 14:15 ` [PATCH 2/6] mm: add get_pageblock_migratetype_nolock() for cases where locking is undesirable Vlastimil Babka
2014-03-03 8:22 ` Joonsoo Kim
2014-03-03 13:54 ` Vlastimil Babka
2014-03-04 0:55 ` Joonsoo Kim
2014-03-04 12:16 ` Vlastimil Babka
2014-03-05 0:29 ` Joonsoo Kim
2014-03-05 0:37 ` Joonsoo Kim
2014-02-28 14:15 ` Vlastimil Babka [this message]
2014-03-05 0:39 ` [PATCH 3/6] mm: add is_migrate_isolate_page_nolock() " Joonsoo Kim
2014-02-28 14:15 ` [PATCH 4/6] mm: add set_pageblock_migratetype_nolock() for calls outside zone->lock Vlastimil Babka
2014-02-28 14:15 ` [PATCH 5/6] mm: compaction: do not set pageblock skip bit when already set Vlastimil Babka
2014-02-28 14:15 ` [PATCH 6/6] mm: use atomic bit operations in set_pageblock_flags_group() Vlastimil Babka
2014-03-03 8:28 ` Joonsoo Kim
2014-03-03 12:46 ` Vlastimil Babka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1393596904-16537-4-git-send-email-vbabka@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=iamjoonsoo.kim@lge.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=minchan@kernel.org \
--cc=riel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).