From mboxrd@z Thu Jan 1 00:00:00 1970 From: Baoquan He Subject: Re: [PATCH v2 02/17] dma-contiguous: simplify cma_early_percent_memory() Date: Wed, 5 Aug 2020 11:50:24 +0800 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 Return-path: Content-Disposition: inline In-Reply-To: <20200802163601.8189-3-rppt@kernel.org> Sender: linux-mips-owner@vger.kernel.org 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 List-Id: linux-arch.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 >