From: Greentime Hu <green.hu@gmail.com>
To: Logan Gunthorpe <logang@deltatee.com>
Cc: Rob Herring <robh@kernel.org>, Albert Ou <aou@eecs.berkeley.edu>,
Andrew Waterman <andrew@sifive.com>,
Palmer Dabbelt <palmer@sifive.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Stephen Bates <sbates@raithlin.com>, Zong Li <zong@andestech.com>,
paul.walmsley@sifive.com, Olof Johansson <olof@lixom.net>,
greentime.hu@sifive.com, linux-riscv@lists.infradead.org,
Michael Clark <michaeljclark@mac.com>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v4 2/2] RISC-V: Implement sparsemem
Date: Sat, 10 Aug 2019 01:01:50 +0800 [thread overview]
Message-ID: <CAEbi=3ebNM-t_vA4OA7KCvQUF08o6VmL1j=kMojVnYsYsN_fBw@mail.gmail.com> (raw)
In-Reply-To: <0926a261-520e-4c40-f926-ddd40bb8ce44@deltatee.com>
Hi Logan,
Logan Gunthorpe <logang@deltatee.com> 於 2019年8月9日 週五 下午11:47寫道:
>
>
>
> 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.
>
Thank you for point me out that. I just checked the generic
implementation and I should use that one.
Sorry I didn't check the generic one and just implement it again.
I think the only patch we need is the first part to use generic
pfn_valid(). I just tested it and yes it can boot successfully in dts
with hole.
It will fail in this check ((pfn)-pfn_base) < max_mapnr.
In my test case it will be
((6GB>>PAGE_SHIFT)-(2GB>>PAGE_SHIFT)=(4GB>>PAGE_SHIFT) <
(3GB>>PAGE_SHIFT) to return false.
memory@80000000 {
device_type = "memory";
reg = <0x0 0x80000000 0x0 0x80000000>;
};
memory@180000000 {
device_type = "memory";
reg = <0x1 0x80000000 0x0 0x40000000>;
};
To cause the check here failed to initialize page struct.
for (pfn = start_pfn; pfn < end_pfn; pfn++) {
/*
* There can be holes in boot-time mem_map[]s handed to this
* function. They do not exist on hotplugged memory.
*/
if (context == MEMMAP_EARLY) {
if (!early_pfn_valid(pfn))
continue;
if (!early_pfn_in_nid(pfn, nid))
continue;
if (overlap_memmap_init(zone, &pfn))
continue;
if (defer_init(nid, pfn, end_pfn))
break;
}
page = pfn_to_page(pfn);
__init_single_page(page, pfn, zone, nid);
------------------------------------------------------------------------------
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..80d28fa1e2eb 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_SPARSEMEM_VMEMMAP)
#define pfn_valid(pfn) \
(((pfn) >= pfn_base) && (((pfn)-pfn_base) < max_mapnr))
+#endif
#define ARCH_PFN_OFFSET (pfn_base)
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2019-08-09 17:02 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-09 20:39 [PATCH v4 0/2] [PATCH v2 0/6] sparsemem support for RISC-V Logan Gunthorpe
2019-01-09 20:39 ` [PATCH v4 1/2] sh: mm: make use of new memblocks_present() helper Logan Gunthorpe
2019-01-15 13:58 ` Christoph Hellwig
2019-01-15 17:30 ` Logan Gunthorpe
2019-01-09 20:39 ` [PATCH v4 2/2] RISC-V: Implement sparsemem Logan Gunthorpe
2019-01-15 13:58 ` Christoph Hellwig
2019-07-31 6:30 ` Greentime Hu
2019-07-31 17:07 ` Logan Gunthorpe
2019-08-01 3:34 ` Greentime Hu
[not found] ` <CAEbi=3eZcgWevpX9VO9ohgxVDFVprk_t52Xbs3-TdtZ+js3NVA@mail.gmail.com>
2019-08-09 15:46 ` Logan Gunthorpe
2019-08-09 17:01 ` Greentime Hu [this message]
2019-08-09 19:03 ` Logan Gunthorpe
2019-08-12 4:01 ` Greentime Hu
2019-08-12 15:51 ` Logan Gunthorpe
2019-08-13 6:04 ` Greentime Hu
2019-08-13 16:14 ` Logan Gunthorpe
2019-08-13 16:39 ` Paul Walmsley
2019-08-13 16:48 ` Paul Walmsley
2019-08-13 16:49 ` Logan Gunthorpe
2019-08-14 13:35 ` Greentime Hu
2019-08-14 16:56 ` Logan Gunthorpe
2019-08-14 17:40 ` Paul Walmsley
2019-08-14 17:46 ` Logan Gunthorpe
2019-08-14 20:09 ` Paul Walmsley
2019-08-14 22:21 ` Logan Gunthorpe
2019-08-15 9:31 ` Greentime Hu
2019-08-15 16:20 ` Logan Gunthorpe
2019-08-16 2:07 ` Greentime Hu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAEbi=3ebNM-t_vA4OA7KCvQUF08o6VmL1j=kMojVnYsYsN_fBw@mail.gmail.com' \
--to=green.hu@gmail.com \
--cc=andrew@sifive.com \
--cc=aou@eecs.berkeley.edu \
--cc=greentime.hu@sifive.com \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=logang@deltatee.com \
--cc=michaeljclark@mac.com \
--cc=olof@lixom.net \
--cc=palmer@sifive.com \
--cc=paul.walmsley@sifive.com \
--cc=robh@kernel.org \
--cc=sbates@raithlin.com \
--cc=zong@andestech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).