From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: Re: [PATCH] riscv: fixup max_low_pfn with PFN_DOWN. Date: Tue, 15 Jan 2019 08:12:54 -0800 Message-ID: <20190115161254.GA19081@infradead.org> References: <1547280987-7630-1-git-send-email-guoren@kernel.org> <20190115153613.GC26443@infradead.org> <20190115161000.GA22705@guoren-Inspiron-7460> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20190115161000.GA22705@guoren-Inspiron-7460> Sender: linux-kernel-owner@vger.kernel.org To: Guo Ren Cc: Christoph Hellwig , palmer@sifive.com, aou@eecs.berkeley.edu, linux-arch@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Guo Ren , Mao Han List-Id: linux-arch.vger.kernel.org On Wed, Jan 16, 2019 at 12:10:00AM +0800, Guo Ren wrote: > > > set_max_mapnr(PFN_DOWN(mem_size)); > > > - max_low_pfn = memblock_end_of_DRAM(); > > > + max_low_pfn = PFN_DOWN(memblock_end_of_DRAM()); > > > > I know it is used just above, but can we please just switch this > > code to use >> PAGE_SHIFT instead of PFN_DOWN, which just horribly > > obsfucates what is going on? > ??? > #define PFN_DOWN(x) ((x) >> PAGE_SHIFT) > > phys_addr_t __init_memblock memblock_end_of_DRAM(void) > { > int idx = memblock.memory.cnt - 1; > > return (memblock.memory.regions[idx].base + memblock.memory.regions[idx].size); > } > > What's the problem? PFN_DOWN() couldn't be used with function call? PFN_DOWN gives you the correct result. But I think it actually drastically reduces readability over just opencoding it. > My patch just want to point out that max_low_pfn is PFN not size. In fact > there is no error for running without my patch :P No, I think your patch is correct. I just wonder if we could make the code easier to read. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bombadil.infradead.org ([198.137.202.133]:42882 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727088AbfAOQM5 (ORCPT ); Tue, 15 Jan 2019 11:12:57 -0500 Date: Tue, 15 Jan 2019 08:12:54 -0800 From: Christoph Hellwig Subject: Re: [PATCH] riscv: fixup max_low_pfn with PFN_DOWN. Message-ID: <20190115161254.GA19081@infradead.org> References: <1547280987-7630-1-git-send-email-guoren@kernel.org> <20190115153613.GC26443@infradead.org> <20190115161000.GA22705@guoren-Inspiron-7460> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190115161000.GA22705@guoren-Inspiron-7460> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Guo Ren Cc: Christoph Hellwig , palmer@sifive.com, aou@eecs.berkeley.edu, linux-arch@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Guo Ren , Mao Han Message-ID: <20190115161254.uYVaGkHPRErzOX44veOK0mwKPPHcNKeOmdPc0aEJ6bU@z> On Wed, Jan 16, 2019 at 12:10:00AM +0800, Guo Ren wrote: > > > set_max_mapnr(PFN_DOWN(mem_size)); > > > - max_low_pfn = memblock_end_of_DRAM(); > > > + max_low_pfn = PFN_DOWN(memblock_end_of_DRAM()); > > > > I know it is used just above, but can we please just switch this > > code to use >> PAGE_SHIFT instead of PFN_DOWN, which just horribly > > obsfucates what is going on? > ??? > #define PFN_DOWN(x) ((x) >> PAGE_SHIFT) > > phys_addr_t __init_memblock memblock_end_of_DRAM(void) > { > int idx = memblock.memory.cnt - 1; > > return (memblock.memory.regions[idx].base + memblock.memory.regions[idx].size); > } > > What's the problem? PFN_DOWN() couldn't be used with function call? PFN_DOWN gives you the correct result. But I think it actually drastically reduces readability over just opencoding it. > My patch just want to point out that max_low_pfn is PFN not size. In fact > there is no error for running without my patch :P No, I think your patch is correct. I just wonder if we could make the code easier to read.