Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1514842imm; Fri, 6 Jul 2018 01:17:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfigpSLB3x1TGy/0TXbDRb3QDyhYpMJVkO0/G3k5TAdpHet+hr4dOJ6HEoEFiHPod/3L+nW X-Received: by 2002:a63:89c7:: with SMTP id v190-v6mr2411810pgd.194.1530865053245; Fri, 06 Jul 2018 01:17:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530865053; cv=none; d=google.com; s=arc-20160816; b=GX6s7Ot2E+g+i/DEUshMLFbGMCOhTHZLbB9w4fsRwxKyLZm4o30DuYSTT9d0Q1iagE USu6Ct87VrDVXO9cybWhDhceNH8/GpmPNDQZokqkV4cSJal9Ixp0ue10NfmIwcjm5qty N1iqL2R57NjrzAOfONIv//IWl2Dgi2gayvkywrKWszeo8HZwYm6YyPzyhEHY8w3R+ApL /yOzffZ1q4No78SIgdJbYnbu4/PRNnm9tyxO3cFcmrWWnlJYpzEkXKxacaS9m88O7IC9 xAUljMFE5WGmgfK+eh2zxXsURqO7KfxgBAxSGsLG2hV8Yhtt+ezl6AqbYJKp7KR4zBBJ r59A== 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=KBVWoCjiNTgx3OnopaUozpRLlK9tc1muAL6uwtd7eM8=; b=D/eDqQ+qH0NqwrXHe7PDGcBPzSauNAWM8XrUaO9nlYW8Mcna8aiC0abec+K59/vsWw enARacg7a1phNR5zHbUXnzeOVV3GYFjPkCO7iJ4igfvupGpamVriRLuJCO8FmkYBfeVa tW364JIM4Qyz03QIKmkU3r3a5n5iPcSNLieNTJVAQhBbo6p/5cuOJrwbjGchZITEpEU9 pNMlwWiteNpSfMJtnMM6OzphKTcP4AOIOjlYCZYz5O9/hSdyeIv9DQ2HKlImD5bW2pOJ yf3FAS0H3vaqpNBxY3L7RIybbB3/moPZ5lSQENa50w2UsjmZ1uwwE/M5OFQohVyeq8oF 6Aig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IIw54DWk; 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 d19-v6si8669915pfm.226.2018.07.06.01.17.18; Fri, 06 Jul 2018 01:17:33 -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=IIw54DWk; 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 S1754221AbeGFIQI (ORCPT + 99 others); Fri, 6 Jul 2018 04:16:08 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:39134 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753281AbeGFIQF (ORCPT ); Fri, 6 Jul 2018 04:16:05 -0400 Received: by mail-pf0-f193.google.com with SMTP id s21-v6so7798630pfm.6 for ; Fri, 06 Jul 2018 01:16:05 -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=KBVWoCjiNTgx3OnopaUozpRLlK9tc1muAL6uwtd7eM8=; b=IIw54DWkDXYRccHSMjpmgHB0umWJr2Ggmu4f8zAw+imiWejPJy71zXZiSUN6XPO2CT JGGhx1eu+CGElJchLD3ofpR1UalMrIZpmLSNKdt0MzznsROCSmgepAlomEnz9VWLZ4q7 /TFmyiSU/HR/VyDz9XST+r+F/ErC1lLfPU7Ax05lYu2i3c1tO/MCYub6bbc10Dpk7GrC lLx6LdyVk3CYI+vuJVFdQ/8S4UYjZ2lFnRnrhzKNcnSnujN1chHCru4n6Nr9+tO5+eJr WCl9vnBSE6R74mjAkLelx6lz6x4ma+awSHbEQVHsLT4/TwNRLSgojUc8wP5CM4xbkzLq 7xBg== 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=KBVWoCjiNTgx3OnopaUozpRLlK9tc1muAL6uwtd7eM8=; b=Kd/1Fg1zHX0QfwfW/2hzBy3Wy+M6dcIdaw2lTBwvfWLuxGJOwwjlMvLRitXPALX2oR LMt545yvCoMj0YHnuk/WCKmpAFjKrDGhSYI19O1ONCToJSXMeyYCGmj37u5844byyS0W 0sY94jPNjpH48QuouQQBJJxABw5bfgLrHCAMOUZygpIkQH+FqoXOLlQsix7mC0AqX5Sz N0Yd5lqWKyaOilKgC9HQQgrFY/szPB9uyvnjnzA8zKtbOqKgSj2X390evMmwUoMpCuLx hquTXZRRzwmDlBMTx6X2HTXhImhMcRJpa7Drg4ZOi/mgQn7IxKQsU/ZcSoK1c24+NK0S 5EPQ== X-Gm-Message-State: APt69E08OGmLY25rJu8O3O3Oq/CyDxwUrFSWXUhlUh31ye8vpf7CBzHa ync9ey+xEfgMC8P7zwzXkF4= X-Received: by 2002:a63:5d58:: with SMTP id o24-v6mr6961593pgm.349.1530864965186; Fri, 06 Jul 2018 01:16:05 -0700 (PDT) Received: from ct7host.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id c141-v6sm4673049pfc.25.2018.07.06.01.15.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 01:16:04 -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 v10 6/6] mm: page_alloc: reduce unnecessary binary search in early_pfn_valid() Date: Fri, 6 Jul 2018 16:14:20 +0800 Message-Id: <1530864860-7671-7-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530864860-7671-1-git-send-email-hejianet@gmail.com> References: <1530864860-7671-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..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) -- 1.8.3.1