Received: by 10.213.65.68 with SMTP id h4csp1929334imn; Sun, 1 Apr 2018 19:35:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx49az1AsVzvj2Mx36WpsyhcieB5axuBeAynXJJ4qE+hd/RKn9KUJF/3cOqa6bNMBZb0mrDKv X-Received: by 2002:a17:902:8d84:: with SMTP id v4-v6mr7961093plo.215.1522636510813; Sun, 01 Apr 2018 19:35:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522636510; cv=none; d=google.com; s=arc-20160816; b=C67FlvCpMkTWBXObSdG3ptOO9HPmvyjqJj5enfhX2ZNSFpDokzNwMDdfkBGfAy9DXZ wiaHDCiziwez2kAX/Lp0eWqi39UpegOx/P1d4rrRcPhqlhd/RsxUiVn9//V5xlkph0IP ZkPdnRCmG49+FiHHlge5SOAF+rUVKrlKIWSmdlT+tNIzszNptIRXbiHNqdbNdivpniHy Wn26PUjisr1lnoQ5TbS7aziumPyfv+7U5kKQN+nEF/JCE7OMuDckUuT5XPZUolFqI/ln lZIMIFXzzsZwvAAj9ZRntIpAjjlDsF3x75TKo30gsUfPJAwiR0S7HhgWtSkx1qxLACJL N+9w== 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=H4z8XOuAyZ5aJ7cuIi2sr6WxOzbhm/qJcwGCMmQoqMU=; b=jKsGCc2jDY9Fk/6Ub7/idNvAxGvazNYOwhN6jNKNEhAjRcn783XXTalEZV663VMMfk wwBsHD1bc/2dczpL8kPa50Rc0++Y4EFshaBtIU9U6kVJQunYx+9MPEZQim/rGtaQZ589 QKb5/G3ZH7jXZ4XXCjhIWDXMZwLmVW87Yi8R1/sIzAj1Y/TW31O7jjhSijcgJXf9WB+6 5Hw5XyCWw4MliTY8BdqthZcJnpCKgQ5t4HLdtQdbBSaoh6yZuGaIdWpxeZ7pbXsQL9Rr wKqNbiEBeOxPf90RE17SUBvEtzDWrXHB++s3N/Xt8WjA+FQfqmu6qPEPj2reA12USUKU Gyvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E3fdqLJN; 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 67si10232430pfr.239.2018.04.01.19.34.57; Sun, 01 Apr 2018 19:35:10 -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=E3fdqLJN; 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 S1754211AbeDBCdR (ORCPT + 99 others); Sun, 1 Apr 2018 22:33:17 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:42749 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754074AbeDBCdP (ORCPT ); Sun, 1 Apr 2018 22:33:15 -0400 Received: by mail-pl0-f65.google.com with SMTP id g20-v6so3283116plo.9 for ; Sun, 01 Apr 2018 19:33:14 -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=H4z8XOuAyZ5aJ7cuIi2sr6WxOzbhm/qJcwGCMmQoqMU=; b=E3fdqLJNW8PjRZ2U0anLIjJ0AkvFTyX4wfJWhObHmTPNl6gbYzy2H245L5hemQOD/2 3oQ+2q9h1lfbasCS8ucbRsySg3r2yWRK4yLm4h1CE1o3NsF7v4lHajiv2Ftw+5xcDj+Q avcK+TVLQnTwyYVzuAI+2rd97Tyo9YE1cXUpjimThYHfKNahb8FC8gg3w6J9BABZNVVC igNJ/cJb5psMoKZOu4g1dyjQUNgSOQkxcVhx+CFXS8OuCY4qBV3JIMk2jkDCT3jGB6Fm fGcvh33U+AVvm/4kr4pkhIqrgZ61e8FpRvZ+AHx1Gd8N0/0VHKiyi+s/kY6ayN2P9GCv n6Gg== 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=H4z8XOuAyZ5aJ7cuIi2sr6WxOzbhm/qJcwGCMmQoqMU=; b=Jkb7iB6c2IwwXmLHbog2lt09UbrNkZY2UxoWHk075OLVIbS3YJIbDQ6E3JTA4J++Vl iRKLYDd6pacObTkmrCiRpcTvXVXJMt2C3A9zJPRcP6uBE+HufO/CaXFKfa33YeAwmdfq jBTje1bgtjsbSd9w8H1bTYkkbwdG3FTSR6ebYKuW4sN8/B4T3ogJMdKPTrtDWJ7ZXxQi nHPzYB1NMUkGIg4VIR1ch0Hx8iX8htGS97JZVoDVzzCyjndlViCW7AJJTlLLbgM22hpb IcPRvdhEi+mox9RnLUrolvEdfOuKVEvoN6LDsj/6X1eAxemtHi6EKir3L9WAmt8Jkq78 9OKw== X-Gm-Message-State: AElRT7EmkZGH0+AvAxeNolQFP5awUjcoYzDjTKBLKtSA4kuiczrh8SRi SRenqsUGxZ242tVkPUhEa3g= X-Received: by 2002:a17:902:10d:: with SMTP id 13-v6mr7977791plb.266.1522636394739; Sun, 01 Apr 2018 19:33:14 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id t20sm25934371pfh.182.2018.04.01.19.33.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 01 Apr 2018 19:33:14 -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 , Grygorii Strashko , 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 v5 5/5] mm: page_alloc: reduce unnecessary binary search in early_pfn_valid() Date: Sun, 1 Apr 2018 19:30:36 -0700 Message-Id: <1522636236-12625-6-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522636236-12625-1-git-send-email-hejianet@gmail.com> References: <1522636236-12625-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 check pfn++ is still in the same region. Currently it only improve the performance on arm64 and will have no impact on other arches. Signed-off-by: Jia He --- include/linux/mmzone.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index f9c0c46..079f468 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1268,9 +1268,14 @@ static inline int pfn_present(unsigned long pfn) }) #else #define pfn_to_nid(pfn) (0) -#endif +#endif /*CONFIG_NUMA*/ +#ifdef CONFIG_HAVE_ARCH_PFN_VALID +#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