From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6260C49ED9 for ; Thu, 12 Sep 2019 08:40:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A56D3208E4 for ; Thu, 12 Sep 2019 08:40:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="H7N65ZTm"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=preh.de header.i=@preh.de header.b="kkAQxuK5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A56D3208E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=preh.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-ID:In-Reply-To: References:Message-ID:Date:Subject:To:From:Reply-To:Cc:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=U8pMCSgU9qAr19bJTQvmK4XYSVc2TeLW36tPXg4H1js=; b=H7N65ZTmHzXcWH v6ntBEyWuSa0yTxwO/yp1qtnnWz3LR53vcGDBnP8MbnRrD3ZoQJyrS3s+vGL41hHbJPQSUGaOwYRx aAx6sV0Ws1Gj9vJ6/xPqTNen04VSJlfxp7Pl9oQtsJglYrfPWpoTFUqSwu6RRgbTp4ELnzFduxxX7 5StnzMhnX9QIa5ozMT/jRe2JizO8v1qLZKPu3YBM/Q8t/QcQsDjc9y4lqtLact8sOOYctTqp83Je1 cHNm3pQ2NGyU46+2zb2zNWzJue+PMkovecKBSHn7OSK+SWCtTdxYVUiqxRr4MDz6a09tcFjm/Vj+n 09FPZ7t/GMTBw6/3hMYw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1i8KeM-0004DI-U7; Thu, 12 Sep 2019 08:40:22 +0000 Received: from mail01.preh.com ([80.149.130.22]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1i8KeI-0004Ch-Sl for linux-arm-kernel@lists.infradead.org; Thu, 12 Sep 2019 08:40:20 +0000 From: Hubert Ralf To: "linux-arm-kernel@lists.infradead.org" , "anshuman.khandual@arm.com" Subject: Re: [PATCH] aarch64/mm: speedup memory initialisation Thread-Topic: [PATCH] aarch64/mm: speedup memory initialisation Thread-Index: AQHVZ7YAP7sn04V7oEKvWrPakQZn36cnkreAgAAHnIA= Date: Thu, 12 Sep 2019 08:40:12 +0000 Message-ID: References: <20190910085822.27072-1-ralf.hubert@preh.de> <645c9de8-d82a-8d51-ae4a-bcf903ccd1e5@arm.com> In-Reply-To: <645c9de8-d82a-8d51-ae4a-bcf903ccd1e5@arm.com> Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-tm-snts-smtp: F3CD44FFDCA80C49406212E51BA14C0E735217CA327F3C4BF5855FCB79B0CA1B2000:8 x-exclaimer-md-config: 142fe46c-4d13-4ac1-9970-1f36f118897a Content-ID: <5A748C9235CB314B96B3AD44B957F82B@preh.de> MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; d=preh.de; s=key1; c=relaxed/relaxed; h=from:to:subject:date:message-id:references:content-type:mime-version; bh=s1pvdvHnBiRrpTVXcOtVIsYH20hnmvOXB0Bg9zwBByU=; b=kkAQxuK5WxCSEoCuVqQNc/vp2JtrQJHJ+/okFntEPH7JJCWUu0IFYgOI0CFteN77nPhYOeJPjZvD rUiCZ8pa+nNtzdwixspZImZeAw2nwO7riOnL/Vzr8Z7BhJ+KdPl46igCFFs2Bu4WwHj2m/n3sAmC TjLiYL/QkfiYNAMwmYqYnvi6A2CNO7sCIA2Kevoc2Q6n3tW/l/xhNmR+GZVRmR4hMSDd14Res0QZ v4krHN0eVDqhfSJQZepK7imMhplWLF6tAgQwQUWFouKMoltCmGwB93UZnef+Ou3G+M0nzGubxcwg cQG5mD17Rc4sWvRRFfTAKdDJh8/bKPWvg6pA8Q== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190912_014019_461382_79F81405 X-CRM114-Status: GOOD ( 23.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Am Donnerstag, den 12.09.2019, 13:42 +0530 schrieb Anshuman Khandual: > > On 09/10/2019 02:29 PM, Hubert Ralf wrote: > > On ARM64 memmap_init_zone is used during bootmem_init, which iterates over > > all pages in the memory starting at the lowest address until the highest > > address is reached. On arm64 this ends up in searching a memmory region > > containing for each single page between lowest and highest available > > physicall address. > > > > Having a sparse memory system there may be some big holes in the > > memory map. For each page in this holes a lookup is done, which is > > implemented as a binary search on the available memory blocks. > > > > Adding a memmap_init for aarch64 to do the init only for the available > > memory areas reduces the time needed for initialising memory on startup. > > On a Renesas R-CAR M3 based system with a total hole of 20GB bootmem_init > > execution time is reduced from 378ms to 84ms. > > > > Signed-off-by: Ralf Hubert > > --- > > arch/arm64/include/asm/pgtable.h | 7 +++++++ > > arch/arm64/mm/init.c | 24 ++++++++++++++++++++++++ > > 2 files changed, 31 insertions(+) > > > > diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h > > index e09760ece844..8c6eefc08b0b 100644 > > --- a/arch/arm64/include/asm/pgtable.h > > +++ b/arch/arm64/include/asm/pgtable.h > > @@ -298,6 +298,13 @@ static inline int pte_same(pte_t pte_a, pte_t pte_b) > > return (lhs == rhs); > > } > > > > +#ifdef CONFIG_SPARSEMEM > > +/* arch mem_map init routine is needed due to holes in a memmap */ > > +# define __HAVE_ARCH_MEMMAP_INIT > > This is not required any more. Its gone with the following commit which > also made generic memmap_init() an weak function currently overridden > only on ia64. > > dfb3ccd00a0 ("mm: make memmap_init a proper function") > > > + void memmap_init(unsigned long size, int nid, unsigned long zone, > > + unsigned long start_pfn); > > +#endif /* CONFIG_SPARSEMEM */ > > + > > /* > > * Huge pte definitions. > > */ > > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > > index f3c795278def..206b28310872 100644 > > --- a/arch/arm64/mm/init.c > > +++ b/arch/arm64/mm/init.c > > @@ -250,6 +250,30 @@ int pfn_valid(unsigned long pfn) > > } > > EXPORT_SYMBOL(pfn_valid); > > > > +#ifdef CONFIG_SPARSEMEM > > +void __meminit > > +memmap_init(unsigned long size, int nid, unsigned long zone, > > + unsigned long start_pfn) > > +{ > > + struct memblock_region *reg; > > + > > + for_each_memblock(memory, reg) { > > + unsigned long start = memblock_region_memory_base_pfn(reg); > > + unsigned long end = memblock_region_memory_end_pfn(reg); > > + > > + if (start < start_pfn) > > + start = start_pfn; > > + if (end > start_pfn + size) > > + end = start_pfn + size; > > + > > + if (start < end) { > > + memmap_init_zone(end - start, nid, zone, start, > > + MEMMAP_EARLY, NULL); > > + } > > + } > > +} > > +#endif /* CONFIG_SPARSEMEM */ > > In generic mmap_init(), the current high cost comes from early_pfn_valid() > check for each pfn in memmap_init_zone() given that early_pfn_valid() is > pfn_valid() when CONFIG_SPARSEMEM which is known to be expensive on arm64. > > Though we cannot do anything about pfns which are really present but the > high cost for non present pfns should be eliminated. The following check > in the above for_each_memblock() loop can achieve that. > > if (reg->flags & MEMBLOCK_NOMAP) > continue; > > MEMBLOCK_NOMAP universally should not be initialized into a zone and holes > if any should also be universally skipped across platforms. So these changes > can be moved into generic memmap_init() which will benefit other platforms. Not sure if I got this. This is a additional short path for memblocks with the MEMBLOCK_NOMAP flag set, right? For memblocks without these flag the remaining code still needs to be executed? In my case I have 4 memblocks with 1.5GB RAM at 0x4000 0000, 0x4 8000 0000, 0x6 0000 0000 and 0x6 8000 0000. None of them has the MEMBLOCK_NOMAP flag set. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel