Received: by 10.213.65.68 with SMTP id h4csp132917imn; Fri, 30 Mar 2018 02:25:55 -0700 (PDT) X-Google-Smtp-Source: AIpwx49/bS97GVFVCT1yEypA4Xk/I4DoFe27ZxJ0Onu72aI9F6ESB6rz4+ZbaVlNuZ48Wdg/aEpL X-Received: by 10.101.97.16 with SMTP id z16mr8081170pgu.23.1522401955465; Fri, 30 Mar 2018 02:25:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522401955; cv=none; d=google.com; s=arc-20160816; b=bvvLw3cRQmfRZiW2XNuMXzg9lqAwl9shp0FiMNJhCuq52kOBASLtGRMmHZB79fPzXx fXPyWOeELKwBvbRagcEklzMyOLi3v6pyzZ9mxOfsdYucuFDPFAUWt56LXTj/irgQuevG 7my3ObGYfQ4t23cDxm6gvpQ2bL+7NKgkAKFAbLQjIWk/s1/A4JjsZoHw+gjiI33oUruZ SxOlJvepfNkMVdLX5uj051OzBXZDHuwXkb5v7z7Leptaz0wxclf0QdXP/O9xj3ki1IrL dBnm1+ssUcHBpT6e4Rxl7SvtV5vVxYinpcK2B3tg+LtXBy49u3z4Ped1PDJueh3hrsDt EQBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:arc-authentication-results; bh=X/2QHdU6CPBbWmzMaqiuLMyH3v26oZIaOug7RY1HhiM=; b=Sm2jOPi4mdrrUluSUEJky9DY+XuYQqAuIg8fCeQ9Li4Y4UZj8sCY+C7eYV8mpMv1iG efp66yk4lfE1t78UtBVomnVRMDH09gcBNa+3honhFEraYS03/EBZ8pqZd+3Suwd/nWmE AKaBc3liRSgd825x2zw5l4tCVK7pBX5ZNS1JggCEDZJ4HmhF9OrTt6AP17naKjcMhH+c VSOTzDyRryyKNP11r86sV7NlzYpBWRORhrm6nXfmc52Nme+Zn4Ciw3irKvGTWzmYBSTn A9JMW/gDwnvcfg0OhJe5Lrr666BkrBfSAOCId8+uoUkB/WwOrmxxiX4qg5TkjcjVTHs7 KGEA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g33-v6si8012108plb.499.2018.03.30.02.25.39; Fri, 30 Mar 2018 02:25:55 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751251AbeC3JY3 (ORCPT + 99 others); Fri, 30 Mar 2018 05:24:29 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:41673 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750831AbeC3JY1 (ORCPT ); Fri, 30 Mar 2018 05:24:27 -0400 Received: by mail-oi0-f66.google.com with SMTP id 188-v6so7380346oih.8 for ; Fri, 30 Mar 2018 02:24:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=X/2QHdU6CPBbWmzMaqiuLMyH3v26oZIaOug7RY1HhiM=; b=SoMWeMyfebH/Jrz1nnakGUNhAeXKz7xUviUvm0dMpl9OgID6Duci3zaxpNm//+p91s IVfsAA1vsqfjX1Zl+0qbcgZfFfTzU4dDuGVnH94BC8PKpH9qPLpOKP06eCCA+LsWbSYB 6vB/bvPoJRnnD8axmnlICY/XHcT1uGXTdte/xOisIAch9BGa6WEpc0ga1TbarQ2gux01 jsK+BoKuI8EVjGDkFGE7XFSaMWC9M5dOKIxeBlhh4/LYHd8/EHHfH5s4LsayhMVAdstE J6ZwIB6CklBnNAPZ0euwqbBr456yGrI+DAEERdG2Vyif/4hydrWqfoY/yuW9L/TCjf8d 5aKA== X-Gm-Message-State: ALQs6tBSAYiUAzZz9Ywy3rHQ9zhiGUnFYG0MXjs4stmcAlcrMjv9OTEC fJAPD49hBchRUwwbM2i25jWxjGX9Qq9LIuwXppdoVw== X-Received: by 10.202.234.10 with SMTP id i10mr6130072oih.33.1522401866846; Fri, 30 Mar 2018 02:24:26 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:cef:0:0:0:0:0 with HTTP; Fri, 30 Mar 2018 02:24:26 -0700 (PDT) In-Reply-To: <1522397755-33393-5-git-send-email-hejianet@gmail.com> References: <1522397755-33393-1-git-send-email-hejianet@gmail.com> <1522397755-33393-5-git-send-email-hejianet@gmail.com> From: Daniel Vacek Date: Fri, 30 Mar 2018 11:24:26 +0200 Message-ID: Subject: Re: [PATCH v4 4/5] arm64: introduce pfn_valid_region() To: Jia He Cc: Russell King , Andrew Morton , Michal Hocko , Catalin Marinas , Mel Gorman , Will Deacon , Mark Rutland , "H. Peter Anvin" , Pavel Tatashin , Daniel Jordan , AKASHI Takahiro , Gioh Kim , Steven Sistare , Eugeniu Rosca , Vlastimil Babka , open list , linux-mm@kvack.org, James Morse , Ard Biesheuvel , Steve Capper , Thomas Gleixner , Ingo Molnar , x86@kernel.org, Greg Kroah-Hartman , Kate Stewart , Philippe Ombredanne , Johannes Weiner , Kemi Wang , Petr Tesarik , YASUAKI ISHIMATSU , Andrey Ryabinin , Nikolay Borisov , richard.weiyang@gmail.com, Jia He Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 30, 2018 at 10:15 AM, Jia He wrote: > 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 | 23 +++++++++++++++++++++++ > arch/arm64/include/asm/page.h | 3 ++- > arch/arm64/mm/init.c | 23 +++++++++++++++++++++++ > 4 files changed, 50 insertions(+), 2 deletions(-) > > diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h > index 7a0404f..559b414 100644 > --- a/arch/arm/include/asm/page.h > +++ b/arch/arm/include/asm/page.h > @@ -158,7 +158,8 @@ 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 int pfn_valid_region(unsigned long pfn, int *last_idx); > #endif > > #include > diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c > index 7779804..11f9b82 100644 > --- a/arch/arm/mm/init.c > +++ b/arch/arm/mm/init.c > @@ -201,6 +201,29 @@ int pfn_valid(unsigned long pfn) > } > EXPORT_SYMBOL(pfn_valid); > > +int pfn_valid_region(unsigned long pfn, int *last_idx) > +{ > + unsigned long start_pfn, end_pfn; > + struct memblock_type *type = &memblock.memory; > + struct memblock_region *regions = type->regions; > + > + if (*last_idx != -1) { > + start_pfn = PFN_DOWN(regions[*last_idx].base); > + end_pfn = PFN_DOWN(regions[*last_idx].base + > + regions[*last_idx].size); > + > + if (pfn >= start_pfn && pfn < end_pfn) > + return !memblock_is_nomap(®ions[*last_idx]); > + } > + > + *last_idx = memblock_search_pfn_regions(pfn); > + if (*last_idx == -1) > + return false; > + > + return !memblock_is_nomap(®ions[*last_idx]); > +} > +EXPORT_SYMBOL(pfn_valid_region); > + > /* HAVE_MEMBLOCK is always enabled on arm */ > unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn, > int *last_idx) Since you have both functions in the same file, can you make the early_region_idx global static here and get rid of the arguments, perhaps? > diff --git a/arch/arm64/include/asm/page.h b/arch/arm64/include/asm/page.h > index 84b503a..27892d5 100644 > --- a/arch/arm64/include/asm/page.h > +++ b/arch/arm64/include/asm/page.h > @@ -39,7 +39,8 @@ 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 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 cd9b473..6dedd77 100644 > --- a/arch/arm64/mm/init.c > +++ b/arch/arm64/mm/init.c > @@ -293,6 +293,29 @@ int pfn_valid(unsigned long pfn) > } > EXPORT_SYMBOL(pfn_valid); > > +int pfn_valid_region(unsigned long pfn, int *last_idx) > +{ > + unsigned long start_pfn, end_pfn; > + struct memblock_type *type = &memblock.memory; > + struct memblock_region *regions = type->regions; > + > + if (*last_idx != -1) { > + start_pfn = PFN_DOWN(regions[*last_idx].base); > + end_pfn = PFN_DOWN(regions[*last_idx].base + > + regions[*last_idx].size); > + > + if (pfn >= start_pfn && pfn < end_pfn) > + return !memblock_is_nomap(®ions[*last_idx]); > + } > + > + *last_idx = memblock_search_pfn_regions(pfn); > + if (*last_idx == -1) > + return false; > + > + return !memblock_is_nomap(®ions[*last_idx]); > +} > +EXPORT_SYMBOL(pfn_valid_region); > + > /* HAVE_MEMBLOCK is always enabled on arm64 */ > unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn, > int *last_idx) Ditto. --nX > -- > 2.7.4 >