From patchwork Fri Jun 29 02:29:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10495541 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 96626602B3 for ; Fri, 29 Jun 2018 02:31:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E3892A6B0 for ; Fri, 29 Jun 2018 02:31:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F4F52A6E0; Fri, 29 Jun 2018 02:31:12 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0979B2A6B0 for ; Fri, 29 Jun 2018 02:31:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 170E96B026B; Thu, 28 Jun 2018 22:31:11 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 120D06B026C; Thu, 28 Jun 2018 22:31:11 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 037CD6B026D; Thu, 28 Jun 2018 22:31:11 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f198.google.com (mail-qk0-f198.google.com [209.85.220.198]) by kanga.kvack.org (Postfix) with ESMTP id CCC516B026B for ; Thu, 28 Jun 2018 22:31:10 -0400 (EDT) Received: by mail-qk0-f198.google.com with SMTP id d64-v6so7807450qkb.23 for ; Thu, 28 Jun 2018 19:31:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=ANjZSVV6/FyPAnL6DgFx6fAokkehXedgEm1vEVKqb5Q=; b=VQeMjZpvCCiQqzV5faNBOZBlZ3qqFMJUKaFFjhWbDlDRlxD+E56JJEloMasbnEOWrN k62R0Zr66wzFsTbhe3Bgach3y5qQrdeL9SKVGSin1q3UtrEUkJk3K+x44g8mfUl3MhTo YutNbjn8yqwa12HTfBVOX0l8qimJPhFnhbLs9/G3zpZLur2C2XSdVbMrX69zRAWT+uZF HH1+t9Kp5NlsgkBb6Zi1lQEny0wIL9q47vVsxsuSnQvgQ7hOseUnrphbJVf8m2guw7M3 bBxVrreUtWIm8p78M1fQE6yVCfkZTYM1cPigATySaaIgiS27eydqjI32l7OUt/gAv7wc uxhg== X-Gm-Message-State: APt69E0qv7EZZB7cHD6yspXyWZV/n/4CeF21tmDagwQop7rqRcnOs8j4 Fk6Vwt1bWsHTqB0wEbh0DksOz6YE8uRwQ70ub2LQkh0usBRRo0DmkNG7npIqdXgJFEvpqn4qgJr 6LFpKkFKz647Mo5JuvC2kk/TItlO7z8XOc56JhYJh1bM+BQbdzRy+VbkiX1uQ4GvmRDcQJ1u9j4 uDP7ZU56qGGTjqPpXUCwOD7EF3DYaez9TGzLcuQWARYEf6g+WtkrvBGDGeWeL39D8OuGbxvwcDE dOE2lf/1ylUMIiarQWBxIe7q2pL9G5cK4ShqsCdCx+xaRSC/PD3xfa4umlosdvJAbhfmBEpnVRw ajeYe7F2GUdiZXix9PcULvHhMxMwvaFCOL1eH10UaGDnDdphPiV/hWbNwwM+p3KaeQKzlSskuSG d X-Received: by 2002:a37:81:: with SMTP id t1-v6mr10983233qkg.152.1530239470624; Thu, 28 Jun 2018 19:31:10 -0700 (PDT) X-Received: by 2002:a37:81:: with SMTP id t1-v6mr10983219qkg.152.1530239470151; Thu, 28 Jun 2018 19:31:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530239470; cv=none; d=google.com; s=arc-20160816; b=EflSz6/m+M549Jq5KAMTRysBl1tb+/5GOA2onL753k9bxuOTp7dSSBLCE6KPzh7CyO lDwnhBMa6GtUHJWAQwv+2XFlyXNrEpfbL4cnY1dDneTo4lipDPRTRx7iniWHSN6J+PLp jn0ccsDI9GHhJpmAyo3/eRko5zqaSF86waNN6gplYudjXJuBTA/2X2d/bhgcaS6LZf7h KuPVHULR0+cqrgkClIgROMtQHeUCPMVGnrEqWUgfxmNy2ni73wbT5sCDWiYgbe59f0Eu LF5LDbeXlmM1epJiydPgf7W1N985cemC1RDcD4e3jICjkV8V8oIkp1RgDe0tbE8VbXNw raZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=ANjZSVV6/FyPAnL6DgFx6fAokkehXedgEm1vEVKqb5Q=; b=j6pLauGd8ecTuikTXnfVsFqDQ4fJI0n6H3goD60ahWfaWp+GLLCr+gdMUmQhvP9DP4 R7MurZjaRbVniu4WRJenbNEbbv5MsTm3JuAlvs1KTZdVfgKHqsKmCS157sICeQMlrHKU 81eXhjICB/j7lUAwHSLrYp0cJsO1I6N0Jy/X/vnump4TfnGVgZKxlbmrKr9UFnxP/ziA 4XCnG5q6bBr0e1Zq+l7syRxBEspgu4TC17ssZ/F0wL9nB96fqDH3706jdJutElCAfdn1 gWzCTZ7VYbovN9s2gne5XZtBx+rTDpD0ocbYH4muDs6h6umxkbaI0IHRES2e9M1YJ/Te 7cag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vN9ycXl2; spf=pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=hejianet@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 9-v6sor4314705qkn.40.2018.06.28.19.31.10 for (Google Transport Security); Thu, 28 Jun 2018 19:31:10 -0700 (PDT) Received-SPF: pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vN9ycXl2; spf=pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=hejianet@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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=ANjZSVV6/FyPAnL6DgFx6fAokkehXedgEm1vEVKqb5Q=; b=vN9ycXl286nY/2K+lgChPocmWSDFrhtmMiDEQv9FC7mLuogqARnTsteWxWBhLRPmo1 6cOScxrrSa9tebr3VOj5rPmL5F42O+sxJP2LSM/VpQwtc/eNbPRRQIugABLUEUzAMHNf dv0UK0SLyVxqrIRPvyKC/BoDw+zl83vBsKLzBvV3g3YbA54Z0UgXtsv8imoTak+am3hA i81x+u8H53LiEs+dMovYfbr3F0+C0/7G/IKCJ5LbAlZ6TQB+bBxJbMi+/C7LUWV5ZH/g 8YsogGNnZIdo32UEMHX2cJM/oOqpKf5iQRgebPxQJ6Ynpt51U0rPOSQ4y71mvxsmaymF 9TDQ== X-Google-Smtp-Source: AAOMgpfJCiGO8W5evQ545apAUKCPxpTYPKw0zAlJvN5wwtaoI18P3088z5Ca5uhYVEShMMCTZf8KtA== X-Received: by 2002:a37:cf43:: with SMTP id e64-v6mr6247099qkj.68.1530239469971; Thu, 28 Jun 2018 19:31:09 -0700 (PDT) Received: from ct7host.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id y25-v6sm6390186qtc.48.2018.06.28.19.30.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 19:31:09 -0700 (PDT) From: Jia He To: Russell King , Andrew Morton , Michal Hocko , Catalin Marinas , Mel Gorman , Will Deacon , Mark Rutland , "H. Peter Anvin" Cc: Pavel Tatashin , Daniel Jordan , AKASHI Takahiro , Gioh Kim , Steven Sistare , Daniel Vacek , Eugeniu Rosca , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mm@kvack.org, James Morse , Ard Biesheuvel , Steve Capper , Thomas Gleixner , Ingo Molnar , Greg Kroah-Hartman , Kate Stewart , Philippe Ombredanne , Johannes Weiner , Kemi Wang , Petr Tesarik , YASUAKI ISHIMATSU , Andrey Ryabinin , Nikolay Borisov , richard.weiyang@gmail.com, Jia He , Jia He Subject: [PATCH v9 6/6] mm: page_alloc: reduce unnecessary binary search in early_pfn_valid() Date: Fri, 29 Jun 2018 10:29:23 +0800 Message-Id: <1530239363-2356-7-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530239363-2356-1-git-send-email-hejianet@gmail.com> References: <1530239363-2356-1-git-send-email-hejianet@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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..ac34238 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)