Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp427783imm; Thu, 28 Jun 2018 23:43:04 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJGpMu3OLeAaM0qXwQmnsvuJ4S+mnk5XssJ/ATQzUiGF6IrOtnvgaQ0n0FwUIkH8s9hsDKT X-Received: by 2002:a17:902:88:: with SMTP id a8-v6mr13291367pla.156.1530254584876; Thu, 28 Jun 2018 23:43:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530254584; cv=none; d=google.com; s=arc-20160816; b=gRuN728EqdxXGNIMasuNQMCl5UFMN7LZlwaXFZbJTV+zaB2UHZQ/D3x0JGgkwxFmPC i8702vxRCuO3MYKLY3Jpxp9pfxtYiFGA6dzkoWL2TRa6KArSKzWY0872rtuvhgjOYGTz YBQ07BGtAjfw9U76nfJMbpH4guMVEgvad9t8/Csn6rB2ah02qyS/CVOQXiTkZKyxLYSB dns9ELft+xz8P7QQvs597KDROVfeCzVtjGVHqutloVjQx1eR0+YAgHHdF8PRUPORK6Mu tpRrh6oA8kmOYrsanE2K52U2r45/sSH4cyiBm0IlcQkEwr50KnGPJkewMJU57yco8c9S fvWg== 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=ANjZSVV6/FyPAnL6DgFx6fAokkehXedgEm1vEVKqb5Q=; b=Kevlekju7nD+cVERCEb/I1eDZmlxd8ccSzJJIsQjHkwFcde22ESqiVW9F+j5kdB9ZJ 5gwJpL1e0Om6mxdmbSTvyi/0ccM0Xx6yrNsOeNfY36fIhsOR/5YGM16e76wMXxahOGkH uRFZlnbZrqd/FE8cBxYaIjNnT6KSwc3RTWI8hbwbjoT0j/odkYcEJKsLtjJaQje5BQGR 18byi2DDMOk2HyOxFvs3/4jpR6X7UWcLDcD3VQnXRweD52N5L6YvLpj/RAA93G4IxwwS RMx6U6jdjuiM9CLs8AYB2xtR0IpEk/KrvKRqLEeO5xcMZtaOJhkt3/Eu5E3ySITzR6rA TlIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vN9ycXl2; 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 e6-v6si7274934pgq.265.2018.06.28.23.42.50; Thu, 28 Jun 2018 23:43:04 -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=vN9ycXl2; 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 S1030676AbeF2CbM (ORCPT + 99 others); Thu, 28 Jun 2018 22:31:12 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:39996 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030522AbeF2CbK (ORCPT ); Thu, 28 Jun 2018 22:31:10 -0400 Received: by mail-qk0-f196.google.com with SMTP id b129-v6so4177649qke.7 for ; Thu, 28 Jun 2018 19:31:10 -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=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-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=ANjZSVV6/FyPAnL6DgFx6fAokkehXedgEm1vEVKqb5Q=; b=fadYOBjOzL6EqHYxGr9oZJJ/RJZkBa+0KQyENDBz/x2FvDvY/4XmRBAK3E0kk2Ogju MTZYDiCBvq6q/0Z1NsZGgIGkzLjAAo1PH7raCn3tNeCjJY+IQrFzm6AZdhCpSMTf9kH3 mLYrO0q+259vh2rV7J6EvmK/OMhOOKoIV9dicPkkOBuYdeJoUoEQ0wR6Vpwv2xFcSnKA iN0sCTBwgAtnnpA5/Sxw3SQWeGDSnM9IobO5LHJfnwXSmOSmcmcBAcw8AD/jExHB25bI HR9sG5ejpBb9U8MIwrGovkz5u8LhFGS77R+D92M2+KqHjyvRcgcNoGLPzi4Dy2BaTbmf iZ8g== X-Gm-Message-State: APt69E2IywSw29JC9On1ABJnlRwNO5OQdGFqxZ6GflYAQgX8S8JqDJd3 KRPGewBTTbYQm5yrVUlFHgc= 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> 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 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) -- 1.8.3.1