From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Andrew Morton <akpm@osdl.org>
Cc: apw@shadowen.org, mel@csn.ul.ie, stable@kernel.org, linux-mm@kvack.org
Subject: Re: [patch 2/2] mm: handle unaligned zones
Date: Sun, 21 May 2006 20:31:27 +1000 [thread overview]
Message-ID: <4470417F.2000605@yahoo.com.au> (raw)
In-Reply-To: <20060521021905.0f73e01a.akpm@osdl.org>
Andrew Morton wrote:
> Nick Piggin <nickpiggin@yahoo.com.au> wrote:
>
>>Allow unaligned zones, and make this an opt-in CONFIG_ option because
>>some architectures appear to be relying on unaligned zones being handled
>>correctly.
>>
>>- Also, the bad_range checks are removed, they are checked at meminit time
>> since the last patch.
>>
>>...
>>
>>Index: linux-2.6/mm/page_alloc.c
>>===================================================================
>>--- linux-2.6.orig/mm/page_alloc.c 2006-05-21 17:53:36.000000000 +1000
>>+++ linux-2.6/mm/page_alloc.c 2006-05-21 18:20:13.000000000 +1000
>>
>>...
>>
>>+{
>>+#ifdef CONFIG_HOLES_IN_ZONE
>
>
> (Why is this a config option? If we can optionally handle it, why not
> always just handle it?
Holes in zone? or unaligned zones? Holes in zone, I guess because
it is seen as somewhat of a special case, and can be removed if ia64
moves to sparsemem.
>
>
>>+/*
>>+ * If the the zone's mem_map is not 1<<MAX_ORDER aligned, CONFIG_ALIGNED_ZONE
>>+ * must *not* be set by the architecture, because the buddy allocator will run
>>+ * into "buddies" which are outside mem_map.
>>+ *
>>+ * It is not enough for the node's mem_map to be aligned, because unaligned
>>+ * zone boundaries can cause a buddies to be in different zones.
>>+ */
>>+static inline int buddy_outside_zone_span(struct page *page, struct page *buddy)
>>+{
>>+ int ret = 0;
>>+
>>+#ifndef CONFIG_ALIGNED_ZONE
>>+ unsigned int seq;
>>+ unsigned long pfn;
>>+ struct zone *zone;
>>+
>>+ pfn = page_to_pfn(page);
>>+ zone = page_zone(page);
>>+
>>+ do {
>
>
> You'll want a `ret = 0' here.
Thanks.
>
>
>>+ seq = zone_span_seqbegin(zone);
>>+ if (pfn >= zone->zone_start_pfn + zone->spanned_pages)
>>+ ret = 1;
>>+ else if (pfn < zone->zone_start_pfn)
>>+ ret = 1;
>>+ } while (zone_span_seqretry(zone, seq));
>>+ if (ret)
>>+ goto out;
>>+
>>+ /*
>>+ * page_zone_idx accesses page->flags, so this test must go after
>>+ * the above, which ensures that buddy is within the zone.
>>+ */
>>+ if (page_zone_idx(page) != page_zone_idx(buddy))
>>+ ret = 1;
>>+
>>+out:
>>+#endif
>>+
>>+ return ret;
>>+}
>>+
>>+/*
>>+ * In some memory configurations, buddy pages may be found which are
>>+ * outside the zone pages. Check for those here.
>>+ */
>>+static int buddy_outside_zone(struct page *page, struct page *buddy)
>>+{
>>+ if (page_in_zone_hole(buddy))
>>+ return 1;
>>+
>>+ if (buddy_outside_zone_span(page, buddy))
>>+ return 1;
>>+
>>+ return 0;
>>+}
>>+
>>+/*
>>+ * This function checks whether a buddy is free and is the buddy of page.
>>+ * We can coalesce a page and its buddy if
>>+ * (a) the buddy is not "outside" the zone &&
>> * (b) the buddy is in the buddy system &&
>> * (c) a page and its buddy have the same order.
>> *
>>@@ -292,15 +320,13 @@ __find_combined_index(unsigned long page
>> *
>> * For recording page's order, we use page_private(page).
>> */
>>-static inline int page_is_buddy(struct page *page, 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(page)))
>>+ if (buddy_outside_zone(page, buddy))
>> return 0;
>
>
> This is a heck of a lot of code to be throwing into the page-freeing
> hotpath. Surely there's a way of moving all this work to
> initialisation/hotadd time?
Can't think of any good way to do it. We could add yet another page
flag, which would relegate unaligned portions of zones to only order-0
pages (and never try to merge them up the buddy allocator).
Of course that's another page flag.
It is possible we can avoid the zone seqlock checks simply by always
testing whether the pfn is valid (this way the test would be more
unified with the holes in zone case).
The tests would still be pretty heavyweight though.
--
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com
--
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:[~2006-05-21 10:31 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-21 8:22 [patch 1/2] mm: detect bad zones Nick Piggin
2006-05-21 8:22 ` [patch 2/2] mm: handle unaligned zones Nick Piggin
2006-05-21 9:19 ` Andrew Morton
2006-05-21 10:31 ` Nick Piggin [this message]
2006-05-21 10:59 ` Andrew Morton
2006-05-21 11:44 ` Nick Piggin
2006-05-21 11:52 ` Nick Piggin
2006-05-22 9:24 ` Mel Gorman
2006-05-22 9:28 ` Mel Gorman
2006-05-22 9:06 ` Mel Gorman
2006-05-22 9:51 ` Nick Piggin
2006-05-21 11:53 ` Nick Piggin
2006-05-22 8:18 ` Andy Whitcroft
2006-05-22 9:37 ` Nick Piggin
2006-05-22 9:52 ` [PATCH 0/2] Zone boundary alignment fixes, default configuration Andy Whitcroft
2006-05-22 9:53 ` [PATCH 1/2] zone allow unaligned zone boundaries add configuration Andy Whitcroft
2006-05-22 9:53 ` [PATCH 2/2] x86 add zone alignment qualifier Andy Whitcroft
2006-05-25 11:19 ` [PATCH 0/2] Zone boundary alignment fixes, default configuration Andy Whitcroft
2006-05-31 0:13 ` [stable] " Chris Wright
2006-05-31 11:41 ` Nick Piggin
2006-05-31 12:08 ` Andy Whitcroft
2006-05-31 17:42 ` Greg KH
2006-05-31 17:16 ` Andy Whitcroft
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=4470417F.2000605@yahoo.com.au \
--to=nickpiggin@yahoo.com.au \
--cc=akpm@osdl.org \
--cc=apw@shadowen.org \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
--cc=stable@kernel.org \
/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