From patchwork Thu Apr 5 08:04:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10323855 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 2C5D46032A for ; Thu, 5 Apr 2018 08:12:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D09A287CB for ; Thu, 5 Apr 2018 08:12:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10CBF28834; Thu, 5 Apr 2018 08:12:44 +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=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM 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 07C85287D5 for ; Thu, 5 Apr 2018 08:12:41 +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=WCVozbcVJZlScp1IvISI6gHAHddXcPVkpSYXP0qfqQY=; b=AnlovHVPXsaEMSk9XMhI38MCb9 0SPhDB6gLJBl5zQfbt9JbFizBAi1LY1QyJ7VN89svGAQvWJAEbmFcWVPoqf6sUozGy+m/OHbIPg+N CPLRplexTz0RPC9dMjy2yE8aJ4dRDvBnahJhgV2F609sZCf7Eelsu2KiobdzlH82R4hE6raX6islR KAYMBjp4o6FuzLrcXBH5uYZjCjQbmO6lS3TZqYNVGFOz+P06jAHvqJGkXrzpT9iUqvEj6HnYZtH2w 5XACTRGHfw0Osjk3Z7ZS2RBBvvxhAOn06Y1O1rYGh807gXyD0C14ZfAkS95zjU3kAWYXuRgqVBawo StPFr/uQ==; 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 1f3zwG-0005MD-SN; Thu, 05 Apr 2018 08:08:08 +0000 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f3zuP-0003wY-K0 for linux-arm-kernel@lists.infradead.org; Thu, 05 Apr 2018 08:06:40 +0000 Received: by mail-pl0-x244.google.com with SMTP id bj1-v6so15626128plb.8 for ; Thu, 05 Apr 2018 01:06:03 -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=Lj8tZiSMyxH885oWcXv9IEvnkVHUu4ZtmfRGhkabDlo=; b=syQHY5PMLKaJG8tFv1kxfitiLnIjYTHX/9wgBIZ1KARwnXQ11/1WYXZe5ZBHEk/h8Z 9lb7jyBLRlgkalijc/jYOQdBgMh3YnfokjQW6GowR2GgyinK3lmJMoTQ7I5ZXhwH+W/F 4MLjq2tm80azxobhYpTFxE0aBGaUu61/bd1P+u/DR21KBkuywak97rRtCJ7/mIPTsUEg dHqcl3dHHz6mIC7RclAxFFl8BWn/4jsPSld70NlXKmakL/NnJ2TG1ReKQplr8Ad90ZtG zNMDI1vgQsSO7iN+1dY9xm+45omIRZXMqdWCTfaS96nCpLbt2AK7/1J/c9FikRUSoX82 tVWw== 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=Lj8tZiSMyxH885oWcXv9IEvnkVHUu4ZtmfRGhkabDlo=; b=Omq55pnkh0PvKb+lmHm2NLuZzDbnigbUhSRZE+qK7j5eqW6Vbq5gFaOE/D06ueQoSc KUBP4NLuiSIlledp7R6LiJETSGbWq3SQDUJU1VtI5He5uGGZkvGtJ3uJ6Qxt+E6TbbHb sU3vRgazB3hZdbn56PQS3L3iGlntyTPEVhoj4oNTrwkkv10nOQaUR5DeJn6B3TH99B0t cF94Ou65tCKtIyTBeJTsfMm5ebomFuq4YNkjGg6tSaG5aiHZWFTVA0z1al7dj/Q91nbn PLV/dz2XZVDqgEfLjsM501lVew9ho4jH3rOMkd/xSqEXBMDnpK6+XSMdjduzLNKTafYA oefA== X-Gm-Message-State: AElRT7H8IcOe7fyvXSmRcBe3QKbebU0so8c3ZP1RK7r9Dabjl5E7CLVS 98R/RBbP2custJtCfsWSKr0= X-Google-Smtp-Source: AIpwx48+6qCYyfYK5xW/PiQrq/7DgW0OzJEtSqWDHGUcAxUQFwLvf6km6OZBwmVVXmosIhMDN0ZNEA== X-Received: by 10.167.130.22 with SMTP id k22mr16467685pfi.73.1522915562393; Thu, 05 Apr 2018 01:06:02 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id 2sm14983690pft.33.2018.04.05.01.05.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 01:06:01 -0700 (PDT) From: Jia He To: Russell King , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Andrew Morton , Michal Hocko Subject: [PATCH v7 5/5] mm: page_alloc: reduce unnecessary binary search in early_pfn_valid() Date: Thu, 5 Apr 2018 01:04:38 -0700 Message-Id: <1522915478-5044-6-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522915478-5044-1-git-send-email-hejianet@gmail.com> References: <1522915478-5044-1-git-send-email-hejianet@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180405_010613_692216_7EFE0EE5 X-CRM114-Status: GOOD ( 16.24 ) 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 41313 us to 24345 us in my armv8a server(QDF2400 with 96G memory). 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 eb56071..ab01bd3 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1271,11 +1271,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_ARCH_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)