Received: by 10.213.65.68 with SMTP id h4csp1929221imn; Sun, 1 Apr 2018 19:34:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/o6jd9JfDb5NLks10TLMwrP+t/0jo0O7RxwMOR6cHI3U7IDj9mOkqjT+g+QcbNDERezF9H X-Received: by 10.98.214.218 with SMTP id a87mr6087152pfl.124.1522636497332; Sun, 01 Apr 2018 19:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522636497; cv=none; d=google.com; s=arc-20160816; b=sB/cETFYTfNbDTyn5YvLNQjy504gqjSJOJgc/GMVLYbAHtCjtsqMEqFJ+eByS7g2u9 mvIB3ry1SnKXvraEVzrD3+VU8AaCp1frp91K9HPlUcsMdBdeQOrWpjKqefrC7lBK/IRD 3b+ow6j0/ne38q75vKEkWDGjeonKyVlEPtlhyat9t+LxTz+IySmFC7HDzLdb+jeh3zuv xmhzQZd5u8C1OTahEjVh/9StPwfHUrtg3ViAoAkovPs8axXLZ93K3FUcxMt5vu/NhRpJ LWKO8ROVarEggVugyeFOy8qIcY81gnWio8Ea12wdq3LYDMaedLtjGbLhg3w6THycKbzJ rXeQ== 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=89tLmX1ioocai1fj4zT7S9JG4pMiMYTIMAUpVpzMpzs=; b=qJVS/0um1kg0YWBR3x5FtzbVztjEelkQLk+ZxtxforqeJIuZOcbaLL+/eSG9jN1egm ixxvq2T2gKCm+iLFfoh2z1ZRljnyzYHgl9cc+X4m7Sl3qU9CrMSY7hAZdj5SYZfC0OlT 4E6YbzAsD4BszX2NjIZCh2vCd19o5a2inBOe15o+yDhECfeGvAzFnoHJk06EzVDseh/P gQ8rsBI62lWvDkcR+C6SKz9XlAUPE523ppuNvlOmjuCHqR167rc9Y5Vl44MZiI7ETz6j VjupsC9tCdnGJsHnhVVWmvY4R3VIbN2ry21cs30iMVs5unvyfB3eeC7tjKly6MbGeqNm MXvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=skE6NEiu; 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 j12si9064783pgf.678.2018.04.01.19.34.43; Sun, 01 Apr 2018 19:34:57 -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=skE6NEiu; 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 S1754192AbeDBCdE (ORCPT + 99 others); Sun, 1 Apr 2018 22:33:04 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:41670 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754074AbeDBCdC (ORCPT ); Sun, 1 Apr 2018 22:33:02 -0400 Received: by mail-pf0-f196.google.com with SMTP id a2so5943162pff.8 for ; Sun, 01 Apr 2018 19:33: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=89tLmX1ioocai1fj4zT7S9JG4pMiMYTIMAUpVpzMpzs=; b=skE6NEiuhET7jDql6dDDLqjuh+B/GpiFe1iYbD7Qu2VA4G8QwYhH6AHhu1BNTrfmmP HsiaOeJe7lYxSUyCGixcBVni5VWi7DAuKn+BLgsebX5adnCVCuzok+bJMwFy7UtsTocK 4dz4ibX1MiYqpPQJU4xpTzkEW9WWIkHw1dW2DM0Qn55uM5RiTiNTbyrQBKeesIzvuEbq 36RwyDRYGC96MAZA7cnKU1FzaumX5Cvq7/qqMNO5uXWI9sT52EZ4DVi3/KFc/8297+tX ZgjFgrfizdgUBnANlZMXFhI3Emr/L8+oOTPs9XWlCd+OGKpzxlRyBEpG3a67mOPeAdCw SPbg== 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=89tLmX1ioocai1fj4zT7S9JG4pMiMYTIMAUpVpzMpzs=; b=FrAyj5jessuJqGyZIerFumK/uTOrt7CpF3YICQpZcZjdrLvEIWWWWmIw3qaOySa5Oi hiJaPzydj9wpmG1nx9nGBbgmv6UdaGO5buQrZUMWODM8iBUyBREhdRNbrZuhbs//1RhY tgJjSVsYxaniCaIqYckS4skz7kdJqAKsCjfHWPrjpvWnYudlw4gB2YdJPa9pDB4m9PsB OappXRscfSVvxSqHyVgkghKmOhOT6GGw3qIQtEneZQaF3I6JSYeemBBeYGSFdVOHjU87 kHM/S+tTK5EUcBIMkaVOlYFM8io759BL2P9t3qVdm3TqqTCBeJRdqt5P2uhngxzHjoRU ei7A== X-Gm-Message-State: AElRT7HLwxG6zT4TkBZ3JmSbv6ghUWc9pcWME13AQKol7mBr+0Ig3yfz eaugZ1RfI7MwDB7MgTicCNk= X-Received: by 10.101.75.202 with SMTP id p10mr5169900pgr.339.1522636382089; Sun, 01 Apr 2018 19:33:02 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id t20sm25934371pfh.182.2018.04.01.19.32.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 01 Apr 2018 19:33: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 , 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 4/5] arm64: introduce pfn_valid_region() Date: Sun, 1 Apr 2018 19:30:35 -0700 Message-Id: <1522636236-12625-5-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 This is the preparation for further optimizing in early_pfn_valid on arm and arm64. Signed-off-by: Jia He --- arch/arm/include/asm/page.h | 3 ++- arch/arm/mm/init.c | 24 ++++++++++++++++++++++++ arch/arm64/include/asm/page.h | 3 ++- arch/arm64/mm/init.c | 24 ++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h index f38909c..3bd810e 100644 --- a/arch/arm/include/asm/page.h +++ b/arch/arm/include/asm/page.h @@ -158,9 +158,10 @@ typedef struct page *pgtable_t; #ifdef CONFIG_HAVE_ARCH_PFN_VALID extern int early_region_idx; -extern int pfn_valid(unsigned long); +extern int pfn_valid(unsigned long pfn); extern unsigned long memblock_next_valid_pfn(unsigned long pfn); #define skip_to_last_invalid_pfn(pfn) (memblock_next_valid_pfn(pfn) - 1) +extern int pfn_valid_region(unsigned long pfn); #endif #include diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 06ed190..bdcbf58 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -201,6 +201,30 @@ int pfn_valid(unsigned long pfn) } EXPORT_SYMBOL(pfn_valid); +int pfn_valid_region(unsigned long pfn) +{ + unsigned long 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); + /* HAVE_MEMBLOCK is always enabled on arm */ unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn) { diff --git a/arch/arm64/include/asm/page.h b/arch/arm64/include/asm/page.h index f0d8c8e5..7087b63 100644 --- a/arch/arm64/include/asm/page.h +++ b/arch/arm64/include/asm/page.h @@ -39,9 +39,10 @@ typedef struct page *pgtable_t; #ifdef CONFIG_HAVE_ARCH_PFN_VALID extern int early_region_idx; -extern int pfn_valid(unsigned long); +extern int pfn_valid(unsigned long pfn); extern unsigned long memblock_next_valid_pfn(unsigned long pfn); #define skip_to_last_invalid_pfn(pfn) (memblock_next_valid_pfn(pfn) - 1) +extern int pfn_valid_region(unsigned long pfn); #endif #include diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 342e4e2..a1646b6 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -293,6 +293,30 @@ int pfn_valid(unsigned long pfn) } EXPORT_SYMBOL(pfn_valid); +int pfn_valid_region(unsigned long pfn) +{ + unsigned long 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); + /* HAVE_MEMBLOCK is always enabled on arm64 */ unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn) { -- 2.7.4