Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1051430ybl; Wed, 14 Aug 2019 09:58:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqwgHlYeeYUSpirxuK+ibuqj/XhpZenHVE09wOzSGf4l/z8vnmlY+0a4sCistR9PnlUHi4aW X-Received: by 2002:a62:f24b:: with SMTP id y11mr969931pfl.0.1565801888721; Wed, 14 Aug 2019 09:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565801888; cv=none; d=google.com; s=arc-20160816; b=QzWMmNpMxoBKL98jq/RT2Ukrm38K1+/IAER8gOYrn9qjG2V2lokL8xNrDaKqzlU6Q2 ryRvhM1DmKvlsE+6ALGioEBM4/T6KpvTp58vaCJbdW6jTSPvvRczAl7IJouTVUa2AP+7 xL7O7LugR+MPoocChdPgQuWRhSJt6D4oEn7+qq9axn3YMtgxb3sfazwS6s1PNhuDaxzY Y0ZNVXRAQXVhZ8nYmVR6+we0CxJU6zsbGHit1wc/TySntRhfFAyr8KZ+ciPfeOgePfg7 5H7zdmplJ2Gyfa7SujxlGnP/pUI1xbgi9mhEy4u0bEtVlxBVtv1sohUR5bRvcb+oqnD/ ntTA== 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=oo89GqU58af2On4q4o3EoKQ2Vz6/iD7W7sMlp6RtItw=; b=gOdXvutW0C60GLhntHcVYmh6M9nnMnbILVCVmyet4wX3c2xj8qtpoVqPwHLswX1eiS yEsXUtxSlqbuWgyWro5b7Y/zbV266xJt4rrs6ID8XX9BIIlDe4k+b+sRx9YTtyrjpif+ eyy0mhiTYWFZtnlRBFi1o0BA6VtXP6WJWAPb3nhbDhgpJa0q66b+5Hr14uxd2o/HfDoK Vc1/S+wOWXazmQTyHe2oTGKdL5dS1CESyHifgd840tJx9UOER+nOlm2FDtQ/dhvnoFPh BQzVuEffTmv8H00E/9P6y39R9xrLHaX3W5DmCuLANdxjqfsAY5d5t1R9QxltgKphwfK5 EJHA== 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 j64si135051pge.556.2019.08.14.09.57.52; Wed, 14 Aug 2019 09:58:08 -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 S1728253AbfHNQ4t (ORCPT + 99 others); Wed, 14 Aug 2019 12:56:49 -0400 Received: from ale.deltatee.com ([207.54.116.67]:37072 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbfHNQ4s (ORCPT ); Wed, 14 Aug 2019 12:56:48 -0400 Received: from s0106ac1f6bb1ecac.cg.shawcable.net ([70.73.163.230] helo=[192.168.11.155]) by ale.deltatee.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1hxwZj-0007WM-Jh; Wed, 14 Aug 2019 10:56:41 -0600 To: Greentime Hu Cc: Paul Walmsley , Rob Herring , Albert Ou , Andrew Waterman , Palmer Dabbelt , Linux Kernel Mailing List , Stephen Bates , Olof Johansson , greentime.hu@sifive.com, linux-riscv@lists.infradead.org, Michael Clark , Christoph Hellwig , linux-mm@vger.kernel.org References: <20190109203911.7887-1-logang@deltatee.com> <20190109203911.7887-3-logang@deltatee.com> <0926a261-520e-4c40-f926-ddd40bb8ce44@deltatee.com> <96156909-1453-d487-ff66-a041d67c74d6@deltatee.com> <5506c875-9387-acc9-a7fe-5b7c10036c40@deltatee.com> From: Logan Gunthorpe Message-ID: <0d81412d-73fc-fa56-6f84-dedda72b9cc6@deltatee.com> Date: Wed, 14 Aug 2019 10:56:35 -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-US Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 70.73.163.230 X-SA-Exim-Rcpt-To: linux-mm@vger.kernel.org, hch@lst.de, michaeljclark@mac.com, linux-riscv@lists.infradead.org, greentime.hu@sifive.com, olof@lixom.net, 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, 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=-7.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,LR_URI_NUMERIC_ENDING 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-14 7:35 a.m., Greentime Hu wrote: > Logan Gunthorpe 於 2019年8月14日 週三 上午12:50寫道: >> >> On 2019-08-13 10:39 a.m., Paul Walmsley wrote: >>> On Tue, 13 Aug 2019, Logan Gunthorpe wrote: >>> >>>> On 2019-08-13 12:04 a.m., Greentime Hu wrote: >>>> >>>>> Every architecture with mmu defines their own pfn_valid(). >>>> >>>> Not true. Arm64, for example just uses the generic implementation in >>>> mmzone.h. >>> >>> arm64 seems to define their own: >>> >>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/Kconfig#n899 >> >> Oh, yup. My mistake. >> >>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/mm/init.c#n235 >>> >>> While there are many architectures which have their own pfn_valid(); >>> oddly, almost none of them set HAVE_ARCH_PFN_VALID ? >> >> Yes, much of this is super confusing. Seems HAVE_ARCH_PFN_VALID only >> matters if SPARSEMEM is set. So risc-v probably doesn't need to set it >> and we just need a #ifdef !CONFIG_FLATMEM around the pfn_valid >> definition like other arches. >> > > Maybe this commit explains why it used HAVE_ARCH_PFN_VALID instead of SPARSEMEM. > https://github.com/torvalds/linux/commit/7b7bf499f79de3f6c85a340c8453a78789523f85 > > BTW, I found another issue here. > #define FIXADDR_TOP (VMALLOC_START) > #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) > #define VMEMMAP_END (VMALLOC_START - 1) > #define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE) > These 2 regions are overlapped. > > How about this fix? Not sure if it is good for everyone. Yes, this looks good to me. I can fold these changes into my patch and send a v5 to the list. Thanks! Logan > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > index 3f12b069af1d..3c4d394679d0 100644 > --- a/arch/riscv/Kconfig > +++ b/arch/riscv/Kconfig > @@ -115,9 +115,6 @@ config PGTABLE_LEVELS > default 3 if 64BIT > default 2 > > -config HAVE_ARCH_PFN_VALID > - def_bool y > - > menu "Platform type" > > choice > diff --git a/arch/riscv/include/asm/fixmap.h b/arch/riscv/include/asm/fixmap.h > index c207f6634b91..72e106b60bc5 100644 > --- a/arch/riscv/include/asm/fixmap.h > +++ b/arch/riscv/include/asm/fixmap.h > @@ -26,7 +26,7 @@ enum fixed_addresses { > }; > > #define FIXADDR_SIZE (__end_of_fixed_addresses * PAGE_SIZE) > -#define FIXADDR_TOP (VMALLOC_START) > +#define FIXADDR_TOP (VMEMMAP_START) > #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) > > #define FIXMAP_PAGE_IO PAGE_KERNEL > diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h > index 8ddb6c7fedac..83830997dce6 100644 > --- a/arch/riscv/include/asm/page.h > +++ b/arch/riscv/include/asm/page.h > @@ -100,8 +100,10 @@ extern unsigned long min_low_pfn; > #define page_to_bus(page) (page_to_phys(page)) > #define phys_to_page(paddr) (pfn_to_page(phys_to_pfn(paddr))) > > +#if defined(CONFIG_FLATMEM) > #define pfn_valid(pfn) \ > (((pfn) >= pfn_base) && (((pfn)-pfn_base) < max_mapnr)) > +#endif > > #define ARCH_PFN_OFFSET (pfn_base)