From: Mark Salter <msalter@redhat.com>
To: Michal Nazarewicz <mina86@mina86.com>
Cc: David Rientjes <rientjes@google.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Catalin Marinas <catalin.marinas@arm.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arm64: fix MAX_ORDER for 64K pagesize
Date: Fri, 20 Jun 2014 13:37:14 -0400 [thread overview]
Message-ID: <1403285834.755.39.camel@deneb.redhat.com> (raw)
In-Reply-To: <xa1tfvj01z57.fsf@mina86.com>
On Thu, 2014-06-19 at 21:24 +0200, Michal Nazarewicz wrote:
> On Thu, Jun 19 2014, Mark Salter <msalter@redhat.com> wrote:
> > On Tue, 2014-06-17 at 20:32 +0200, Michal Nazarewicz wrote:
> >> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> >> index 5dba293..6e657ce 100644
> >> --- a/mm/page_alloc.c
> >> +++ b/mm/page_alloc.c
> >> @@ -801,7 +801,15 @@ void __init init_cma_reserved_pageblock(struct page *page)
> >>
> >> set_page_refcounted(page);
> >> set_pageblock_migratetype(page, MIGRATE_CMA);
> >> - __free_pages(page, pageblock_order);
> >> + if (pageblock_order > MAX_ORDER) {
> >> + struct page *subpage = p;
> >> + unsigned count = 1 << (pageblock_order - MAX_ORDER);
> >> + do {
> >> + __free_pages(subpage, pageblock_order);
> > ^^^^^^^
> > MAX_ORDER
>
> D'oh! I'll send a revised patch.
>
> >> + } while (subpage += MAX_ORDER_NR_PAGES, --count);
> >> + } else {
> >> + __free_pages(page, pageblock_order);
> >> + }
> >> adjust_managed_page_count(page, pageblock_nr_pages);
> >> }
> >> #endif
> >> --------- >8 ---------------------------------------------------------
> >>
> >> Thoughts? This has not been tested and I think it may cause performance
> >> degradation in some cases since pageblock_order is not always
> >> a constant, so the comparison may end up not being stripped away even on
> >> systems where it's always false.
>
> > This works with the above tweak. So it fixes the problm here, but I was
> > not sure if we'd get bitten elsewhere by pageblock_order > MAX_ORDER.
>
> This is always a possibility, but in such cases, it's a bug in CMA.
> I've tried to keep in mind that pageblock_order may be greater than
> MAX_ORDER when writing CMA, but I've never tested on such a system.
>
> > It will be slower, but does it only gets called a few time at most at
> > boot time, right?
>
> Yes. The performance degradation should be negligible since
> init_cma_reserved is hardly a critical path and is called at most
> MAX_CMA_AREAS times which by default is 8. And I mean it will be slower
> because it will have to perform a branch.
>
I ended up needing this (on top of your patch) to get the system to
boot. Each MAX_ORDER-1 group needs the refcount and migratetype set so
that __free_pages does the right thing.
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 02fb1ed..a7ca6cc 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -799,17 +799,18 @@ void __init init_cma_reserved_pageblock(struct page *page)
set_page_count(p, 0);
} while (++p, --i);
- set_page_refcounted(page);
- set_pageblock_migratetype(page, MIGRATE_CMA);
-
- if (pageblock_order > MAX_ORDER) {
- i = pageblock_order - MAX_ORDER;
+ if (pageblock_order >= MAX_ORDER) {
+ i = pageblock_order - MAX_ORDER + 1;
i = 1 << i;
p = page;
do {
- __free_pages(p, MAX_ORDER);
+ set_page_refcounted(p);
+ set_pageblock_migratetype(p, MIGRATE_CMA);
+ __free_pages(p, MAX_ORDER - 1);
} while (p += MAX_ORDER_NR_PAGES, --i);
} else {
+ set_page_refcounted(page);
+ set_pageblock_migratetype(page, MIGRATE_CMA);
__free_pages(page, pageblock_order);
}
next prev parent reply other threads:[~2014-06-20 17:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-11 21:33 Mark Salter
2014-06-11 23:03 ` David Rientjes
2014-06-11 23:04 ` David Rientjes
2014-06-12 13:57 ` Mark Salter
2014-06-17 18:32 ` Michal Nazarewicz
2014-06-19 18:12 ` Mark Salter
2014-06-19 19:24 ` Michal Nazarewicz
2014-06-20 17:37 ` Mark Salter [this message]
2014-06-23 19:40 ` [PATCHv3] mm: page_alloc: fix CMA area initialisation when pageblock > MAX_ORDER Michal Nazarewicz
2014-06-23 21:10 ` Mark Salter
2014-06-19 19:53 ` [PATCHv2] " Michal Nazarewicz
2014-06-20 13:54 ` Christopher Covington
2014-06-20 15:48 ` Mark Salter
2014-06-20 16:36 ` Michal Nazarewicz
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=1403285834.755.39.camel@deneb.redhat.com \
--to=msalter@redhat.com \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mina86@mina86.com \
--cc=rientjes@google.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
Powered by JetHome