lkml.org 
[lkml]   [2019]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] riscv: fixup max_low_pfn with PFN_DOWN.
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.

\
 
 \ /
  Last update: 2019-01-15 17:13    [W:0.815 / U:2.668 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site