Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4970027imu; Tue, 15 Jan 2019 08:59:00 -0800 (PST) X-Google-Smtp-Source: ALg8bN5qfBqhKK1Ic4ig0zWDkPeDu0NZlSf54FLJBsgW+38yR2bBsRdemxGGuCEVfuJAoXt6h6YM X-Received: by 2002:a17:902:4624:: with SMTP id o33mr4943595pld.289.1547571540807; Tue, 15 Jan 2019 08:59:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547571540; cv=none; d=google.com; s=arc-20160816; b=rCpzdMpQfa3tuduoEVg/e5qfg9qb3UP5FvTw437dN8hNzVVNtuXyIoFIKSAlbiL6rz RmAcOIk5dMz/CkxQkmCcQWcMXSpmeaRmhZJy/QIIR5u0SmDTFCh8GjXQU9hkh5x/9nBt diZy0heJhSBL5CKXgJvdrFfHRCM7CXZ/N9Pm4ZfqgnnJYGzNF0A7aMwerwAtQgwGNDUg iz7buO/pJ3hizkPPXdQZJy7phTuhR6XRzPpXfxD2zlWsiWVGKv4yiq8vGd6roZD4w32q MZLaLOtEz9FEOrt4GWfin8y4BDkWn8cNIhUu8ylx9SVfNzxwlxqep1M1ppRO6zglegsx W8hw== 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=OcDt7TWKrclSFkfWyryNYOz6oQ1jOA1snrF0soX+2go=; b=LC+bxFd7OhktI+uJtlGyR5UK8xPiPgqWyVHN+qX2xHlRm2qVGkEetOzG26+PQcAD7w 18W0tDyzl8k1b2scTo6at9j3WQnj2trkyCy2iLRJXOinvj9qHGcLJQIbG3qoihhtmU/0 OvrZWow3A+JmkI18Gz9AJFgXOejRwX6jVwG1tWb3Fpigd661Acv6iFyCMEh6Fai51OcN Y1xRPIQozsPMFeR1t2oDFYAvPTrV49mHYb2YrbKc4NwSXUEPrUiUmP7RQhWzuQEGT+OP jvnBgx8oR7GaHDZ0QaLGDVm/ZGDmsoyWOdwQaBmezQkHQip/8O9EeFbd+zIMOXKhxG7L 20NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=XKL7xsKa; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8si3455604pgc.580.2019.01.15.08.58.44; Tue, 15 Jan 2019 08:59:00 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=XKL7xsKa; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730125AbfAOQM5 (ORCPT + 99 others); Tue, 15 Jan 2019 11:12:57 -0500 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 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=OcDt7TWKrclSFkfWyryNYOz6oQ1jOA1snrF0soX+2go=; b=XKL7xsKaAsmZs5Zyks9eqZmtX PUvSDfBkK42XtZ0PYviMYzUUl+QPNCUMSMU9Ujiega1l4pKwPhdOSUex2JCSjarXn3erUdxd+5P8f UPMt+5ofxIQS1oG6xhxsd5gPg3U0j3Ch6OBKbmABOoQxwwytPltH/nDKFqifIy9r3I8eyy1LVwLFA CMCjH1EOrkz5ArqoasgcBs1z/w/cqZKPeibWw74mvXrRNnrZhlXgAsdCzBUR+2QQ6ctY9AVZYq9Ev aqRdwaLzlgHfICkZ53eU8pjOb6r+5sABk+P0G1pQvezxt5iBWEISBxxolfaNe/IXKDXjiRu4BHYC3 qcCX2Ssjw==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gjRKg-00053I-Jy; Tue, 15 Jan 2019 16:12:54 +0000 Date: Tue, 15 Jan 2019 08:12:54 -0800 From: Christoph Hellwig 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 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> User-Agent: Mutt/1.9.2 (2017-12-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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.