Received: by 10.192.165.156 with SMTP id m28csp395688imm; Wed, 11 Apr 2018 00:28:35 -0700 (PDT) X-Google-Smtp-Source: AIpwx48T/zC4jYbD6afCPwXGlBi7RrxP5e8nIcmac1Htyhc/sIfM9Sap4LIR1jtPcdmLbYja6tLY X-Received: by 2002:a17:902:5985:: with SMTP id p5-v6mr3911690pli.74.1523431715312; Wed, 11 Apr 2018 00:28:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523431715; cv=none; d=google.com; s=arc-20160816; b=XGsfZiNH+hVhMTo+uV2Wf93a6FEzAcuW9G2YHfR+Xcizc51X4ATPwE88PkKW8QVnVB WIw7T5P20l76JYJFEUFFb/AQGPVkZpk2sd8OonhzccAcTMMuK8UCsfelnmcPQiGnsAJG loMKVRTp7aCq5p61P8yrdgecT+brbK3AWLBP1ueBEe5vN2wShDH6V1681VrHmJjU0+Aa SuynZ+WwThsErpFaVwO6NAr6lMQoICwhzJuW8QN1objhph+rJWzE656PYtwpeEjbJqFa dAaLR+7mDS+NaBIJf5fO16UQK+sgUKS705Q1cdiACaf3c9DFX3Z/hP9U8/Xo8+aL5keA /y5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=MCRSDxqii34Tpn/Lt0Gl3cTBKHT9DL9NvZuUQKn48/c=; b=VJKcvMlSwLBCEcnoy8GXoCLQoNuO85g3Vq8mnZBMypthX2y+byb6F+n0oePyjtODax h9uLowWFz/Rmq1Iz9CwJTiLfXC/ACDHRt2mYwas90WkiIqwbkuMPUp0gkyvNsGuRoz0D HA35QaiW60FMJlGbUz1Yd1hE020ROE0Rljn9DU9kfZnY7u4i4QW/uuflCFqo7fkCCU2v 0UPtNpmHPYRzDyBs4XBDulGbqQ1f2H+YjtKFlp8pNXLkVQwPhzpJXEdDUihAG34v4J1D d+nuC+TmwqvE6K4FhyLAqGqb9Wx9cMx+nqg+X2hsw/AtwQ0VBxZuOirY7sPd6cyFgAOg wa7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Uhema1d4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l9si359986pgs.673.2018.04.11.00.27.58; Wed, 11 Apr 2018 00:28:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Uhema1d4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752751AbeDKHYQ (ORCPT + 99 others); Wed, 11 Apr 2018 03:24:16 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:36185 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751553AbeDKHYO (ORCPT ); Wed, 11 Apr 2018 03:24:14 -0400 Received: by mail-pf0-f194.google.com with SMTP id g14so518766pfh.3 for ; Wed, 11 Apr 2018 00:24:14 -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=MCRSDxqii34Tpn/Lt0Gl3cTBKHT9DL9NvZuUQKn48/c=; b=Uhema1d4pCjI4KXcnBZHrpxl6TN4RktEoMuc4/gwqweX61NPwo3gQ394se2cVS0pja 1s0w8QuchmNHX4ZoT5Md86cW7NheBip+/hrLZTFK/qC8/iz9rDubh1SVv9kmCgIEpuex q5GJbgYmTd02KsGUWGKq5EBMkGiSJvvT5vmx222a/NPOdkEjkRRx31XxCX2xxHuDbZko Uqzr1ulxv8nhyx+nBcezxDsN+5T36yQ9UE+HLvJk6F/hDpYpWuH6h1xjXfl3dgoMTbPl PKe0GeiD5Rb1grg7Z4geg1njEeDmMPCpZAnd6o2C4kNQ4va93cL/FjAdC0rdrjH5sfWa 7e2Q== 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=MCRSDxqii34Tpn/Lt0Gl3cTBKHT9DL9NvZuUQKn48/c=; b=r5pavPFxd0aq9btV4nN8KbrSFw3e3JAQuPiXP9MTenF3Wkk92DtLb9wq/eTImvI9hO C8JHwPwrTQiYKUM5rurnQOkA4XitR1lMrjAgU99iSMiC4F5qL3OQ/Ef9px0ahvPYhHe3 X6I9hkurfGJYjJ3m9sfb6Xfb7HBG1zdlCfhUuhA04lSTuIxKDVtMgcIH4wzavKLZBXwU bXQFoiYO3VtQsxzWNeE1A0Nyf+35IJkkRMmI1JhtV/d0Fr9GcNmYgNniatjBFbsH9RSj TsVI/MCyKGxIkuT6anIXsNLZn1RcF9ey5x0BAb0bA1DOGvpLctfVB8Jvj8WsxC3f3QSz MPvQ== X-Gm-Message-State: ALQs6tDnnUjEiQdmDaJhykqVN/dmPjr6MDjuJEdmz6phlFEMINTcbQTR OyBQgDQww4dPkrHI5yhBkxE= X-Received: by 10.99.117.79 with SMTP id f15mr2642096pgn.47.1523431454282; Wed, 11 Apr 2018 00:24:14 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id o90sm1561898pfj.102.2018.04.11.00.24.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Apr 2018 00:24:13 -0700 (PDT) From: Jia He To: Russell King , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Andrew Morton , Michal Hocko Cc: Wei Yang , Kees Cook , Laura Abbott , Vladimir Murzin , Philip Derrin , AKASHI Takahiro , James Morse , Steve Capper , Pavel Tatashin , Gioh Kim , Vlastimil Babka , Mel Gorman , Johannes Weiner , Kemi Wang , Petr Tesarik , YASUAKI ISHIMATSU , Andrey Ryabinin , Nikolay Borisov , Daniel Jordan , Daniel Vacek , Eugeniu Rosca , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jia He , Jia He Subject: [PATCH v8 6/6] mm: page_alloc: reduce unnecessary binary search in early_pfn_valid() Date: Wed, 11 Apr 2018 00:21:57 -0700 Message-Id: <1523431317-30612-7-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523431317-30612-1-git-send-email-hejianet@gmail.com> References: <1523431317-30612-1-git-send-email-hejianet@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 c40297d..426db40 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_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) -- 2.7.4