Received: by 10.213.65.68 with SMTP id h4csp245893imn; Tue, 3 Apr 2018 19:59:18 -0700 (PDT) X-Google-Smtp-Source: AIpwx48OFqMWIZQPTh0XnK2UPmevljzlx4KztsmG0l2FzMrjCoPwEIgg8k0vKxKHDcl5eQ9pC70R X-Received: by 10.101.74.69 with SMTP id a5mr11097703pgu.32.1522810758331; Tue, 03 Apr 2018 19:59:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522810758; cv=none; d=google.com; s=arc-20160816; b=BRuTs2PeDNo7ysMJP20CiX/lJLXxBYuvcT2KhUJK4cCaEZ6r1QfeEFBrlpyWmnkkki yGf2SszjFHOhM+7K+AXNYVlnNieaKUf82fm0W37V9dP3300PpLsKzN1MsppeNfdNzj8T 6zOu9zS9yAeGJewMFstBHBgws+IhMnlMNfIWCqMklig2Td0BKH2Qhyykre0rOlJtYdGR vNKYvuE0qh2bPLAF9U6WI8brm/4gGBW/4qz8/fuQPh5X6EP730TR2Esq/H0EgdlSlQnM YqLX1l2EdfI/o8KgodAALKzWMKWba1tjJGQH7/1aYsiFLFMYj4uO+m08HrEHI8/wMi1a RhgA== 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=ieW6Yp/ttHGGz0nzBCjYHSwJcIZ2bSoQtdoURi3Cslk=; b=iLMTq4zLtrmA4w3FXYrtlK4+OQiVGENH4Y1wvUy8ExPs3KCmosKycg8XXVid7jtWDc TsR6MVbW7hRWnGjMizKb93Q4JTvW0E7Wj35uGCcYb2RjL/QGKgiAEnmXc/sCN2iF6EwW 56Y3UTnUiMHDJilUc7dR8xdoV9Vxs+k5VACELJ99NtWNMyUtSUHOw8ujk4ST/BPAFwr7 VlLaakZ4AN9FM5Zg2xGPCejhbrKxnGUCtBcRn/DUg/yYfB+3IeSIgZH9i36LflWRQt8x 4iQzrl671MbluhMfRvq6ALsclEwW2Wf1nwS1U1mDjDskKYdkdidvZN0EADzk2HMuzI4u 7Lvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=X8CtjIxp; 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 b17si2902294pgu.407.2018.04.03.19.59.04; Tue, 03 Apr 2018 19:59:18 -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=X8CtjIxp; 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 S1753658AbeDDC5f (ORCPT + 99 others); Tue, 3 Apr 2018 22:57:35 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:46912 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752883AbeDDC5e (ORCPT ); Tue, 3 Apr 2018 22:57:34 -0400 Received: by mail-pl0-f66.google.com with SMTP id 59-v6so9311935plc.13 for ; Tue, 03 Apr 2018 19:57:34 -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=ieW6Yp/ttHGGz0nzBCjYHSwJcIZ2bSoQtdoURi3Cslk=; b=X8CtjIxp2D8HtC/9n0HyruQe9pjwR5enFq8cFXRmzUdb/Wiiqc8HKBAhPmqSeWEL3h gcZ0FrrlbOwqUqcrj8f0+F0I78xdiYenNQ5O/NVMkSnRjNvqUyO7o8FGA+wgZBtNHLoS ocGlWqqVZnWiET5FrkXEWSkaG2J+HcbJ8cJWuf16pOkME4ru2StmOylU/+P3Lg8I/8OT ISadhNQsfq3Jo4/UgyAnHESPaGh/4eH0U6fubswJ+dqbm7WvYONUdyKJlXX5dvW0AlD5 j3o32Uu0KcfIDWjKjxeJ3X5OcfUridL0HA5ZwtwKD8QgtRwes5mvrkAZHRPF3QaP0eG5 aVEg== 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=ieW6Yp/ttHGGz0nzBCjYHSwJcIZ2bSoQtdoURi3Cslk=; b=EewO2R6+0TYCUCuYGxSli4ECm+ii5gFyZ7XPjV6s0rjwRw2jZfrgavld4uzriOrGN0 QasogiTacf/GdirdKPpLtdahUsvi0x6DjwgDMc4UUCkfM+taz62Zo16qPLXgBQ01mJlr UpFvVxMtiALZFhJMQork5ZEfXahlDM4bmWe92W4rKYcBgp6uH8OEJEuBL8s5/i9s/2sN t0W56tUo1q884fuy757yzyIZ1UR9hQuxBH/kmAfJqRQos4z9iDn2uJKEuAS331rRCxzv NH0LLkcT0UVOYYDqd6ic2fiOGTiHFPHH5SxTrUj2AN/brB64iOJ5D0AzKU/N0CSRkjh0 oJUQ== X-Gm-Message-State: AElRT7GaC2RVdH65fp9eMLl7n1V0f4sil0lY9E0ZeO+1o5lBCrCZJPR9 ugoPp8xJjP5zX1vT5wbdBb8= X-Received: by 10.101.99.149 with SMTP id h21mr10914642pgv.345.1522810654256; Tue, 03 Apr 2018 19:57:34 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id a4sm8020701pfj.107.2018.04.03.19.57.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Apr 2018 19:57:33 -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 v6 4/5] arm: arm64: introduce pfn_valid_region() Date: Tue, 3 Apr 2018 19:56:18 -0700 Message-Id: <1522810579-7466-5-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522810579-7466-1-git-send-email-hejianet@gmail.com> References: <1522810579-7466-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 pfn++ is still in the same region. Thus we can avoid do the slow binary searches. Currently it only improve the performance on arm/arm64 and will have no impact on other arches. Signed-off-by: Jia He --- include/linux/arm96_common.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/arm96_common.h b/include/linux/arm96_common.h index 2f4dea4..bb86bd3 100644 --- a/include/linux/arm96_common.h +++ b/include/linux/arm96_common.h @@ -48,5 +48,29 @@ ulong __init_memblock memblock_next_valid_pfn(ulong pfn) return PHYS_PFN(regions[early_region_idx].base); } EXPORT_SYMBOL(memblock_next_valid_pfn); + +int pfn_valid_region(ulong pfn) +{ + ulong start_pfn, end_pfn; + struct memblock_type *type = &memblock.memory; + struct memblock_region *regions = type->regions; + + if (early_region_idx != -1) { + start_pfn = PFN_DOWN(regions[early_region_idx].base); + end_pfn = PFN_DOWN(regions[early_region_idx].base + + regions[early_region_idx].size); + + if (pfn >= start_pfn && pfn < end_pfn) + return !memblock_is_nomap( + ®ions[early_region_idx]); + } + + early_region_idx = memblock_search_pfn_regions(pfn); + if (early_region_idx == -1) + return false; + + return !memblock_is_nomap(®ions[early_region_idx]); +} +EXPORT_SYMBOL(pfn_valid_region); #endif /*CONFIG_HAVE_ARCH_PFN_VALID*/ #endif /*__ARM96_COMMON_H*/ -- 2.7.4