Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp476378ybl; Fri, 9 Aug 2019 08:48:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJiH5OMgqgbnL1E5521rtQUapVTimDOhLf3FB6p/94TAJlItN54X/5XCnAvR+E7VboGNzQ X-Received: by 2002:a17:90a:380d:: with SMTP id w13mr9894620pjb.138.1565365683918; Fri, 09 Aug 2019 08:48:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565365683; cv=none; d=google.com; s=arc-20160816; b=ZIvmxlAXubLXWB3CoYhdxaEUuK6FYp6b6rOGjyTEviUTJp5BjGhxIpICi0dgRNeFpo fE9LxCQfCgr5RUoZR6dE1Al/E4V31bac30xhOrTAjI+E0WbOvZqLLxm34RAbQGv5b50Y hOjGTWZX0Kb4OAysU/HiORVEBAkXb9uBXkXONa6xwM+QdlfKBxXrN+vbyWuZZinQBkac FE5bP+f8PXahAKodCRTUhLHh/0cbLMgtQZetGQTOj6AqArU9p+Liv0xCp3N2b8C+W4o0 qwgB3MxRfD66Zfcm+hLQsqf9NCUNRRIMgCvrM3oA/HirtRqGSAlpkLfANyXEOihffy4D 9X1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to; bh=hnHNPd7VVlVgSmLvU8sBPdfKyTFu+0AKqgo8pzBXHPY=; b=L8MyTb4sV5Sjn3/1czeQC1vm3inInL1XwQxa7T2IhqWzVK0gQi0NzHIlb++Cda5/qx 3sUbT2oE/FM+3JL6Eb8irabhuN3cPwutq/G8RBeP1tl/CAfXGBwo7wHSHteCm32ReHE6 YyeMnvDgnPGosZ9o6N0OT9Y5oyd6RooBsO01Ehg7kEAvuE7gccarTLPmzzLT9Gk2Ar7k t1QVuiNX8cnGUxOIMTUSiDoxbXZfe55K9wnnbmRti8S6OtGu6glYr4M5m2Kwealm4tAS PCg8VbSyA5TI8Pwvcvfozw03/Oee6ui22TFR2edvU6Uf8xwgH/jQCfSDjALzLVjVJypL WvNQ== ARC-Authentication-Results: i=1; mx.google.com; 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 g98si4516465pje.92.2019.08.09.08.47.47; Fri, 09 Aug 2019 08:48:03 -0700 (PDT) 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; 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 S2436799AbfHIPrA (ORCPT + 99 others); Fri, 9 Aug 2019 11:47:00 -0400 Received: from ale.deltatee.com ([207.54.116.67]:45332 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436647AbfHIPrA (ORCPT ); Fri, 9 Aug 2019 11:47:00 -0400 Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.89) (envelope-from ) id 1hw76S-0000Nl-DT; Fri, 09 Aug 2019 09:46:53 -0600 To: Greentime Hu Cc: greentime.hu@sifive.com, paul.walmsley@sifive.com, Rob Herring , Albert Ou , Andrew Waterman , Palmer Dabbelt , Linux Kernel Mailing List , Stephen Bates , Zong Li , Olof Johansson , linux-riscv@lists.infradead.org, Michael Clark , Christoph Hellwig References: <20190109203911.7887-1-logang@deltatee.com> <20190109203911.7887-3-logang@deltatee.com> From: Logan Gunthorpe Message-ID: <0926a261-520e-4c40-f926-ddd40bb8ce44@deltatee.com> Date: Fri, 9 Aug 2019 09:46:49 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: hch@lst.de, michaeljclark@mac.com, linux-riscv@lists.infradead.org, olof@lixom.net, zong@andestech.com, sbates@raithlin.com, linux-kernel@vger.kernel.org, palmer@sifive.com, andrew@sifive.com, aou@eecs.berkeley.edu, robh@kernel.org, paul.walmsley@sifive.com, greentime.hu@sifive.com, green.hu@gmail.com X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [PATCH v4 2/2] RISC-V: Implement sparsemem X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-08-08 10:23 p.m., Greentime Hu wrote: > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > index 3f12b069af1d..208b3e14ccd8 100644 > --- a/arch/riscv/Kconfig > +++ b/arch/riscv/Kconfig > @@ -116,7 +116,8 @@ config PGTABLE_LEVELS >         default 2 > >  config HAVE_ARCH_PFN_VALID > -       def_bool y > +       bool > +       default !SPARSEMEM_VMEMMAP > >  menu "Platform type" > > diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h > index 8ddb6c7fedac..6991f7a5a4a7 100644 > --- a/arch/riscv/include/asm/page.h > +++ b/arch/riscv/include/asm/page.h > @@ -93,16 +93,20 @@ extern unsigned long min_low_pfn; >  #define virt_to_pfn(vaddr)     (phys_to_pfn(__pa(vaddr))) >  #define pfn_to_virt(pfn)       (__va(pfn_to_phys(pfn))) > > +#if !defined(CONFIG_SPARSEMEM_VMEMMAP) > +#define pfn_valid(pfn) \ > +       (((pfn) >= pfn_base) && (((pfn)-pfn_base) < max_mapnr)) >  #define virt_to_page(vaddr)    (pfn_to_page(virt_to_pfn(vaddr))) >  #define page_to_virt(page)     (pfn_to_virt(page_to_pfn(page))) > +#else > +#define virt_to_page(vaddr)    ((struct page *)((((u64)vaddr - > va_pa_offset) / PAGE_SIZE) * sizeof(struct page) + VMEMMAP_START)) > +#define page_to_virt(pg)       ((void *)(((((u64)pg - VMEMMAP_START) / > sizeof(struct page)) * PAGE_SIZE) + va_pa_offset)) > +#endif This doesn't make sense to me at all. It should always use pfn_to_page() for virt_to_page() and the generic pfn_to_page()/page_to_pfn() implementations essentially already do what you are doing in a cleaner way. So I'd be really surprised if this does anything at all. Logan