Received: by 10.213.65.68 with SMTP id h4csp247088imn; Tue, 3 Apr 2018 20:00:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx49IgRRWnlZkq7jN9b5poBniWlZzilLo+OEAQhz9kjvG/u4Wr2z+L4Po0Zg4yx8GmP6qHA3v X-Received: by 2002:a17:902:8d97:: with SMTP id v23-v6mr16421400plo.285.1522810847408; Tue, 03 Apr 2018 20:00:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522810847; cv=none; d=google.com; s=arc-20160816; b=eRxiSutjwtjsco2RsaIAL2Jw88WpdGheiUHgFEMm07Dh63DsXUX0Rq+6F6elDAPAv9 QgPbIZ2EkTN7QJO0m/a9Nc7mVYz+T2Z587I3bJrY5jRSlX9CE4u9bZCJ+L4PSzXa1YAA USM0KvAYlNo1aLqT68P6w3QPufMEhiHN+oNITJHpG64Nay6lJWjszwT1fMigsMpGBV2F 7BOXeO3SYSCyi4ds3q0qrkIImH6NnRF04dgrutCgZghFoew5aLEgVqy8C2V+W4Beqkcn AtYQq+8Ka88sKUm3Bvpgr08uu6PGRcYXFOheo/MN2qUM/pSkCNOjSZcOyzb7Cpgx/Y4N 2+2A== 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=ykNuYTs3vQADVQ7BqYp+potI3FMwH8+qeszIvIfF+1w=; b=HQaWrIfo9eY1VAXFANb6pw28VzE1dqK1mRmD4ua1hhAAG3oWHLE3nqlbn5B/YgSMGP MZSA1fjKVebA8aoIIUxo9Qae5aEBxjwJXL6eUugk/UwnsA67yKITDDcsy9tfOJascNGr UPhxR3jW1A3pOe2+bQ684VX0VFX+YsjU0jtW4SNU5iRnOvudLme/ju2Dx+vIiWmObJXw EP79izTTPueTWgWKh9Simr1g51dDov3kj76WXIT1zZJ0/bCnwxnrfuRjg4ZdDU15a89j uwMO1AFR6lv2ar4GFDfaNkERrP3CMiaz+jfhj+jj+OuFNQRWsYszDCqBOTFdPjrLonYs YgJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ihS+op64; 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 a1-v6si2110107plt.693.2018.04.03.20.00.32; Tue, 03 Apr 2018 20:00:47 -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=ihS+op64; 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 S1753824AbeDDC5s (ORCPT + 99 others); Tue, 3 Apr 2018 22:57:48 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:33497 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753747AbeDDC5r (ORCPT ); Tue, 3 Apr 2018 22:57:47 -0400 Received: by mail-pl0-f67.google.com with SMTP id s10-v6so10033064plp.0 for ; Tue, 03 Apr 2018 19:57:47 -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=ykNuYTs3vQADVQ7BqYp+potI3FMwH8+qeszIvIfF+1w=; b=ihS+op64Ie0xSEd3zZ2WW2SYLQq6wvi8BM0DhVcKMyM+QBIuuzSH9lG6L2SpZtc7G/ q2WkigujxgRYzfYjKCmfKltiC+I2CWOHHpqeyaLe6ggPCup5Oq/L1zYrmlhD9rCF/OON yqRHzO6X1jV/4ZnLWdOSycqqvbIzAmgUYtxzMWEJT7icpSsxl7QTiXd2prNlwJjdgUhy 4og8YogEIAZdDh1ujaU5NdgbD4OPcQZnquMk1Zc76Qm1L7hbHjyobT9czF3U7Dkfv5rz tVbSwtvKmJ754HCBFmWNyOGApmARSYhITklHap544cTI6EFk3uHJxVSsWJebPdeDhpZe 4jKQ== 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=ykNuYTs3vQADVQ7BqYp+potI3FMwH8+qeszIvIfF+1w=; b=XV9T5oCnNPaLB9SwVJkvtfIhLtTDKatoUj5KsOUfWST+FEDHmC8yFaIV0+3EIGMP72 rP8uvGnfTHSVKRGpsOXgciK11aQLYuQu3IkJEdilpEAUvlblo0QIo8f+YgBxtUJpsig8 pSH8nZvJfVTue8oW/tXmvA9om8YzXtCNsKz4KaicDSdpVDj550AVyFTLta28IJ2fNGYR 1zCWcsrYSwzYhtQngeESjqRVbHVPGpwhlnq6cEBkClf3O7jd2+UirWHPSZkmY68YnRIB sORd5cHAvfkCfhcUFdYSC1X/VPy0asaRx2uiNXw36ZCGZCcpR6FTXJM8KOOxKcJpCQ/9 HCcw== X-Gm-Message-State: AElRT7Ghz2AmZKijr7fs3NZhOeb2vuam0xUUZQQWGixixW4VCSf1vDxd nFFDKL9NfWgh65tgm3glxEo= X-Received: by 10.98.214.91 with SMTP id r88mr12494616pfg.8.1522810667180; Tue, 03 Apr 2018 19:57:47 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id a4sm8020701pfj.107.2018.04.03.19.57.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Apr 2018 19:57:46 -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 v6 5/5] mm: page_alloc: reduce unnecessary binary search in early_pfn_valid() Date: Tue, 3 Apr 2018 19:56:19 -0700 Message-Id: <1522810579-7466-6-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522810579-7466-1-git-send-email-hejianet@gmail.com> References: <1522810579-7466-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 check pfn++ is still in the same region. Currently it only improve the performance on 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 a517d43..516ffb49 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) -- 2.7.4