Received: by 10.213.65.68 with SMTP id h4csp1652918imn; Thu, 5 Apr 2018 01:08:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/uS9LwcS1OzFepvfpsKM7yx1tWHSIVUnGi4xLtF7ym+YCm9XfJgTXxy6ajMKw06dZD9IUg X-Received: by 2002:a17:902:aa0b:: with SMTP id be11-v6mr12265011plb.36.1522915728152; Thu, 05 Apr 2018 01:08:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522915728; cv=none; d=google.com; s=arc-20160816; b=k+hv28FDrvL7V5qVye610BZlB3UUTobNk0Q+iDK8j+UT31BPZRc+wk3NY3uRy4VxVO sC8L0sPof5/mKM3as/w2xgygXC0z8K2l4LGtQj9/SfajDrot91vYuiYDfgkJl4l0UDy4 cXBE7xYYyw0IX4i5oO7MhNXoU5VSIgQdEEHLdSRQYGfNBh0bS5iNw1ZnMfIeUuLPA0nl 7h08y4NcaOV+74eeAhzirnonvK0RvS+OXW490qhEPhDg8XCqsjrn2HFf8Q8U/k5yIaFb dDurZBSdUxwT+hCOX7aJxOdltpwZzRZiVG3UVZNkWTJf8yJF5plFdtoi/9otJ7dPdS1Q oRHg== 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=Lj8tZiSMyxH885oWcXv9IEvnkVHUu4ZtmfRGhkabDlo=; b=XDBPnB0rj2FJf/wGEI9ibR8BeHOEijklnUs3CxkoiWsiDkihIjQj/mP+PamKkznylO 2WW69YW/6GgK4lEC0mPinmw2p7kbUl7jNxgRguGaxDyPLQM4FHBb8yKshwZYHCSnDgY4 lmrRCQhuikjJXRSby+MwrDo2OwHTNbT4jD0YXi5DHk1Cfcv7WS6qOeTt4ydYLtdCVbZq e0hX+AsmMfpJwbGZxnsPuD9y2G4XSoE0T2YrHve/hqz2yx+m93ybj7hg7hii4ZnUXNJq 0SdLfl3Hn7o/dmWh7YIsWaZoTt60nxfzLIVT90AGYJYcFQwkbhw/Y7I61DTpGyIx3e77 IDiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=syQHY5PM; 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 r20si5766709pff.361.2018.04.05.01.08.34; Thu, 05 Apr 2018 01:08:48 -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=syQHY5PM; 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 S1751976AbeDEIGI (ORCPT + 99 others); Thu, 5 Apr 2018 04:06:08 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:36779 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751952AbeDEIGC (ORCPT ); Thu, 5 Apr 2018 04:06:02 -0400 Received: by mail-pl0-f67.google.com with SMTP id 91-v6so18064490pld.3 for ; Thu, 05 Apr 2018 01:06:02 -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=Lj8tZiSMyxH885oWcXv9IEvnkVHUu4ZtmfRGhkabDlo=; b=syQHY5PMLKaJG8tFv1kxfitiLnIjYTHX/9wgBIZ1KARwnXQ11/1WYXZe5ZBHEk/h8Z 9lb7jyBLRlgkalijc/jYOQdBgMh3YnfokjQW6GowR2GgyinK3lmJMoTQ7I5ZXhwH+W/F 4MLjq2tm80azxobhYpTFxE0aBGaUu61/bd1P+u/DR21KBkuywak97rRtCJ7/mIPTsUEg dHqcl3dHHz6mIC7RclAxFFl8BWn/4jsPSld70NlXKmakL/NnJ2TG1ReKQplr8Ad90ZtG zNMDI1vgQsSO7iN+1dY9xm+45omIRZXMqdWCTfaS96nCpLbt2AK7/1J/c9FikRUSoX82 tVWw== 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=Lj8tZiSMyxH885oWcXv9IEvnkVHUu4ZtmfRGhkabDlo=; b=Xg6NE/JZhOm5N3JfW+yizK+5RpG3q0AsBAJctFNfa+zjL/0pHASsuSATKsBVBAByBG 7fXsShSTLpsLxLwcOgY+SydY84LOAyeYAJOw/pSvn+CdzJbVWJ1X21VrIIZj9O2R+5eP vIdBRgUb/KIZcNSojBtOQSsdkCFHiuQ8a0fGh69hrfM1SLC52zArQKt5wj9ZAt1taCVN YZfrwXpKcHBrtIziSA3B9Iq26J2Al+87HrCvORtBtA/aWktG721xTRy62l5a+h1oza+t 8ekg0kH/iI3qxjw6eajVqhDgE7TnOcHfsGDur32meWf9wflmhEunjv4MCEP5boDYpVt5 DiCw== X-Gm-Message-State: AElRT7GzbHZPpnsoEQEF85+Q14K1F5iVArNJtYYSA7p11sLlGZgZkqQA tAkpycefxB7HWmW80FJ7OLo= X-Received: by 10.167.130.22 with SMTP id k22mr16467685pfi.73.1522915562393; Thu, 05 Apr 2018 01:06:02 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id 2sm14983690pft.33.2018.04.05.01.05.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 01:06:01 -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 v7 5/5] mm: page_alloc: reduce unnecessary binary search in early_pfn_valid() Date: Thu, 5 Apr 2018 01:04:38 -0700 Message-Id: <1522915478-5044-6-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522915478-5044-1-git-send-email-hejianet@gmail.com> References: <1522915478-5044-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 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 eb56071..ab01bd3 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