Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5093677imu; Tue, 15 Jan 2019 11:04:38 -0800 (PST) X-Google-Smtp-Source: ALg8bN46BJ+5qJqihlNLmOqyYzSDHVx1Slw1thbSHmmMXJ8t6rm3ckP9Il3Fv8bSkxpDYNeSvp63 X-Received: by 2002:a65:47ca:: with SMTP id f10mr5232612pgs.166.1547579078718; Tue, 15 Jan 2019 11:04:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547579078; cv=none; d=google.com; s=arc-20160816; b=xWrIEM7kCNj/UDv24oGG3SRe9hHyT8cutY/BdDRyegKcmoAc4Su+ttqUGD+zR5QpAy sMG+/WpXzAKpHzzGjGxmkr5FuzlHPEzsEaNMMThtQwoCDlMSY1Jjc2drBOsyws/SYtAu rtJ+f+pmQAXVGNRPdohh8ACfg1wUPl3y/svTtQcK7qPWm+BBp4Ppz/MV44csqw1Imzw6 +QZ1hmPFdoNkJSXkS3O9zWg1N3XI/NHOXGpg/fyjDXwdByZEcSCNfap186buNOOgxfi1 uVhypt/W61s4IzDOotzojHDFruaZnXHcbmq/M1Yl6u8fBbIumScFyVLOc0stqKsfiRH4 r1tg== 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=L4ORP5hMXfMPE7azW13cKWXwVzDIkDQKNUWnKxKr6C4=; b=m+3WgRppqIyDje8kGueyBtenFWPycdVeVAhXEAM71j170ZeX/cRb0lr2iPOvfnPXAS WIhMuH8UHLvn8tTS9fBRY5179bmjWv3wcTgi96XD5bhgnvLgLegN0AMYhPGCcSJfb32R BPgh5jUZxlZIgRe/DwZFYGq4q1Ul5be4Xm54Fa3w6kkQHqxilOKVZf/Wy9xPeuS6W3Zb kWekwbO/bjhKHXEp1K3p7MhWUSdJPp6T89iSqoI8eQwyeEsupT8f1T4EIJ9eWLjH2iBU PltfHBnAsuo4qdzlr1Na0JMDmhRXKD0jV4rW4bV1vIoek6PhqJKkraoQlhspLj+FvzSa 8F+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XUOzSdhM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10si4133429pgt.343.2019.01.15.11.04.18; Tue, 15 Jan 2019 11:04:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XUOzSdhM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731387AbfAOQKL (ORCPT + 99 others); Tue, 15 Jan 2019 11:10:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:39982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728498AbfAOQKL (ORCPT ); Tue, 15 Jan 2019 11:10:11 -0500 Received: from guoren-Inspiron-7460 (23.83.240.247.16clouds.com [23.83.240.247]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D8EF620645; Tue, 15 Jan 2019 16:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547568610; bh=0MnOS9LDHfl8BmPZHjoV1rOe8OZATuZFEWUAuHMahFw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XUOzSdhMI5ILmXbe7dicd/dIWlXWpSrCbhSQZUPAJGReMgRo4ArAZOajAeYXyBT5S yKkFrTfdP1kDSzTQmUJho0xHnvH1DFL5/skcYIjN/nwt1w6yhhAl4I3N1aKwY/KOV4 pPpX9NYXthM1opr6SdXLUSGYgal9nELivanud8hE= Date: Wed, 16 Jan 2019 00:10:00 +0800 From: Guo Ren To: Christoph Hellwig Cc: 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 Subject: Re: [PATCH] riscv: fixup max_low_pfn with PFN_DOWN. Message-ID: <20190115161000.GA22705@guoren-Inspiron-7460> References: <1547280987-7630-1-git-send-email-guoren@kernel.org> <20190115153613.GC26443@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190115153613.GC26443@infradead.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 15, 2019 at 07:36:13AM -0800, Christoph Hellwig wrote: > On Sat, Jan 12, 2019 at 04:16:27PM +0800, guoren@kernel.org wrote: > > From: Guo Ren > > > > max_low_pfn should be pfn_size not byte_size. > > > > Signed-off-by: Guo Ren > > Signed-off-by: Mao Han > > Cc: Palmer Dabbelt > > Cc: Albert Ou > > --- > > arch/riscv/kernel/setup.c | 2 +- > > arch/riscv/mm/init.c | 3 ++- > > 2 files changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c > > index fc8006a..5463e67 100644 > > --- a/arch/riscv/kernel/setup.c > > +++ b/arch/riscv/kernel/setup.c > > @@ -174,7 +174,7 @@ static void __init setup_bootmem(void) > > BUG_ON(mem_size == 0); > > > > 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? > > > > > #ifdef CONFIG_BLK_DEV_INITRD > > setup_initrd(); > > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c > > index 1d9bfaf..658ebf6 100644 > > --- a/arch/riscv/mm/init.c > > +++ b/arch/riscv/mm/init.c > > @@ -28,7 +28,8 @@ static void __init zone_sizes_init(void) > > unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, }; > > > > #ifdef CONFIG_ZONE_DMA32 > > - max_zone_pfns[ZONE_DMA32] = PFN_DOWN(min(4UL * SZ_1G, max_low_pfn)); > > + max_zone_pfns[ZONE_DMA32] = PFN_DOWN(min(4UL * SZ_1G, > > + (unsigned long) PFN_PHYS(max_low_pfn))); > > #endif > > Same comment as above here, plus I think we should just use > memblock_end_of_DRAM directly, e.g. something like: > > static const phys_addr_t max_dma32_addr = 4UL * SZ_1G; > > max_zone_pfns[ZONE_DMA32] = > min(memblock_end_of_DRAM(), max_dma32_addr) >> PAGE_SHIFT; Em... The meaning of PFN_PHYS(max_low_pfn) != memblock_end_of_DRAM() in 32-bit highmem system. Of cause, riscv doesn't support highmem, so I think memblock_end_of_DRAM() is also OK. But... static void __init zone_sizes_init(void) { unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, }; #ifdef CONFIG_ZONE_DMA32 max_zone_pfns[ZONE_DMA32] = PFN_DOWN(min(4UL * SZ_1G, max_low_pfn)); #endif max_zone_pfns[ZONE_NORMAL] = max_low_pfn; free_area_init_nodes(max_zone_pfns); } The max_low_pfn also used by ZONE_NORMAL, So shall we need change that? max_zone_pfns[ZONE_NORMAL] = PFN_DOWN(memblock_end_of_DRAM()); ^^^^^^^^ also must >> PAGE_SHIFT? 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 Best Regards Guo Ren