From patchwork Fri Jul 6 09:01:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10511145 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 0B5DC600CA for ; Fri, 6 Jul 2018 09:02:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1B632855E for ; Fri, 6 Jul 2018 09:02:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4C902856D; Fri, 6 Jul 2018 09:02:55 +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 792EB2855E for ; Fri, 6 Jul 2018 09:02:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7387F6B026D; Fri, 6 Jul 2018 05:02:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 710BE6B026E; Fri, 6 Jul 2018 05:02:54 -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 626456B026F; Fri, 6 Jul 2018 05:02:54 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f70.google.com (mail-pl0-f70.google.com [209.85.160.70]) by kanga.kvack.org (Postfix) with ESMTP id 233B16B026D for ; Fri, 6 Jul 2018 05:02:54 -0400 (EDT) Received: by mail-pl0-f70.google.com with SMTP id bf1-v6so4188615plb.2 for ; Fri, 06 Jul 2018 02:02:54 -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=KBVWoCjiNTgx3OnopaUozpRLlK9tc1muAL6uwtd7eM8=; b=DEtUcPHJl9TVU/tGIDoMxJJS4QgAPc9sl4ASHt7eIbBGqvHZrTWdYhXQOV3r6yl5/X Q5ofkc/ZYUwAUIQ1ainPZbgTTnXHGNYHaQ2uRSc7UpLFWAsvS9secNHXjnbcKWOvsvsx Kmp9kQu76BPzMg2NT+ruuc1wEnUueWwkAvsZgxZStPzYLGapwynL3tSUKtNToMSa4flI aiAAGynTqbtO947grY2p6M5w8VisAwIG5cW3p90DCR16JNVgzIA9170Z5Ft6VM1bcDFG DJLDv8kwA/Ho3asjnV8FrWX2D7QlErnPYYURSz56t+RXa0N4cv69K39zikeGk8rjWgQI FJ9A== X-Gm-Message-State: APt69E2CN6yap8yXgEybG5P3bsWwJ2jp6dhs+JffrumyZ3yZNzEM58je LVs1rcQ6ow5VjeDJcvDQnxMPYz6jsfnEHNawwIBUK7KsJHRiggEZ8WRC+VCsGIAUy0yJlP6XYgP dxlhfhymaAQGamtUjGQ3tfjswFTfYHmpS8GfdoPkwjxPUho60ZK5T7ONpqCf6b6Q+tNCwcsNEml okvAZfKp9K4GdhgtFWqgdI25ITVgOR+4u7knUIrEsZVRtnhO14uiWYGaPQx2uUsbGz5GiHCfhTk Xelb1+dHmoJU9QqDcLt/t0b5VeWRtfrVd/QnbGugSB+ko/dWfcN823h+7CpKJv5bSoBxZ8uot33 WTKcJP3IdtRgWeQElciT9mx0vOu65cz8Q1HEnD6hGhhONfWoQgPtkPzrOZza2m2OlHueT+4YYGQ E X-Received: by 2002:a65:4348:: with SMTP id k8-v6mr2475357pgq.341.1530867773836; Fri, 06 Jul 2018 02:02:53 -0700 (PDT) X-Received: by 2002:a65:4348:: with SMTP id k8-v6mr2475317pgq.341.1530867773234; Fri, 06 Jul 2018 02:02:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530867773; cv=none; d=google.com; s=arc-20160816; b=kYgW6eTlSRZv9NcfBewZZAJHnAyGsTNJ97yETKJHYQknaiuNGqaFwsHrZDR6XCQEu/ +1EVAGu+/Y8h1akRqPdL1eTrZuFVC31v9HQeYrYMvA9gZTgPetUuVZkrCpemlvZ//bix RjKMroNLkN/uuCog8mbdhzRAPvkX2SGSC/yx5J414+fwo/pYBNl+vO8XpDDDTt2cpCBi FPBlCEcAymJUfq3Fxn64J3sFLAHga9bUcnZ8XysTgpklemSOjUMN3BYgXAWE2d3+wAX1 DZUsc1g7+WGPHo4HAe1g1b1nRCWHk9QiYvnO+7j67yVEqrDQhDxoe9wjO60w3PuYeZvt 3zKw== 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=KBVWoCjiNTgx3OnopaUozpRLlK9tc1muAL6uwtd7eM8=; b=Rh8J+wYAjKlE9Vk4zSJVkQhm7GI9cjRuFxliQpl6/Rzx+nhgAMpnbsoGKDtLnIPhEl y/jYlrFWYudt60pjU9RenwOztV8zbm9UEiYXEDgw9cflTMzSroWPmThBWR4guIBlLLbA nZW9dqkKBhd/4V+Zc0ryWOAohkLPz6RhIuigiwDVhGftDVbYLEdpHe2j53c1MgfigPRj ISiturEBPjMOlxbu6qGyCemJrGmPQ5NBiN2e9ao14cpWtooo/WKAYRxZGaMWVS5tCUqX VNCOw/waBDqafvRYls3y9YlpLsZNHcKZXp84+lL5LC5rUAQLseoHiuF0vN1veuVKyRRk sMnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IbFIknlz; 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 a137-v6sor2248548pfa.112.2018.07.06.02.02.53 for (Google Transport Security); Fri, 06 Jul 2018 02:02:53 -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=IbFIknlz; 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=KBVWoCjiNTgx3OnopaUozpRLlK9tc1muAL6uwtd7eM8=; b=IbFIknlzuOISLCW8QKOsl5arhgHqijw8hpls1tZ1X+eWQ7jhUs8YYMVvpTUe96mQgs c5BadDGHadOZTEpcs0d+OW9Djn2+iOQn5CPoOu7rH5PbjOajTBTx+km3HuEowOUvWtA1 mT4LeAvRFZMZ1A4+82xcFcZlUt35NYarma/5+iFgFKVw2E9rBmAIhOlFqRrU1qMS+9N/ JRBA97ag1mhrTwPbWVL78n+ZIiOpYQyK5YmJoSpoLIKATZ5x5Tka3MyEEzbd6ehPPQTh UTjMrdmmhB2YhHaqDmvn5P0ITpSIWrWBkpKAJwgqCAgSlHgCsMZqbpnXUYG2FDhIf4SJ q5gQ== X-Google-Smtp-Source: AAOMgpefuXMcTQs2ilg4Vf5rhEn7GIqsVV4ZnoIougF0qHKQtfUKqIuKE1cIao7BmKJF8VuQODSvtA== X-Received: by 2002:a62:ec41:: with SMTP id k62-v6mr9771859pfh.206.1530867772937; Fri, 06 Jul 2018 02:02:52 -0700 (PDT) Received: from ct7host.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id e5-v6sm10837092pgs.59.2018.07.06.02.02.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 02:02:52 -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: [RESEND PATCH v10 6/6] mm: page_alloc: reduce unnecessary binary search in early_pfn_valid() Date: Fri, 6 Jul 2018 17:01:15 +0800 Message-Id: <1530867675-9018-7-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530867675-9018-1-git-send-email-hejianet@gmail.com> References: <1530867675-9018-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..83b1d11 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)