Received: by 10.213.65.68 with SMTP id h4csp2074663imn; Mon, 2 Apr 2018 00:01:03 -0700 (PDT) X-Google-Smtp-Source: AIpwx49T2bOaJlhMxnZ2wseMsEM0tt86HhFMZcyHJnTeLfbn5dKULtXsx4GcktApeSSuOYlkliFt X-Received: by 10.98.178.207 with SMTP id z76mr6548317pfl.37.1522652463644; Mon, 02 Apr 2018 00:01:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522652463; cv=none; d=google.com; s=arc-20160816; b=cZwZ/5UWWcSvGRO5XlKAQQaNbvPPe7pC6DZAFidDid2win4X3B3VGJI0y7He9wfs0n hyKCVzDpVZXvIDEiXPDGtUC1fFipzkO/UyPOOsWN4OthcE3Q+JwKgNCnM/ePylTmmGMZ m0ynfnaZU6RbQ/4qWtQ+0RukJ9l31iBH0zByqpvaD4gh0todvB5I5CTuYmmhzUSul8nm sUCzJG5s6pqVVOeNwgFaiVYw0+kZwmiijF1nO6SA/brlNQbIb5Ms5ASLcTqXklDGCa4+ 7ymBeQaDfM5OwRA4rAHdm10CMss27Lsr+vOanyOUZQqO7V6I0fJLQkxhr/yRuCTX5UX1 eyMw== 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:dkim-signature :arc-authentication-results; bh=5N1basIXvq634eQ8ZhgmqeKmJREVNZukOUZmhOnWa7U=; b=wR4qMJ0Mf61hQuLfeXk+9DMYDi/wWaBOfZgz88YM/RG8aWLavrQfJ0GTE7Bi1OXcEA Aspr78OYMlwY3mP+Qk8NpZ9WgJsvxBZomnGi4DsYNxRcAmtJkRzwIomTEfbHF+3jP4Ww nUcOoMIl+1z4YWmpJp+w3PN7lgD5Mw6Zd1oWE9j0A9AFEr7gV7DsM/hpaFTynCcLXnIe K7yZNMNb3+8l5VlaBM1YKYu/8o7NS+bdtNquZIBr+ooT+sFMa0dkdICx64nci4fVUlAQ GhQEtgUcih+Cb9+ImFxND/m6kSWocpmyVcx5AzA7yIY5kmA10pueuIshd5P3XIGc71Qk jIaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ANvBFXrB; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e3-v6si13971439pld.49.2018.04.02.00.00.50; Mon, 02 Apr 2018 00:01:03 -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=@linaro.org header.s=google header.b=ANvBFXrB; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754373AbeDBG7H (ORCPT + 99 others); Mon, 2 Apr 2018 02:59:07 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:46680 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754223AbeDBG7F (ORCPT ); Mon, 2 Apr 2018 02:59:05 -0400 Received: by mail-io0-f194.google.com with SMTP id q80so16897929ioi.13 for ; Sun, 01 Apr 2018 23:59:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=5N1basIXvq634eQ8ZhgmqeKmJREVNZukOUZmhOnWa7U=; b=ANvBFXrBfdXb+Oh+5uII9ZSE18RZtUJwXRRI0CHHrk/oOSFSZ47I33lxjE5FKUOJ0x lvz3m+4t4XhvFCfJyHlUzA5KMjJv7VNaTtYzS8GSCfrgjcAZXUzwUoGIOlT24oBBhKc3 A7yMXOkoInzogf4XmATpEBP4sDDJQghaVRASI= 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=5N1basIXvq634eQ8ZhgmqeKmJREVNZukOUZmhOnWa7U=; b=WJ1iMh8COwlMhcqoDDzwxlNpemyyXgLnbAJ6SR24WSMx6Z38qTqBOgS6muUH6NIIYx 6CZK471A4JeuoZqTTAIzOtKXn8A42+fJb84C3jvlodRgxyJ2+LOmdNEq18docORdUfGy 9OWa3Zc2hE9gFv+CvSqB60okD5dPaoqvivfqOLMx/YwMCIXZeU38XNN2W7qDV4UjpcD9 tmp1JtWKq3hdZ7vMHEdUvJkl2UAuXQ1wBVJPuacCF7cUT1bPthitEKeiw0v4YlMgB1lt faA74VAi9loTru8HaHVNhnjOV9dTK1F+3z/G6eX5QJC+B+TAt5YR7jSfY847vbZJCMIP p+xg== X-Gm-Message-State: ALQs6tDsWYhEt8bI5+nsNVjgb5P+p4arXvjqXJMYMCCzsX2vLUzeMub/ COlEu52h/4zqU/uFP1HIhCCvhedJsgtZPqufBdyGGQ== X-Received: by 10.107.16.230 with SMTP id 99mr7760206ioq.60.1522652343680; Sun, 01 Apr 2018 23:59:03 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.187.67 with HTTP; Sun, 1 Apr 2018 23:59:03 -0700 (PDT) In-Reply-To: <1522636236-12625-5-git-send-email-hejianet@gmail.com> References: <1522636236-12625-1-git-send-email-hejianet@gmail.com> <1522636236-12625-5-git-send-email-hejianet@gmail.com> From: Ard Biesheuvel Date: Mon, 2 Apr 2018 08:59:03 +0200 Message-ID: Subject: Re: [PATCH v5 4/5] arm64: introduce pfn_valid_region() To: Jia He Cc: Russell King , Catalin Marinas , Will Deacon , Mark Rutland , Andrew Morton , Michal Hocko , 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 , Linux Kernel Mailing List , Linux-MM , 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 2 April 2018 at 04:30, Jia He wrote: > This is the preparation for further optimizing in early_pfn_valid > on arm and arm64. > Same as before - please share the code between ARM and arm64. if necessary, you can invent a new HAVE_ARCH_xxx symbol that is only defined by ARM and arm64 - please explain what the patch does and more importantly, why > 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 >