From patchwork Mon Apr 2 02:30:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10319429 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 23F3D60388 for ; Mon, 2 Apr 2018 02:36:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 146CD28D42 for ; Mon, 2 Apr 2018 02:36:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0520128D4E; Mon, 2 Apr 2018 02:36:06 +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 0AF1B28D42 for ; Mon, 2 Apr 2018 02:36: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=TfPjmXP5uPiu1aiRpWFbrqLh1g52LqK45AY50tSlGTM=; b=KG84Qdk1yJG3sM0ALkd+BdLjV0 78Kn3Rd8w5hh1SbqkDr/Sd4dJ7wumIfJamZWkrS4/MXVrDfxS8Nfb5DqwnZZZmzyRyTb2v6xBWp8+ x+oGKoTG6/Sfn/4RPKD0FDIiwWgLFYC8zqJr9NBoKy4v2BceNB+OZbIQb9wX2Dexyb+xsnoswqIGu HfOuNwYf/sZzAi9HoTWe5RTV3sV9wl1JurxRpiwirVk3LmdfyVFteW484npLCRdnBn20ej81Lg+OU qM5bvMARPRZe0bVPxM+GRsjCDQ/evlji80jck9gyD1RqIoL5K5WEP8fLBOp8egFlBxU+G+aKaJPC+ O/FgKhBw==; 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 1f2pJv-0000Fg-Rh; Mon, 02 Apr 2018 02:35:43 +0000 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f2pHb-0006GS-KP for linux-arm-kernel@lists.infradead.org; Mon, 02 Apr 2018 02:33:33 +0000 Received: by mail-pl0-x241.google.com with SMTP id 91-v6so3296835pld.3 for ; Sun, 01 Apr 2018 19:33:15 -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=H4z8XOuAyZ5aJ7cuIi2sr6WxOzbhm/qJcwGCMmQoqMU=; b=E3fdqLJNW8PjRZ2U0anLIjJ0AkvFTyX4wfJWhObHmTPNl6gbYzy2H245L5hemQOD/2 3oQ+2q9h1lfbasCS8ucbRsySg3r2yWRK4yLm4h1CE1o3NsF7v4lHajiv2Ftw+5xcDj+Q avcK+TVLQnTwyYVzuAI+2rd97Tyo9YE1cXUpjimThYHfKNahb8FC8gg3w6J9BABZNVVC igNJ/cJb5psMoKZOu4g1dyjQUNgSOQkxcVhx+CFXS8OuCY4qBV3JIMk2jkDCT3jGB6Fm fGcvh33U+AVvm/4kr4pkhIqrgZ61e8FpRvZ+AHx1Gd8N0/0VHKiyi+s/kY6ayN2P9GCv n6Gg== 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=H4z8XOuAyZ5aJ7cuIi2sr6WxOzbhm/qJcwGCMmQoqMU=; b=uDWZHDYEFJJOz6n27YbOrDSLvNaANlDi5L2oiU2tEpFFqEiZruTN0/LrueS7t8RdXB mMTFa4ujfn0cMhkXOwM8tVlp9uV8w+LN0Ji80rcKbmmxZOdw61fL2AFOcGmXnd7gIxRj B6BS2QhRh65npxmFAaBjve/wRfNBS5wJxvzVpTIk6BkF/Kd2bnytRvPel0jgIMssXumh iNK6q9EY7Y9YF6ZOTA8EZkVijl2zEpPVgWIT9pYxO10cW/K5LaPaHVfHCXlddlynR1Y+ hGfifPE7J2pwhUYcTAlPx/sbjeXUYgOK8CBDUiW5GnAYsfewsAedpqldn2qoUcpSCTgE 7BGA== X-Gm-Message-State: AElRT7H/v4FILIG3opiA+Gj5Za06gpEnRq9C5x3LTDON2JRgxRTbNCwW FVTvKCztWcKzVrG5Pi1s/jI= X-Google-Smtp-Source: AIpwx48mkf+PFwr1nEEqtVi1UdZH+UnGgI3MwHf3SojOqqY6z4yLvtFG3WSBDPkByKSnV2/N/gkckA== X-Received: by 2002:a17:902:10d:: with SMTP id 13-v6mr7977791plb.266.1522636394739; Sun, 01 Apr 2018 19:33:14 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id t20sm25934371pfh.182.2018.04.01.19.33.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 01 Apr 2018 19:33:14 -0700 (PDT) From: Jia He To: Russell King , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Andrew Morton , Michal Hocko Subject: [PATCH v5 5/5] mm: page_alloc: reduce unnecessary binary search in early_pfn_valid() Date: Sun, 1 Apr 2018 19:30:36 -0700 Message-Id: <1522636236-12625-6-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522636236-12625-1-git-send-email-hejianet@gmail.com> References: <1522636236-12625-1-git-send-email-hejianet@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180401_193319_705049_8CA5A32E X-CRM114-Status: GOOD ( 15.43 ) 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: Grygorii Strashko , Wei Yang , linux-mm@kvack.org, Eugeniu Rosca , Petr Tesarik , Nikolay Borisov , Jia He , Pavel Tatashin , Daniel Jordan , AKASHI Takahiro , Gioh Kim , Andrey Ryabinin , Laura Abbott , Daniel Vacek , Mel Gorman , Vladimir Murzin , Kees Cook , Philip Derrin , YASUAKI ISHIMATSU , Jia He , Kemi Wang , Vlastimil Babka , 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 check pfn++ is still in the same region. Currently it only improve the performance on arm64 and will have no impact on other arches. Signed-off-by: Jia He --- include/linux/mmzone.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index f9c0c46..079f468 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1268,9 +1268,14 @@ static inline int pfn_present(unsigned long pfn) }) #else #define pfn_to_nid(pfn) (0) -#endif +#endif /*CONFIG_NUMA*/ +#ifdef CONFIG_HAVE_ARCH_PFN_VALID +#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)