From: Andy Whitcroft <apw@shadowen.org>
To: Mel Gorman <mel@csn.ul.ie>, Bob Picco <bob.picco@hp.com>
Cc: Andy Whitcroft <apw@shadowen.org>,
Dave Hansen <hansendc@us.ibm.com>, Andrew Morton <akpm@osdl.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] add pfn_valid_within helper for sub-MAX_ORDER hole detection
Date: Wed, 21 Mar 2007 19:15:26 +0000 [thread overview]
Message-ID: <2b7fba2bc49877d95f3ad13735324444@pinky> (raw)
In-Reply-To: <exportbomb.1174504472@pinky>
Generally we work under the assumption that memory the mem_map
array is contigious and valid out to MAX_ORDER_NR_PAGES block
of pages, ie. that if we have validated any page within this
MAX_ORDER_NR_PAGES block we need not check any other. This is not
true when CONFIG_HOLES_IN_ZONE is set and we must check each and
every reference we make from a pfn.
Add a pfn_valid_within() helper which should be used when scanning
pages within a MAX_ORDER_NR_PAGES block when we have already
checked the validility of the block normally with pfn_valid().
This can then be optimised away when we do not have holes within
a MAX_ORDER_NR_PAGES block of pages.
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
Acked-by: Mel Gorman <mel@csn.ul.ie>
---
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 7206c77..8c87d79 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -837,6 +837,18 @@ void sparse_init(void);
void memory_present(int nid, unsigned long start, unsigned long end);
unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long);
+/*
+ * If it is possible to have holes within a MAX_ORDER_NR_PAGES, then we
+ * need to check pfn validility within that MAX_ORDER_NR_PAGES block.
+ * pfn_valid_within() should be used in this case; we optimise this away
+ * when we have no holes within a MAX_ORDER_NR_PAGES block.
+ */
+#ifdef CONFIG_HOLES_IN_ZONE
+#define pfn_valid_within(pfn) pfn_valid(pfn)
+#else
+#define pfn_valid_within(pfn) (1)
+#endif
+
#endif /* !__ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif /* _LINUX_MMZONE_H */
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 3d7a9e2..695b5a6 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -206,10 +206,8 @@ static int page_outside_zone_boundaries(struct zone *zone, struct page *page)
static int page_is_consistent(struct zone *zone, struct page *page)
{
-#ifdef CONFIG_HOLES_IN_ZONE
- if (!pfn_valid(page_to_pfn(page)))
+ if (!pfn_valid_within(page_to_pfn(page)))
return 0;
-#endif
if (zone != page_zone(page))
return 0;
@@ -411,10 +409,8 @@ __find_combined_index(unsigned long page_idx, unsigned int order)
static inline int page_is_buddy(struct page *page, struct page *buddy,
int order)
{
-#ifdef CONFIG_HOLES_IN_ZONE
- if (!pfn_valid(page_to_pfn(buddy)))
+ if (!pfn_valid_within(page_to_pfn(buddy)))
return 0;
-#endif
if (page_zone_id(page) != page_zone_id(buddy))
return 0;
next prev parent reply other threads:[~2007-03-21 19:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Pine.LNX.4.64.0703211510340.15309@skynet.skynet.ie>
2007-03-21 19:14 ` [PATCH 0/3] pfn_valid_within() HOLES_WITHIN_ZONES helper Andy Whitcroft
2007-03-21 19:15 ` Andy Whitcroft [this message]
2007-03-21 23:23 ` [PATCH 1/3] add pfn_valid_within helper for sub-MAX_ORDER hole detection Nick Piggin
2007-03-21 23:46 ` Andrew Morton
2007-03-21 19:15 ` [PATCH 2/3] anti-fragmentation: switch over to pfn_valid_within() Andy Whitcroft
2007-03-21 19:16 ` [PATCH 3/3] lumpy: move to using pfn_valid_within() Andy Whitcroft
2007-03-21 20:55 ` [PATCH 0/3] pfn_valid_within() HOLES_WITHIN_ZONES helper Bob Picco
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=2b7fba2bc49877d95f3ad13735324444@pinky \
--to=apw@shadowen.org \
--cc=akpm@osdl.org \
--cc=bob.picco@hp.com \
--cc=hansendc@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mel@csn.ul.ie \
/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
Powered by JetHome