Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp182721pxa; Tue, 4 Aug 2020 20:53:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzD5DQYomrKMQCmnZh6yucL2oV8LhGbh9LvC9by2UL+4TaXFjDnvUXHZnlOXtsBaIcxAnGH X-Received: by 2002:a50:8a62:: with SMTP id i89mr1016323edi.324.1596599597433; Tue, 04 Aug 2020 20:53:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596599597; cv=none; d=google.com; s=arc-20160816; b=dJFqRSWxItdTx3A7UTGiWdt/ST99j8eHKVFB+HpKCmjDEMIRRKoI9X+brrrZMa+31R 0ZMnZcRSOJiJdp/1ZXWTSuxwb8EsdIRaqVdSTcB+Y74rf6IKUtTl8rZ9VC7aSG/APWmO p1eu+2le97l6M6ZPeCNOhUjQHY/N/LKoi4WxC0BISW4gfKUGrnhE0cKPaOpG6BBU+OVR byjGP2A4edCKDfvbPpPR7uE9VyCYgs7ui5GB42ECeS1Kr7quCMPTvZnrTO138Rq+6flq CHXDI9Vo1QdCP6mDE/XTnZSSFhFtst1RfAfSG02VZD7hqd8gjOKPFc8GiNdx3prG846K r0Fg== 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:message-id:subject:cc :to:from:date:dkim-signature; bh=PBRFUAvhtw5NCrkPVOAd8K2sp2Oav4oQ9F6n5x6FCHA=; b=NMkCErOfqPNNtUGEbJECJLsEL87OD2rQf1xy81ujPimoXQ6nPKh3rFSD4QE7+BrKOR 6MrObbljnly6fOytsSgFBRE0k9M2o7kSPHpr65tn8y2G60aWOpbhTv2QSywpBPz7PQGJ SOV9+botMuM37f83qqi2mfacf6yymgZOSyYFZodoJ5cEc2cKfmFRNPKbKCdzUTLhg0gP gZM8xnSjVKqehU3gIAPz8njK9N8FSpVRoUC3R2tPAy/GQkGB4QbocGDJE5YGqbaH6Bb7 fRzjt17pfjF4z3or/X63FXRD45BSKX5nkHIz4GbMddM+pTKrKrOF3yRt58pIrW54OGxJ iq4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EYZdOlpq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dc15si517250ejb.285.2020.08.04.20.52.55; Tue, 04 Aug 2020 20:53:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EYZdOlpq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726568AbgHEDuo (ORCPT + 99 others); Tue, 4 Aug 2020 23:50:44 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:31905 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726150AbgHEDum (ORCPT ); Tue, 4 Aug 2020 23:50:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596599440; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PBRFUAvhtw5NCrkPVOAd8K2sp2Oav4oQ9F6n5x6FCHA=; b=EYZdOlpqgLfXYcJ95lIiIG9jD3a1oW8PCH1InpolAq3M4UnJOLrALEXAaQQyx/TPShB2DO yfU9TV7/Rg/inqOSJdhhNpc8yXkx+aTt7p0X9cv6/FTadZ+KoS/PAb2VWWKAOx36FAhPGh ia9fLyZzx3ekCylRUwL23E4gDcuFrRo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-185-xI0_yRdGMPGizyxDuo-nyA-1; Tue, 04 Aug 2020 23:50:36 -0400 X-MC-Unique: xI0_yRdGMPGizyxDuo-nyA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8CFAE102C7EC; Wed, 5 Aug 2020 03:50:30 +0000 (UTC) Received: from localhost (ovpn-12-71.pek2.redhat.com [10.72.12.71]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 17E4F8AC06; Wed, 5 Aug 2020 03:50:27 +0000 (UTC) Date: Wed, 5 Aug 2020 11:50:24 +0800 From: Baoquan He To: Mike Rapoport Cc: Andrew Morton , Andy Lutomirski , Benjamin Herrenschmidt , Borislav Petkov , Catalin Marinas , Christoph Hellwig , Dave Hansen , Emil Renner Berthing , Ingo Molnar , Hari Bathini , Marek Szyprowski , Max Filippov , Michael Ellerman , Michal Simek , Mike Rapoport , Palmer Dabbelt , Paul Mackerras , Paul Walmsley , Peter Zijlstra , Russell King , Stafford Horne , Thomas Gleixner , Will Deacon , Yoshinori Sato , clang-built-linux@googlegroups.com, iommu@lists.linux-foundation.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, linuxppc-dev@lists.ozlabs.org, openrisc@lists.librecores.org, sparclinux@vger.kernel.org, uclinux-h8-devel@lists.sourceforge.jp, x86@kernel.org Subject: Re: [PATCH v2 02/17] dma-contiguous: simplify cma_early_percent_memory() Message-ID: <20200805035024.GR10792@MiWiFi-R3L-srv> References: <20200802163601.8189-1-rppt@kernel.org> <20200802163601.8189-3-rppt@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200802163601.8189-3-rppt@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/02/20 at 07:35pm, Mike Rapoport wrote: > From: Mike Rapoport > > The memory size calculation in cma_early_percent_memory() traverses > memblock.memory rather than simply call memblock_phys_mem_size(). The > comment in that function suggests that at some point there should have been > call to memblock_analyze() before memblock_phys_mem_size() could be used. > As of now, there is no memblock_analyze() at all and > memblock_phys_mem_size() can be used as soon as cold-plug memory is > registerd with memblock. > > Replace loop over memblock.memory with a call to memblock_phys_mem_size(). > > Signed-off-by: Mike Rapoport > Reviewed-by: Christoph Hellwig > --- > kernel/dma/contiguous.c | 11 +---------- > 1 file changed, 1 insertion(+), 10 deletions(-) > > diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c > index 15bc5026c485..1992afd8ca7b 100644 > --- a/kernel/dma/contiguous.c > +++ b/kernel/dma/contiguous.c > @@ -73,16 +73,7 @@ early_param("cma", early_cma); > > static phys_addr_t __init __maybe_unused cma_early_percent_memory(void) > { > - struct memblock_region *reg; > - unsigned long total_pages = 0; > - > - /* > - * We cannot use memblock_phys_mem_size() here, because > - * memblock_analyze() has not been called yet. > - */ > - for_each_memblock(memory, reg) > - total_pages += memblock_region_memory_end_pfn(reg) - > - memblock_region_memory_base_pfn(reg); > + unsigned long total_pages = PHYS_PFN(memblock_phys_mem_size()); Reviewed-by: Baoquan He > > return (total_pages * CONFIG_CMA_SIZE_PERCENTAGE / 100) << PAGE_SHIFT; > } > -- > 2.26.2 >