Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp900380imu; Wed, 16 Jan 2019 09:18:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN6II3Lb7u37rnQZQEzYkd4QTdoU+fDtVgpIhnyrg17Z/sYWIqSjwN5hugDx/7PI05u3CSjE X-Received: by 2002:a17:902:9006:: with SMTP id a6mr10788499plp.334.1547659137513; Wed, 16 Jan 2019 09:18:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547659137; cv=none; d=google.com; s=arc-20160816; b=wITDMkJOKBdEdw2uVZHHOGGjw5G5hT2W+Xx1Fd96wLcWviA9jlYKXplDD3eLToo/5M BU1yii9JgKjjaaMo4J8owxQ07zaTdwNTJmJTlq7/5BqVCRW129Pp/Q5W/tWt1cyhlIvc t1b5ZcCIcX4XK8q4mTcpRfDlYqIt+Eovk7fNAN4ymLzYkehrnHpK32LcVtOcMT+oeTBh kTcMPptn0FQzMkZG/gr5oDLCG6Ufyi3OsSzwbMmdEJY0YQr6RO6urw/WM9QM2sOCk00U xyxQ22P5EZ6sR4zkuFYS0++2YCFtUb1wo2WU9YpOwkAeJsymEjlZw5xhshlIu+6NtfQc Jrtg== 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=VK6wsvwiq6P7NLIr6Bg73aaua6jieUdXsnqiEL46THQ=; b=INzepgNB+IV+eXrpui+rubRR6dXVSFHm73xS12b7A1MT989CAXpld++E4Xcj53TCQB XPY26+HuSrD3lw3S6Fe3g08yr4RQqY+zHVO0hNua+wPkchFC1QXutD9oZnXzyvNJb2nh Lj2C4/GmPTw9Bd2ISzZXgCZuTd1hYF0jimRI6vhr/d7fiMsWmqE1gCyCA/y06AT3MCOk tj3twe8aBb43h4cxADG/s1u4FY3Xedg+osMyzE/2vXxXWCieSjfdsCII8+upLlfmJ/0h RV6LlV+xO1R6aFNLSHDGFzjwk3xvMemDlHme2Ioyd2t0zPq0g+sgC/9RDbthPCMC837L h5pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iSVF+jml; 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 r7si2312435pfb.237.2019.01.16.09.18.36; Wed, 16 Jan 2019 09:18:57 -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=iSVF+jml; 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 S1727077AbfAPBHq (ORCPT + 99 others); Tue, 15 Jan 2019 20:07:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:60966 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726841AbfAPBHq (ORCPT ); Tue, 15 Jan 2019 20:07:46 -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 E848D20866; Wed, 16 Jan 2019 01:07:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547600865; bh=ZKHy6uhrsc1OV/zqKQdyUh6VIzyaCN0wZnffuBGFBkQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iSVF+jmlly0DpAVrHjRwcPCszGEAXfIEG1TZOaVWJwPi831eV4DmFvN6v2TFacdCB sZ1Wmv465jpU8D0RxbB/zCWrnIDfO2Z8kCvG71AzzAL7ogcG2Nrx1qfpVmids6QIX0 +7zvZDHEi3lES/o0TLybbFZo9j5YG0eRIb9gWWNI= Date: Wed, 16 Jan 2019 09:07:38 +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: <20190116010738.GA4817@guoren-Inspiron-7460> References: <1547280987-7630-1-git-send-email-guoren@kernel.org> <20190115153613.GC26443@infradead.org> <20190115161000.GA22705@guoren-Inspiron-7460> <20190115161254.GA19081@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190115161254.GA19081@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 Hi Christoph, I use PFN_DOWN() every where as possible and seems it's a habit problem. So let risc-v maintainer to choose "PFN_DOW()" or ">> PAGE_SHIFT". Also the same with "end_of_DRAM & max_low_pfn". Best Regards Guo Ren On Tue, Jan 15, 2019 at 08:12:54AM -0800, Christoph Hellwig wrote: > 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.