Received: by 10.213.65.68 with SMTP id h4csp974793imn; Sun, 25 Mar 2018 20:05:06 -0700 (PDT) X-Google-Smtp-Source: AG47ELv73WdMzV6NIRjqxIfHp8D11x58Wj2LS7A4YeEEqGgQSKgwGhEn2K7AJql9hvepYZNzZbsy X-Received: by 10.98.29.145 with SMTP id d139mr16817483pfd.165.1522033506852; Sun, 25 Mar 2018 20:05:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522033506; cv=none; d=google.com; s=arc-20160816; b=manIsP1ZVJq8MhSxSeNTORl77PmKCk/HIlXXTzVi7SvmmnoF//VWaweKfAoTRE0fp1 emCxtPCSyzFPIpn+z8t5A3DV6IIUqqRZ2tRibkVqMBCyjC3xZjo/4qcoR5nmzcqeL5oI aoSlFXVInj9xWAbroWkFJDWMsyA3QoJK2qiD/Px8sS6p01OJBsHMHKEId/4QjC8+VhJX 4DYFQfNesoD3LuHEPk1tX9hJakAZdhuqvtBeNmsOXr1ZMd3nD4cuUiqqvfWLwVeV2yAi HU5lNp3IUdzIzvDYnJdemOwNaSWkZpYKiPI90qyTtdS7UB2r28PgmXJAriQge9eJirld 80rg== 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=CgVDV6TnbNT0G6IPq/hrv4xR6TOYvoiXvBonAgQwMio=; b=RgJsieww5ZRx4XiFmxcyR7ueU03JUzorBVQ5DRzGZq3TdLB1fLlXE+ULzZKhFCVKwG dgyt1LTI9pJzrh6VMPIyA1TpQbbC6VVLVht2IEf16VyB06Fe97qXdqxbReVOrryL1WKd k6BtTvlRjf6hiOwW19Bgn+gmknZN2AriYHx2Z9T1Ob21fdvyPB+TfZeqWZU2Vcc8ztYI 1VOJ70qdrX7NCbr/c9NFmUT9nbBhIaADaahjdFZgkHCfjhsi0K2uP/NsKIOh+Ors2KMT G7Uv03u+hOfwr4+D0lCrIpfjdDuiD4PjPOV6u1dciLNcc2TabrFc2Arg/dxpkSdY4cEV ewFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ievLv0Uf; 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 1-v6si13903792plj.247.2018.03.25.20.04.52; Sun, 25 Mar 2018 20:05:06 -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=ievLv0Uf; 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 S1752159AbeCZDDk (ORCPT + 99 others); Sun, 25 Mar 2018 23:03:40 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:45965 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751074AbeCZDDi (ORCPT ); Sun, 25 Mar 2018 23:03:38 -0400 Received: by mail-pf0-f195.google.com with SMTP id l27so6993710pfk.12 for ; Sun, 25 Mar 2018 20:03:38 -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=CgVDV6TnbNT0G6IPq/hrv4xR6TOYvoiXvBonAgQwMio=; b=ievLv0UfN5MHqsy0cRxsP3aZ+wKTWrmFEQr4BxEcOkOTurBMI8NNZsYEPepPx1Rvsl hxsdcQ9IG21nGNejHycJQRjKvAACCCFaXpXcaTHxjK5O4GmPD+4RxrPppZtGcJ5WorMz orH3uKppkWJgOjkIodKwrX4MZM6GYb78jCwDagwHs0iTxRgvLt8qyCv5F7IEgznZyw+s nzgyUlJhsnoJXGa3G2Wo3THw2T4CEALxZNpVXYVdYgi+wI5jZ6u/h2wKnDK1YsiD4YBP Ig5Y8tlLFhVZjPMyEQj3NHI+5EJqKA30ypZUzVH2hQImGfPg8d6+T8CAg3R6kkED5Udy eUnA== 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=CgVDV6TnbNT0G6IPq/hrv4xR6TOYvoiXvBonAgQwMio=; b=Vu+Rjxa+1XlFwsMrmRvBrFQUZPLH6MSA5/zJ/0Q3NyowktdRlUb7dh4OeFUTMIiswb j4D4btp0QLS3TgBuyMDlADe4GBxt/KAxcALm3B9GiHVoFHPi+t8vpHG3NiKyYy7tikFK ArGuAHn1p0YPHTjMyrb7xuc22y5ZUCoXA0MGFcOeaKFrGbBv01loQhzHvRXTeRBA0gwa oyq/ZdCQNCe3IKkfaS0T3de4ltPeQgfjZqV/7EnwweF59y4BwTV2HkKAnq5pl+aoiu2M WM9a87jUGJkJ4Sjbxep+X2igwmT/72qYKuMCNxQ320jjmzZXkx+zDdpUeZ0WugB4Nfqd UHIw== X-Gm-Message-State: AElRT7EjKiBfWMyMqjFZUjz7XGXHvvqPadxMLv/Gh7Qh/+xM5Dr/FwzR gUiZU7PC8z0nPCFsv8IrFzc= X-Received: by 10.98.59.4 with SMTP id i4mr31750298pfa.26.1522033417929; Sun, 25 Mar 2018 20:03:37 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id f19sm1634989pgv.39.2018.03.25.20.03.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 25 Mar 2018 20:03:37 -0700 (PDT) From: Jia He To: Andrew Morton , Michal Hocko , Catalin Marinas , Mel Gorman , Will Deacon , Mark Rutland , Ard Biesheuvel , 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 , 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 v3 4/5] arm64: introduce pfn_valid_region() Date: Sun, 25 Mar 2018 20:02:18 -0700 Message-Id: <1522033340-6575-5-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522033340-6575-1-git-send-email-hejianet@gmail.com> References: <1522033340-6575-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..06433d5 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 && 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