From patchwork Fri Jul 6 09:01:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10511205 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BD1E0603D7 for ; Fri, 6 Jul 2018 09:39:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF0C52855D for ; Fri, 6 Jul 2018 09:39:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2E7A28563; Fri, 6 Jul 2018 09:39:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 51E3A2855D for ; Fri, 6 Jul 2018 09:39:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=br/vp8l1g0UlAL0HTyrHdhXy7fZtGMQb63ZCoxUT27s=; b=ubaK4AsNSJeEreHwZIvcRPoUiF 39Lwb9Di4HOoNDVPOJ0Y9umSTerUaU3Aq1teP4mBFC8eaz7izZhWGcuqomrM8t+JAWBZhPdiBVJzz RsAoSpVDRDFiuwIPYabk4kgm8lDCNGAfv+tWE6umrerTVheWskEL/FWY2pEI/E1fgkXEIotvc+r2C aLZHVfX9QammrrHOFWolrgC8/3DDDJamcoyejJZEO8viY7B3kuukFCPK8vqiMQukPvf0NoEmKEzX7 5bL62+rLNFPMyDodaZ0DizyKCwZ7UMCQ8Z3uMMqeFd1EVZlo/dFqZvsSyzl4Yi6Y3n89S09kFvOFG lGjIr4mw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fbNCi-0006xq-G9; Fri, 06 Jul 2018 09:39:04 +0000 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fbMdr-0002NR-BG for linux-arm-kernel@lists.infradead.org; Fri, 06 Jul 2018 09:03:12 +0000 Received: by mail-pf0-x242.google.com with SMTP id j17-v6so7900289pfn.5 for ; Fri, 06 Jul 2018 02:02:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KBVWoCjiNTgx3OnopaUozpRLlK9tc1muAL6uwtd7eM8=; b=IbFIknlzuOISLCW8QKOsl5arhgHqijw8hpls1tZ1X+eWQ7jhUs8YYMVvpTUe96mQgs c5BadDGHadOZTEpcs0d+OW9Djn2+iOQn5CPoOu7rH5PbjOajTBTx+km3HuEowOUvWtA1 mT4LeAvRFZMZ1A4+82xcFcZlUt35NYarma/5+iFgFKVw2E9rBmAIhOlFqRrU1qMS+9N/ JRBA97ag1mhrTwPbWVL78n+ZIiOpYQyK5YmJoSpoLIKATZ5x5Tka3MyEEzbd6ehPPQTh UTjMrdmmhB2YhHaqDmvn5P0ITpSIWrWBkpKAJwgqCAgSlHgCsMZqbpnXUYG2FDhIf4SJ q5gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KBVWoCjiNTgx3OnopaUozpRLlK9tc1muAL6uwtd7eM8=; b=AaBlUz5ZjGrCi7zIU5nELwCpRAiPkjGPe4i+aK4bOuuwPpKaJsVBUIgooIE8RmWdqA m7kXtA7O6phe87UksjBhpD97UglC4ngsD9lTso68AL1DCJkZJSsU5aDVFQNdXcbWcEzU jodjJT3RIxEUn6eNEqmYfF5p9vc8XjfPONeyoP4M8V/XXs7G4usAs7ZDr58UIfBmcy+6 pO1WkMKHn3rouB13KOekvsXyTVRc4x3KGkUwRYKj2TDpkv/u8byXDCaJ4ZzFNBQFjPrv fRYw3HAONE2AxJxb8aXfM5wYbFqlVpSktg4sDk6ioAq2s7DQkq40uMS9KT549bR3RFJv 3SSQ== X-Gm-Message-State: APt69E2tsqm9iQLDM5yG8tyYd/1QhHR8wMLRoDDYXJekeiOJKb8Sqk0n f5430zBjvd4Uon5LueuixcU= X-Google-Smtp-Source: AAOMgpefuXMcTQs2ilg4Vf5rhEn7GIqsVV4ZnoIougF0qHKQtfUKqIuKE1cIao7BmKJF8VuQODSvtA== X-Received: by 2002:a62:ec41:: with SMTP id k62-v6mr9771859pfh.206.1530867772937; Fri, 06 Jul 2018 02:02:52 -0700 (PDT) Received: from ct7host.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id e5-v6sm10837092pgs.59.2018.07.06.02.02.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 02:02:52 -0700 (PDT) From: Jia He To: Russell King , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Andrew Morton , Michal Hocko Subject: [RESEND PATCH v10 6/6] mm: page_alloc: reduce unnecessary binary search in early_pfn_valid() Date: Fri, 6 Jul 2018 17:01:15 +0800 Message-Id: <1530867675-9018-7-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530867675-9018-1-git-send-email-hejianet@gmail.com> References: <1530867675-9018-1-git-send-email-hejianet@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180706_020304_135545_8EBA5CE4 X-CRM114-Status: GOOD ( 14.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gioh Kim , Wei Yang , linux-mm@kvack.org, Eugeniu Rosca , Petr Tesarik , Nikolay Borisov , Jia He , Pavel Tatashin , Daniel Jordan , AKASHI Takahiro , Vlastimil Babka , Andrey Ryabinin , Laura Abbott , Daniel Vacek , Mel Gorman , Vladimir Murzin , Kees Cook , Philip Derrin , YASUAKI ISHIMATSU , Jia He , Kemi Wang , linux-arm-kernel@lists.infradead.org, Steve Capper , linux-kernel@vger.kernel.org, James Morse , Johannes Weiner MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Commit b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns where possible") optimized the loop in memmap_init_zone(). But there is still some room for improvement. E.g. in early_pfn_valid(), if pfn and pfn+1 are in the same memblock region, we can record the last returned memblock region index and check whether pfn++ is still in the same region. Currently it only improve the performance on arm/arm64 and will have no impact on other arches. For the performance improvement, after this set, I can see the time overhead of memmap_init() is reduced from 27956us to 13537us in my armv8a server(QDF2400 with 96G memory, pagesize 64k). Signed-off-by: Jia He --- include/linux/mmzone.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 57cdc42..83b1d11 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1267,11 +1267,16 @@ static inline int pfn_present(unsigned long pfn) #define pfn_to_nid(pfn) (0) #endif -#define early_pfn_valid(pfn) pfn_valid(pfn) #ifdef CONFIG_HAVE_MEMBLOCK_PFN_VALID extern ulong memblock_next_valid_pfn(ulong pfn); #define next_valid_pfn(pfn) memblock_next_valid_pfn(pfn) -#endif + +extern int pfn_valid_region(ulong pfn); +#define early_pfn_valid(pfn) pfn_valid_region(pfn) +#else +#define early_pfn_valid(pfn) pfn_valid(pfn) +#endif /*CONFIG_HAVE_ARCH_PFN_VALID*/ + void sparse_init(void); #else #define sparse_init() do {} while (0)