Received: by 10.213.65.68 with SMTP id h4csp1056782imn; Wed, 21 Mar 2018 01:12:46 -0700 (PDT) X-Google-Smtp-Source: AG47ELs7CLi3vqsOHFcHE5k5vApXYCE2McE+viXHlGaA68nnInPw7NS1jEnVwTJoVTamTjEAfqsq X-Received: by 2002:a17:902:70c4:: with SMTP id l4-v6mr4894456plt.344.1521619966542; Wed, 21 Mar 2018 01:12:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521619966; cv=none; d=google.com; s=arc-20160816; b=DUVkLUozprBnNN0DYI5xLlVPH/4VU1PKO8rUup2B6iMr3JHTulgk8IFkDXNTGr7WDX 1OgZVX7vkraLT4/u97/yURB2lwArogK7VQk4QfZHAA8nEQBNCCxBlOA+oPb6GdNCMGoG gXxClYZ6EZy9eodw8jA+sN5kVgcn0ZHwTCSLGlEjRgTZdPmg3he84LOK2bH2nf2ViqG6 o6RPqSfhLhFzChcCoQdcLCzbcUOLGka+rp1JUTRP+h91aPy/IH1vU7u+KaCdzX43dT21 tVlg2h6eVph5gEuSvI0DN5xZL1JOnHpdvOmR5+qso+bF8w9l3eyWUvoQgdrDZtgSBYy1 7AYw== 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=RABvO65frYI8v2NwjIigZ+5RwFAonwVr7w9ovXuZHJA=; b=XtU7hjlHX7wCrMoaq7FiGKA3RAKPDK7peMCIag4hndsVyzW764+SXb5nPVGLI9HHex k79JdGPVtXWt1g95lrI/LG0kBq93XKaOAR5fDx2ErThRh1yeqKfHrOhsmWo/neOWzALq n1DjaEu3ekiIe0cBmYMoIPgNyo2AVkgz62XsVlQSkyBm30INtssN+Dlf0N7VaHRQzYJj Si4QVtFHUwgkOlSDq3ZMHBDvdh4vE3C/HbjwbO5udHXvxL5C7D1DwmDbZtLlxJE8jeV8 uP676fpb3GKIV1u5xxYxoRYDSDVkIJAXzl192JqlZCzKEuMrJqheSRcoLFAsF1ZCK/P+ q3Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hR3gniP3; 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 c5-v6si3335937pll.90.2018.03.21.01.12.32; Wed, 21 Mar 2018 01:12:46 -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=hR3gniP3; 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 S1751909AbeCUILA (ORCPT + 99 others); Wed, 21 Mar 2018 04:11:00 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:36788 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751472AbeCUIK4 (ORCPT ); Wed, 21 Mar 2018 04:10:56 -0400 Received: by mail-pl0-f68.google.com with SMTP id 61-v6so2697308plf.3 for ; Wed, 21 Mar 2018 01:10:56 -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=RABvO65frYI8v2NwjIigZ+5RwFAonwVr7w9ovXuZHJA=; b=hR3gniP3Zl/IHs7U9M/pisRFF5EKu2g9XmmSmxDq1JNNx6lXQsUlWeMX9ugk1mzNFU DErUztE5/WVbr7u7ZG1pRwUjUC+zi6vDanNyBzLz1bmIGhe2erovzXLblG9H3EGMIYaU OKOUD6ClRGcv1BLTyXrGyun5Yltl7B+qJlA4fMUzDwIxWGg99qa1BU1ZSapXSN9wbdw6 oN/4ua+HmpFqUpuECqLEOjhPvNLZ/52Nze0OjUeOCAnb5Db9CMTKz88FSigomCegkj/T OG+gGURx+VuryuPT1QJRhXQnf09D+FwZgo32KC/pnUCwGu3R1wtyItrTJlNzyQdux9/J zFYQ== 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=RABvO65frYI8v2NwjIigZ+5RwFAonwVr7w9ovXuZHJA=; b=lQqiW08yprflkCTPoO/BSrGWMsWbUfqBiiM0vOV9DS4iYY+JhdzhfYMZBFud3+GMT0 L23vC40MZv1/jq6FVvevaqRofIwHONWL2FsjwB3S8cxs4bQvCOD1+9q9d59F36tfroJo zdElvNJYkpmFbkeZCiuWOK/sgpKia2rfqPCZ88O5Kf87I0QrI8wuZuM2bOLk9+RZA4br pXcaJNcjXU7H65W44yGIcpCMQiQmryL8r6YRkYKgM02CE4y2psDDN1WK1bEEMEr3LRDu ggfBELwFix1jmastycpLOFW7yRrhiqaCpu3ReLVO0BUpESbNFQvIBzFs+XCn0/rv5OFM RHOg== X-Gm-Message-State: AElRT7GRhtA6i0k8e39dP5exzljKbOGNWAtW/ZF8Z2H2ugo0WaA3JgcR gbTwoO2QPiuL2iGUuGaEeDI= X-Received: by 2002:a17:902:444:: with SMTP id 62-v6mr20181309ple.127.1521619855952; Wed, 21 Mar 2018 01:10:55 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id w10sm5950775pgr.57.2018.03.21.01.10.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Mar 2018 01:10:55 -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 3/4] arm64: introduce pfn_valid_region() Date: Wed, 21 Mar 2018 01:09:55 -0700 Message-Id: <1521619796-3846-4-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521619796-3846-1-git-send-email-hejianet@gmail.com> References: <1521619796-3846-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 | 19 ++++++++++++++++++- 2 files changed, 20 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..1d9842e 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -290,7 +290,24 @@ 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) +{ + struct memblock_type *type = &memblock.memory; + + if (*last_idx != -1 && pfn < PFN_DOWN(type->regions[*last_idx].base + + type->regions[*last_idx].size)) + 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