From: Greentime Hu <greentime.hu@sifive.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>,
linux-mm@vger.kernel.org, Greentime Hu <green.hu@gmail.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
Olof Johansson <olof@lixom.net>,
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: Thu, 15 Aug 2019 17:31:52 +0800 [thread overview]
Message-ID: <CAHCEeh+us9N5_AMAJp41Ob9R9PD=JfWLcUrU+gU54xf8NKddJw@mail.gmail.com> (raw)
In-Reply-To: <8b7b6285-dd85-5895-8653-be1f6f08cca8@deltatee.com>
Hi Logan,
On Thu, Aug 15, 2019 at 6:21 AM Logan Gunthorpe <logang@deltatee.com> wrote:
>
> Hey,
>
> On 2019-08-14 7:35 a.m., Greentime Hu wrote:
> > How about this fix? Not sure if it is good for everyone.
>
> I applied your fix to the patch and it seems ok. But it doesn't seem to
> work on a recent version of the kernel. Have you got it working on v5.3?
> It seems the following patch breaks things:
>
> 671f9a3e2e24 ("RISC-V: Setup initial page tables in two stages")
>
> I don't really have time right now to debug this any further.
>
I just tried v5.3-rc4 and it failed. I try to debug this case.
I found it failed might be because of an unmapped virtual address is used
in memblocks_present() -> memblock_alloc ().
In this commit 671f9a3e2e24 ("RISC-V: Setup initial page tables in two
stages"), it finishes all the VA/PA mapping after setup_vm_final() is
called.
So we have to call memblocks_present() and sparse_init() right after
setup_vm_final().
Here is my patch and I tested with memory-with-hole.
It can boot normally in Unleashed board after applying this patch.
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 27d1d847fb2d..35aacb0c93e5 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -138,8 +138,6 @@ void __init setup_bootmem(void)
PFN_PHYS(end_pfn - start_pfn),
&memblock.memory, 0);
}
- memblocks_present();
- sparse_init();
}
unsigned long va_pa_offset;
@@ -452,6 +450,8 @@ static void __init setup_vm_final(void)
void __init paging_init(void)
{
setup_vm_final();
+ memblocks_present();
+ sparse_init();
setup_zero_page();
zone_sizes_init();
}
Test case:
memory@80000000 {
device_type = "memory";
reg = <0x0 0x80000000 0x0 0x80000000>;
};
memory@180000000 {
device_type = "memory";
reg = <0x1 0x80000000 0x0 0x40000000>;
};
# cat /proc/meminfo
MemTotal: 3003496 kB
MemFree: 2986584 kB
MemAvailable: 2970176 kB
Buffers: 0 kB
Cached: 3540 kB
SwapCached: 0 kB
Active: 3920 kB
Inactive: 68 kB
Active(anon): 3920 kB
Inactive(anon): 68 kB
Active(file): 0 kB
Inactive(file): 0 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 528 kB
Mapped: 1984 kB
Shmem: 3540 kB
KReclaimable: 688 kB
Slab: 5700 kB
SReclaimable: 688 kB
SUnreclaim: 5012 kB
KernelStack: 424 kB
PageTables: 80 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1501748 kB
Committed_AS: 3200 kB
VmallocTotal: 67108863 kB
VmallocUsed: 12 kB
VmallocChunk: 0 kB
Percpu: 272 kB
# uname -a
Linux buildroot 5.3.0-rc4-00001-g44404421c481-dirty #10 SMP Thu Aug 15
16:28:24 DST 2019 riscv64 GNU/Lin[ 2352.443621] random: fast init done
ux
# zcat /proc/config.gz |grep SPARSE
CONFIG_SPARSE_IRQ=y
CONFIG_ARCH_SPARSEMEM_ENABLE=y
CONFIG_SPARSEMEM_MANUAL=y
CONFIG_SPARSEMEM=y
CONFIG_SPARSEMEM_EXTREME=y
CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y
CONFIG_SPARSEMEM_VMEMMAP=y
# CONFIG_INPUT_SPARSEKMAP is not set
_______________________________________________
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-15 9:32 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
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 [this message]
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='CAHCEeh+us9N5_AMAJp41Ob9R9PD=JfWLcUrU+gU54xf8NKddJw@mail.gmail.com' \
--to=greentime.hu@sifive.com \
--cc=andrew@sifive.com \
--cc=aou@eecs.berkeley.edu \
--cc=green.hu@gmail.com \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@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 \
/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).