Received: by 10.213.65.68 with SMTP id h4csp1172232imn; Sat, 24 Mar 2018 05:28:36 -0700 (PDT) X-Google-Smtp-Source: AG47ELv+KyqkgJjwF4oomS3FHV5XmFz3vMXDKw4EbelrAsX88u4e/7+kYOjcJVmVvvFcfen6bJj/ X-Received: by 2002:a17:902:2862:: with SMTP id e89-v6mr33077874plb.348.1521894516764; Sat, 24 Mar 2018 05:28:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521894516; cv=none; d=google.com; s=arc-20160816; b=TrFxEbd1pE6ywqFy8GHwfaDN1a/rLMFBmy5jLC0VnCOsK4KqkZrRQxORrcgvian7Y7 qal38hZMFdrai9s0ymWZ/hv/5q/q3eK/IbcTI8m3C2+gTWdKd4p0ZeOpuSJJ1/UcuxXl 6Kg0752U+9w+GoPXopXy9v1Mj7uQiTWrUo+4lEXExLYfs4WL8Cda5R1ThN7bD40OmlQP iPC6BcwBW5+IGolRYVRIMCOZq3cYSY7xjkUntjg3cJSeHHPFNzVpabvLV6mfa9UsHbBk uF17hH9eUZ912ocFg9mvGz4Evob1vMpRZuyEGAeb0CdJIk1Hx+Wez8OB5VDlMMJfk48w srsQ== 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=6pP1sGfEYf76VUP0NdxYf9dNCaWRxdSCR4omDaZW2B4=; b=tMLOfmYXmgdhhhHzew+9W+05+xyrSX6btGJttXHxzHIaazEzW/vpNyMJgu5Insxgrl KaQwGRMTuKOQTotXGqVcJsWA0edCpGDXu2EhaQYt8JNsll+BT6I73jcmIlNwGr9CFMSz rVtULMDc3X15XR4acmj8dt5JaQWam4rYk6hJ1OcT/Zqv5ya5qWYe8BqNzfaOPI1kKWl1 Hb+kvNGDQdXoYOtxuy4boJd/OjuMTeo5UDUlylooOrMn2iCB/z4B1+4m4QLkBpv7NzZ6 Wvm3h9qB/diTEWF2cA/h6c3pflcB2OWe40fkbjkeFOYT6kSoAX8lJ6wPgL986md9CBlN cuIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YSbCROLI; 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 j11si8190634pff.363.2018.03.24.05.28.21; Sat, 24 Mar 2018 05:28:36 -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=YSbCROLI; 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 S1752177AbeCXM0A (ORCPT + 99 others); Sat, 24 Mar 2018 08:26:00 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:42721 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751879AbeCXMZ5 (ORCPT ); Sat, 24 Mar 2018 08:25:57 -0400 Received: by mail-pg0-f67.google.com with SMTP id f10so5407494pgs.9 for ; Sat, 24 Mar 2018 05:25:57 -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=6pP1sGfEYf76VUP0NdxYf9dNCaWRxdSCR4omDaZW2B4=; b=YSbCROLI3JiBBbx1K0volzWaD6a+N4ZoUAusl5h1Kw/ICTVRMqNvTTUbgwRGGbFF4N 41LpUAYvaYHYwUjb4/Q3QLGUx8SNVVxoFCwdDKaP9Ors84ZEyB+LgGYWrCCk2kAIfMs+ 9c/ygvxRwLDWIC0sIK5QOArqtUcmwRhgyolH0KzuU2Kg6bTmi4KjXMdnBkDyRme2MfW0 BQzRp/p+1by0Ho5+kOZn9jOsgI3CzJKXRBjg9PhqAV+Oy1NAOMi/CRPo5CnOb1lHHKY2 xp9Fhm39id5ukE0zMy9l7nS5t4sVCkcV5PjK7UAD4bbNYUJ+e9aQC2VwclWdVL93TsA8 eHQQ== 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=6pP1sGfEYf76VUP0NdxYf9dNCaWRxdSCR4omDaZW2B4=; b=SLmvWxS62oxetKFbV5+UPg2/2hUoKwaTq6OtBgKq2NATAidWd9qQ8pUzvVsNvE6vJ8 tuALuD5OvVNDqbISQwQWJ/2mQZpop4TEdBSlcPXzldcTRAzoa1vgQ0u1Rqas+whf5/kU VKS/egAVnsrXGgz407uAKoNaQwVDSxkJpMHQ9MNrseXuIatdSekXfCdDz5S5rZtt3WFp 9HhyfcxVA3JhUgViBTyisrkL3ZizbIuvqyqFJfUYJTCOHKgInoGz5LFeNZJiK0oD6He9 s7qQ/AZw+xFW0LYyYYrFojCJJAlDRKaxFTk0OMxs4eV1elF2Cz11j+ieqMX/804Sr0cm ZoNQ== X-Gm-Message-State: AElRT7GQiHDNTc9K7L2RNPjrneyJAPlgyJqnYLMdWsBwUCW9dfcsqO4B eY4v9seTW25i/MVHGP2dZ8Q= X-Received: by 10.98.61.206 with SMTP id x75mr21409135pfj.233.1521894357013; Sat, 24 Mar 2018 05:25:57 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id b6sm23152371pfm.160.2018.03.24.05.25.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 24 Mar 2018 05:25:56 -0700 (PDT) From: Jia He To: Andrew Morton , Michal Hocko , Catalin Marinas , Mel Gorman , Will Deacon , Mark Rutland , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" Cc: Pavel Tatashin , Daniel Jordan , AKASHI Takahiro , Gioh Kim , Steven Sistare , Daniel Vacek , Eugeniu Rosca , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mm@kvack.org, James Morse , Ard Biesheuvel , Steve Capper , x86@kernel.org, Greg Kroah-Hartman , Kate Stewart , Philippe Ombredanne , Johannes Weiner , Kemi Wang , Petr Tesarik , YASUAKI ISHIMATSU , Andrey Ryabinin , Nikolay Borisov , Jia He , Jia He Subject: [PATCH v2 4/5] arm64: introduce pfn_valid_region() Date: Sat, 24 Mar 2018 05:24:41 -0700 Message-Id: <1521894282-6454-5-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521894282-6454-1-git-send-email-hejianet@gmail.com> References: <1521894282-6454-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 arm64. Signed-off-by: Jia He --- arch/arm64/include/asm/page.h | 3 ++- arch/arm64/mm/init.c | 25 ++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/page.h b/arch/arm64/include/asm/page.h index 60d02c8..da2cba3 100644 --- a/arch/arm64/include/asm/page.h +++ b/arch/arm64/include/asm/page.h @@ -38,7 +38,8 @@ extern void clear_page(void *to); typedef struct page *pgtable_t; #ifdef CONFIG_HAVE_ARCH_PFN_VALID -extern int pfn_valid(unsigned long); +extern int pfn_valid(unsigned long pfn); +extern int pfn_valid_region(unsigned long pfn, int *last_idx); #endif #include diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 00e7b90..9122102 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -290,7 +290,30 @@ int pfn_valid(unsigned long pfn) return memblock_is_map_memory(pfn << PAGE_SHIFT); } EXPORT_SYMBOL(pfn_valid); -#endif + +int pfn_valid_region(unsigned long pfn, int *last_idx) +{ + unsigned long start_pfn, end_pfn; + struct memblock_type *type = &memblock.memory; + + if (*last_idx != -1) { + start_pfn = PFN_DOWN(type->regions[*last_idx].base); + end_pfn= PFN_DOWN(type->regions[*last_idx].base + + type->regions[*last_idx].size); + + if (pfn >= start_pfn && end_pfn < end_pfn) + return !memblock_is_nomap( + &memblock.memory.regions[*last_idx]); + } + + *last_idx = memblock_search_pfn_regions(pfn); + if (*last_idx == -1) + return false; + + return !memblock_is_nomap(&memblock.memory.regions[*last_idx]); +} +EXPORT_SYMBOL(pfn_valid_region); +#endif /*CONFIG_HAVE_ARCH_PFN_VALID*/ #ifndef CONFIG_SPARSEMEM static void __init arm64_memory_present(void) -- 2.7.4