Message ID | 1530864860-7671-7-git-send-email-hejianet@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 EDAB6600CA for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 6 Jul 2018 08:16:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DAC7128161 for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 6 Jul 2018 08:16:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB4BC284E9; Fri, 6 Jul 2018 08:16:08 +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 B71E128161 for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 6 Jul 2018 08:16:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B7BF66B026D; Fri, 6 Jul 2018 04:16:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B52E46B026E; Fri, 6 Jul 2018 04:16:06 -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 9F3DB6B026F; Fri, 6 Jul 2018 04:16:06 -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 55DD66B026D for <linux-mm@kvack.org>; Fri, 6 Jul 2018 04:16:06 -0400 (EDT) Received: by mail-pl0-f70.google.com with SMTP id e93-v6so1920888plb.5 for <linux-mm@kvack.org>; Fri, 06 Jul 2018 01:16:06 -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=KBMmQ7uMooPntLDFolqKC/e5XoiNWuRYRv9h+eFjrLvqDKVAErNW3+tpsfHJX7cZf8 SKMLIF0AXEeJzh4tNc7gq8SaJGsSPtqq/iIsyBLWcYEIYaK8dqTSfqbx/+Cuv+hkgiEB 1nEgkY9k+2MhDI2k5EU8xRzdMDgOsTg7RI2rFVRDes8UyOvIk6CnpsIMUj+keQBmG13f rYzHd1VHLlbW3Rh8KJzF/jg8ye7aRoMRfIXGu6DHRyKUd/goAI0dioHfcJvO4d2ESFOB WquNr+O0GYBzRT1CuvsztVYNiBKRmlx5YyJk8OePDO29sN7sOyBe9i7OpRCTqg8VNIuG ZQxA== X-Gm-Message-State: APt69E138AeafCRqG4NP7To0Vp5FqRC8W+McPyHOev+blBeBhubmxCny OZaw53I2IRbnm/Go+JLwP8zobdY0TBcMfswtPbsQXD/zFaZ6myTHpU2BsiYS5fZi7xmVkqxvV3e Lg1sl/fl10dOCC/ODXhjXVIAaermUlgMqKALmoMOmINPWiMyaThEjvzAY/CqiYBl66fXjatEIqv iJI0MrAvZsCijzceKlY+uBdjZn4bTaelcasKy2QkTLHdHdrHiz7uW/eFjkqC6vgrxm+RtEvZHLU VY+1JAEDBGeZmAoj9XMGxbRTtCxnS/7jFYEls2mXgOvIkBXjUnEPLZHNhA2YW69iOktGz2epBWh /F2+OrzukRXlD1UphFBomumlU9abCwCha/gE6A/Mgyf16QftMfDIQEUTW5pv7b1ASw/tC7I6uvQ 9 X-Received: by 2002:a65:4541:: with SMTP id x1-v6mr8360514pgr.26.1530864966038; Fri, 06 Jul 2018 01:16:06 -0700 (PDT) X-Received: by 2002:a65:4541:: with SMTP id x1-v6mr8360484pgr.26.1530864965421; Fri, 06 Jul 2018 01:16:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530864965; cv=none; d=google.com; s=arc-20160816; b=g7vmpYzvoG8GcKXStQyARqNLiWzCgP5eLgsOTItg1YJ38hy6vzGyoH3r+hYrG0MFXy TqpfMWCiYdaNcM1m4JXtXItfJtBzm/+hUW09h5SgBv09ELdButzUZMOY+sFaXiMZL+pj 765ckkNdIguOzubvB4bVauulyDAx8kvMqcMCX6+OkRAFD03q89Vcv4jb2s1jl2r7HyU1 OiG5A1NVYfwbBotzqCAWF8bDb85TIdrP3gYGwXly60CWJUjQ/l2QbxGtu0AwrhbSaGel LxT1dHTawX7+sOW7ogTCksdsO6Y8c5Jan+v/dRVC5eAcO8jqFJ0p8JITo5vi3PTZyVa+ f2vA== 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=PCbcWf6EN1GwQMM9xOv0dbwrQlRW5INDmveOjEy/pdhu9Dn1afp2vkOjOpHWKuPcsY H3MkpLW9qINUZTW+Qy7eThvpcAgwfrS3W9f0PD+6pTSHzNKj5WHufmr2NfyEz9qwUfgn 72NG6VLbKHWjJN47pmhF0+bVChSDA/l1JauiHnWEw+v0QSeep96e65ygvUoCvfsnFncr zlKm6C8VB8vc99CEYQT+a9Wco40aoS7bggGyucxIULtaSNDyTyPuMHfAYGHMrlzju1GV slTrZKZSTSqXDDRlpVztgTO9+kApS/eyqczm4fNK2dWDHPv+PUCkIPB5HKfBi++wJV4Q vTNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IIw54DWk; 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 v11-v6sor2088622pgo.128.2018.07.06.01.16.05 for <linux-mm@kvack.org> (Google Transport Security); Fri, 06 Jul 2018 01:16:05 -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=IIw54DWk; 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=IIw54DWkDXYRccHSMjpmgHB0umWJr2Ggmu4f8zAw+imiWejPJy71zXZiSUN6XPO2CT JGGhx1eu+CGElJchLD3ofpR1UalMrIZpmLSNKdt0MzznsROCSmgepAlomEnz9VWLZ4q7 /TFmyiSU/HR/VyDz9XST+r+F/ErC1lLfPU7Ax05lYu2i3c1tO/MCYub6bbc10Dpk7GrC lLx6LdyVk3CYI+vuJVFdQ/8S4UYjZ2lFnRnrhzKNcnSnujN1chHCru4n6Nr9+tO5+eJr WCl9vnBSE6R74mjAkLelx6lz6x4ma+awSHbEQVHsLT4/TwNRLSgojUc8wP5CM4xbkzLq 7xBg== X-Google-Smtp-Source: AAOMgpdjOsuiY+SR9NWHwZGVIRnLuo6Gg5sF8CUM3ZvEuBK1umTwI1CKDM54XhCmVp/Enw1dYHuH2Q== 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 <hejianet@gmail.com> To: Russell King <linux@armlinux.org.uk>, Andrew Morton <akpm@linux-foundation.org>, Michal Hocko <mhocko@suse.com>, Catalin Marinas <catalin.marinas@arm.com>, Mel Gorman <mgorman@suse.de>, Will Deacon <will.deacon@arm.com>, Mark Rutland <mark.rutland@arm.com>, "H. Peter Anvin" <hpa@zytor.com> Cc: Pavel Tatashin <pasha.tatashin@oracle.com>, Daniel Jordan <daniel.m.jordan@oracle.com>, AKASHI Takahiro <takahiro.akashi@linaro.org>, Gioh Kim <gi-oh.kim@profitbricks.com>, Steven Sistare <steven.sistare@oracle.com>, Daniel Vacek <neelx@redhat.com>, Eugeniu Rosca <erosca@de.adit-jv.com>, Vlastimil Babka <vbabka@suse.cz>, linux-kernel@vger.kernel.org, linux-mm@kvack.org, James Morse <james.morse@arm.com>, Ard Biesheuvel <ard.biesheuvel@linaro.org>, Steve Capper <steve.capper@arm.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Kate Stewart <kstewart@linuxfoundation.org>, Philippe Ombredanne <pombredanne@nexb.com>, Johannes Weiner <hannes@cmpxchg.org>, Kemi Wang <kemi.wang@intel.com>, Petr Tesarik <ptesarik@suse.com>, YASUAKI ISHIMATSU <yasu.isimatu@gmail.com>, Andrey Ryabinin <aryabinin@virtuozzo.com>, Nikolay Borisov <nborisov@suse.com>, richard.weiyang@gmail.com, Jia He <hejianet@gmail.com>, Jia He <jia.he@hxt-semitech.com> 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> 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: <linux-mm.kvack.org> X-Virus-Scanned: ClamAV using ClamSMTP |
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)
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 <jia.he@hxt-semitech.com> --- include/linux/mmzone.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)