Received: by 10.213.65.68 with SMTP id h4csp240398imn; Wed, 28 Mar 2018 02:40:13 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/lvaOf5qE5flWHPYnBVMXigNcbmaFcsbFDEQsohXKC7sOhoala5AurjhqSonAvX6P5khbI X-Received: by 2002:a17:902:900b:: with SMTP id a11-v6mr2982217plp.366.1522230013464; Wed, 28 Mar 2018 02:40:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522230013; cv=none; d=google.com; s=arc-20160816; b=JwL2Xn14VDg9+BLs3ULnOlOIvKNKoOPVz+YMJ8tfsR3l56XRHp+0cWOywM7tRfUUx4 FCcY+qwizPSefTJ1QT4apvuWZULYW4RvlaTTq8xfFy030PGd42BmRukkG9tirIM/to13 wIQInu2SPmSN9LrNAX1WE8Y7hYfmmX6zo5Sqn5wqGuCRD75PvlLNdxlS+rrIcF2FJzfK jHhjPvt/VPJW7vJkQNOnKdNEo/43JGfEMsMfiBrOKul4XFsQB/gw5wYEJpiSj25oJKTR BYJyORikSC/h4HdB0au43vQlKv3N3daOpFMVibQ+hBhn5BMQpSIohXNyu6L0zR+ou1AS mCeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature:arc-authentication-results; bh=M2JL+c9OK7o1jHuSKB0PwYzqIny3+aceEa1enEyF1OQ=; b=YsfnsBtJruNhi4RJWFZYtFFEFJD7zqUfw/wtDAGDAHphOWxwh1sQahG+M7t5Oj4LBC Pbc6ggK8PifGqWVV4wUAnJAUONKEC69SD6RSOfpsh7txJub/P+lyWhc+mUwteuzo+pOI QZJIHjuhVowi0bSvn7hjpwjovI87hHgSyOMN0yRNHdJ15AUeVJgHdcjq0A2qYzknXPBx 4CsIZJfMY02sdt0Co8aSfpzb7X4IU2YGhqMQvneDzWo5Jq3vgJ6oMU5E34p0KmF4cqNm hYYAsNomjKcYDh9x3gcYe9w3Mtucof7+EeQZtvypunrqrElZmOZq9I9RqsQkO2iouw5P aDIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=o/ER86bo; 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 d1si2176314pgf.499.2018.03.28.02.39.58; Wed, 28 Mar 2018 02:40:13 -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=o/ER86bo; 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 S1752161AbeC1Jim (ORCPT + 99 others); Wed, 28 Mar 2018 05:38:42 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:39952 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750753AbeC1Jik (ORCPT ); Wed, 28 Mar 2018 05:38:40 -0400 Received: by mail-pl0-f67.google.com with SMTP id x4-v6so1239366pln.7 for ; Wed, 28 Mar 2018 02:38:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:reply-to:references:mime-version :content-disposition:in-reply-to:user-agent; bh=M2JL+c9OK7o1jHuSKB0PwYzqIny3+aceEa1enEyF1OQ=; b=o/ER86bolQi+b3rulnHP/OUGW1t2y7JZUDT5co8DI/8oSIK2v7S2eYc2geXMfMMcIz 82XN7Vy0VnV0tuFXASRqKvAwT9yu25zZbPlMl5V1unfGimeJksl+IPNK87IvkYiJvy1G FpSDZTG9lKizLiv2Qe4ZmBq0j/bMMtHEu+I/pjbEiR63KcJnUkH/pQBnNkDm5lIt3DQp koeS8BESSTdjwa7l3lUtVppNYLwx4xNaDyWXFnKLXHRD0HTusTBvguChbb+Fr5b/B9mC 9AkwrI1w2Uop5LPfN2l/FDr9A1ktQFaooPFajWOdggPYpUG+LDWrgz8rDoRWDPLIWQC5 LRqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:reply-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=M2JL+c9OK7o1jHuSKB0PwYzqIny3+aceEa1enEyF1OQ=; b=QvYcEd6w+riQaba7FFc7KlX5BNaomGImtU4bOHMrt33GxBnWDA/VtGv9AK1KRmoQy5 7PofP/90FsvUzm9Bpx1MFuXxuoOMX4ZG3W8SqV7s6EukIVKSsKOtcTjiaE85dkyGVjy3 3vo7cq8D6XxnqOljxNXBtA1bMyc0dlD5txc5cS8Yz3OEPerrEe4UIGxiEdENfevEeWM/ BVgWgffoOGS4HmjOHLdulNCLw2ztA56SaLvRmmnMG6uDAGNG52v913sd31QBQmOpJC+Z 2ZOeTvUamQpKkbtzQwzqiQ6n1vJbGOK/er3mPdlzKL3Oq6Ut4zn2SsXz1akMgGkCEKsv iaiQ== X-Gm-Message-State: AElRT7H2UvCej/R9B0hnfmdTfTRMCDoF2nvLmTVUdV7kDUX0Q6X6YGZR 85PEJmqU+0Gb1xJdELp6Ijs= X-Received: by 2002:a17:902:525:: with SMTP id 34-v6mr2986542plf.267.1522229919882; Wed, 28 Mar 2018 02:38:39 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id j65sm6212110pge.58.2018.03.28.02.38.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Mar 2018 02:38:39 -0700 (PDT) Date: Wed, 28 Mar 2018 17:38:30 +0800 From: Wei Yang To: Jia He Cc: Andrew Morton , Michal Hocko , Catalin Marinas , Mel Gorman , Will Deacon , Mark Rutland , Ard Biesheuvel , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , 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 Subject: Re: [PATCH v3 4/5] arm64: introduce pfn_valid_region() Message-ID: <20180328093830.GB98648@WeideMacBook-Pro.local> Reply-To: Wei Yang References: <1522033340-6575-1-git-send-email-hejianet@gmail.com> <1522033340-6575-5-git-send-email-hejianet@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1522033340-6575-5-git-send-email-hejianet@gmail.com> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 25, 2018 at 08:02:18PM -0700, Jia He wrote: >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); PFN_UP() should be used. >+ 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]); Could use type->regions directly. >+ } >+ >+ *last_idx = memblock_search_pfn_regions(pfn); >+ if (*last_idx == -1) >+ return false; >+ >+ return !memblock_is_nomap(&memblock.memory.regions[*last_idx]); Could use type->regions directly. Well, since your check memblock.memory.regions, how about use a variable equals memblock.memory.regions directly instead of type->regions? For example: struct memblock_region *regions = memblock.memory.regions; >+} >+EXPORT_SYMBOL(pfn_valid_region); >+#endif /*CONFIG_HAVE_ARCH_PFN_VALID*/ > > #ifndef CONFIG_SPARSEMEM > static void __init arm64_memory_present(void) >-- >2.7.4 -- Wei Yang Help you, Help me