Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1457422imu; Wed, 23 Jan 2019 18:02:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN6YWzJRIcXcVRXd9hd2cGlB5E3K5UdrZQzz4LC7onOqgs/F7Vy6Lb2kUoP2qtb85dgoT1Ls X-Received: by 2002:a62:3a04:: with SMTP id h4mr4454044pfa.119.1548295340340; Wed, 23 Jan 2019 18:02:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548295340; cv=none; d=google.com; s=arc-20160816; b=lqAxSGusHDldxAirvrHKWroHE3Z/lssj4Oz11y4w3y+VmJ6mPdShquI1Gx5PnXVGVk ugm+IenHT6MTuEmVT+dFcRmddMrChTJOUjBHnqEz1Ew5jjM7wllEwYKvxTAoEOfAwuJD eKbQCuNiHsubkAqqQ1vPtWgwmbWTVq05usE7kxWX5YJJb34cc3OjsGx1SE1ZfjfP+WqB 8tFOZi0cS+gABgFpdVe3C7osx11ypi4REdd0x3ysiXDaONo/Yw/bxwh6Cg3nMT/4XdvV bFhT9yWcTF8FNiiL/+ILNx0ed/1a+UTeUArKmwIQhe9aSubHe635vsAtyTMoa4DClGRD P72A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=YBIIZ8XOcYpaFmWKBLCH70Y4SkewX00OSYFAAy95m8A=; b=sfeHzprSEbIt32iogn/NzTvUx9ZnFc79PEprcrKyYhjUUS+TasNvQj/pZ4M89+qVhc 5GxaVAo+bQZCRXkoh3Z/U9jl80VyIn6Giir4HoDAEjTX7YJuerDWEJKW033QSTD9YtF6 7ZhalAsDjUI2tV5RxRpk5QpVloXCdOT+yUHMBrhCrgAqsEMVGFYT3tLYS3ZjMHpTW41m YBAGE8O7QO0pGi4/n2LczJyQHqjmJoczkY3xQzWKG+RxqxvI7rifXThRzFuOqlCzd2jU vvFyxkhiD8Lbm18wklSE2/Di64jmRFhe1y8DSEb+ax04vp4oKV+22RUk/CMFrkrDwUTL cyrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=lCyVnoKI; 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 d32si18219196pla.136.2019.01.23.18.02.03; Wed, 23 Jan 2019 18:02:20 -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=@sifive.com header.s=google header.b=lCyVnoKI; 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 S1726783AbfAXCAi (ORCPT + 99 others); Wed, 23 Jan 2019 21:00:38 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38886 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726313AbfAXCAh (ORCPT ); Wed, 23 Jan 2019 21:00:37 -0500 Received: by mail-pf1-f196.google.com with SMTP id q1so2159990pfi.5 for ; Wed, 23 Jan 2019 18:00:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=YBIIZ8XOcYpaFmWKBLCH70Y4SkewX00OSYFAAy95m8A=; b=lCyVnoKIkk13kXnT5OyBWlkSBrMkjmiKfZb1cw8X7hf/TaVeMiXGHG2vGBHbjUY0vl 3Dzm18NzkKFFaSB8vx31/DYYZGug1K1gZsuggbRZnysemxJcO8q6ty9NWUduAM1tXhuw +pRzYFA8K9IisgQCQ5gfHIAtHEbYbMcY5RrXiCEBrastikdjo/phXweL+VSMip1xVEju 7bUNeaNkwY7C9tbWIu2jOmmir9+9xaAVyWUoUISUow5fJ2gacNQHvqpe84LTEsR8K8D6 7rM2vxHhpRWQ//2oCAG4+IYAQws+HLByct+pQ6rGiBA0MnVJCFZvTxG8NDXR6hZC5Hwo stFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=YBIIZ8XOcYpaFmWKBLCH70Y4SkewX00OSYFAAy95m8A=; b=YkEgX35EcYwskcjFS1OrpV2aRYMAbhMLkV5mGkiJsnyBEGwyXUm7Yn/RvOi/neO6PQ P1BeZcO569aMy3POmoyVFWnxzMMgFeZZPdZUQJxXicIcA3VQ38bULrAtL0WRHC7cIGbm 705wHofgH2cJm3bJ9CfszVGkUz8fUAvZyyrzPMdcWSvwQA11FrunvKy/KpWSpQRoWRHd vdQr9AVNsRuM1UMGBG2RDi9McifFRpwLLh+mffcFKauCmgo3PA2pIuwYtsEmJ96FkBP4 uloF6EhIxVY98efsY2UYFuV3QJit8nT49vfvHm3p7HyBNPjhepOHTd+MmLNqXLM8cgue l4Iw== X-Gm-Message-State: AJcUukekB/8NTaur9FQoMxEY7Z933dpKYDep4JUQDyVGzvNrpStZRbr3 Nv8ktHa1JXCW9P8w0ZwNZy9cYw== X-Received: by 2002:a62:2b8b:: with SMTP id r133mr4477658pfr.246.1548295236700; Wed, 23 Jan 2019 18:00:36 -0800 (PST) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id f20sm24636364pfn.177.2019.01.23.18.00.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 18:00:35 -0800 (PST) Date: Wed, 23 Jan 2019 18:00:35 -0800 (PST) X-Google-Original-Date: Wed, 23 Jan 2019 17:51:28 PST (-0800) Subject: Re: [PATCH] riscv: fixup max_low_pfn with PFN_DOWN. In-Reply-To: <20190116010738.GA4817@guoren-Inspiron-7460> CC: Christoph Hellwig , aou@eecs.berkeley.edu, linux-arch@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, ren_guo@c-sky.com, mao_han@c-sky.com From: Palmer Dabbelt To: guoren@kernel.org Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 15 Jan 2019 17:07:38 PST (-0800), guoren@kernel.org wrote: > 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". PFN_DOWN makes sense to me, as that's what we're trying to do here (round a physical address down to page frame number). Am a I misunderstanding something? > > 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.