From patchwork Fri Jun 20 17:37:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salter X-Patchwork-Id: 4391341 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 71B26BEEAA for ; Fri, 20 Jun 2014 17:39:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A077220351 for ; Fri, 20 Jun 2014 17:39:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D102E202FE for ; Fri, 20 Jun 2014 17:39:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wy2kz-0005J9-H9; Fri, 20 Jun 2014 17:37:45 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wy2kv-0005EL-Be for linux-arm-kernel@lists.infradead.org; Fri, 20 Jun 2014 17:37:41 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5KHbF8L026039 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Jun 2014 13:37:15 -0400 Received: from [10.3.113.76] (ovpn-113-76.phx2.redhat.com [10.3.113.76]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5KHbEKF029624; Fri, 20 Jun 2014 13:37:14 -0400 Message-ID: <1403285834.755.39.camel@deneb.redhat.com> Subject: Re: [PATCH] arm64: fix MAX_ORDER for 64K pagesize From: Mark Salter To: Michal Nazarewicz Date: Fri, 20 Jun 2014 13:37:14 -0400 In-Reply-To: References: <1402522435-13884-1-git-send-email-msalter@redhat.com> <1403201524.32688.62.camel@deneb.redhat.com> Organization: Red Hat, Inc Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140620_103741_443538_E5597DC2 X-CRM114-Status: GOOD ( 26.10 ) X-Spam-Score: -5.0 (-----) Cc: Catalin Marinas , Marek Szyprowski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, David Rientjes X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, 2014-06-19 at 21:24 +0200, Michal Nazarewicz wrote: > On Thu, Jun 19 2014, Mark Salter 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); }