* [PATCH] riscv: Fixup one-page wasting
@ 2021-11-24 6:05 guoren
2021-11-24 6:55 ` Anup Patel
0 siblings, 1 reply; 5+ messages in thread
From: guoren @ 2021-11-24 6:05 UTC (permalink / raw)
To: guoren
Cc: linux-kernel, linux-riscv, linux-csky, Guo Ren, Alexandre Ghiti,
Anup Patel, Atish Patra
From: Guo Ren <guoren@linux.alibaba.com>
For small memory systems(Allwinner D1s/F133), one page size memory
cannot be ignored.
Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Anup Patel <anup@brainfault.org>
Cc: Atish Patra <Atish.Patra@wdc.com>
---
arch/riscv/mm/init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 24b2b8044602..097bb3bc4020 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -241,9 +241,9 @@ unsigned long riscv_pfn_base __ro_after_init;
EXPORT_SYMBOL(riscv_pfn_base);
pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
-pgd_t trampoline_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
static pte_t fixmap_pte[PTRS_PER_PTE] __page_aligned_bss;
+pgd_t trampoline_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
pgd_t early_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
static pmd_t __maybe_unused early_dtb_pmd[PTRS_PER_PMD] __initdata __aligned(PAGE_SIZE);
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] riscv: Fixup one-page wasting
2021-11-24 6:05 [PATCH] riscv: Fixup one-page wasting guoren
@ 2021-11-24 6:55 ` Anup Patel
2021-11-24 7:22 ` Guo Ren
0 siblings, 1 reply; 5+ messages in thread
From: Anup Patel @ 2021-11-24 6:55 UTC (permalink / raw)
To: Guo Ren
Cc: linux-kernel@vger.kernel.org List, linux-riscv, linux-csky,
Guo Ren, Alexandre Ghiti, Atish Patra
On Wed, Nov 24, 2021 at 11:35 AM <guoren@kernel.org> wrote:
>
> From: Guo Ren <guoren@linux.alibaba.com>
>
> For small memory systems(Allwinner D1s/F133), one page size memory
> cannot be ignored.
>
> Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
> Cc: Alexandre Ghiti <alex@ghiti.fr>
> Cc: Anup Patel <anup@brainfault.org>
> Cc: Atish Patra <Atish.Patra@wdc.com>
This PATCH breaks the CPU hotplug functionality.
When a CPU/HART is turned off and turned on at runtime, the
low-level relocate() will be called to enable MMU on the CPU
being brought-up which in-turn uses trampoline_pg_dir.
Regards,
Anup
> ---
> arch/riscv/mm/init.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index 24b2b8044602..097bb3bc4020 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -241,9 +241,9 @@ unsigned long riscv_pfn_base __ro_after_init;
> EXPORT_SYMBOL(riscv_pfn_base);
>
> pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
> -pgd_t trampoline_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
> static pte_t fixmap_pte[PTRS_PER_PTE] __page_aligned_bss;
>
> +pgd_t trampoline_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
> pgd_t early_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
> static pmd_t __maybe_unused early_dtb_pmd[PTRS_PER_PMD] __initdata __aligned(PAGE_SIZE);
>
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] riscv: Fixup one-page wasting
2021-11-24 6:55 ` Anup Patel
@ 2021-11-24 7:22 ` Guo Ren
2021-11-24 7:56 ` Anup Patel
0 siblings, 1 reply; 5+ messages in thread
From: Guo Ren @ 2021-11-24 7:22 UTC (permalink / raw)
To: Anup Patel
Cc: linux-kernel@vger.kernel.org List, linux-riscv, linux-csky,
Guo Ren, Alexandre Ghiti, Atish Patra
On Wed, Nov 24, 2021 at 2:55 PM Anup Patel <anup@brainfault.org> wrote:
>
> On Wed, Nov 24, 2021 at 11:35 AM <guoren@kernel.org> wrote:
> >
> > From: Guo Ren <guoren@linux.alibaba.com>
> >
> > For small memory systems(Allwinner D1s/F133), one page size memory
> > cannot be ignored.
> >
> > Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
> > Cc: Alexandre Ghiti <alex@ghiti.fr>
> > Cc: Anup Patel <anup@brainfault.org>
> > Cc: Atish Patra <Atish.Patra@wdc.com>
>
> This PATCH breaks the CPU hotplug functionality.
>
> When a CPU/HART is turned off and turned on at runtime, the
> low-level relocate() will be called to enable MMU on the CPU
> being brought-up which in-turn uses trampoline_pg_dir.
Yeah, I forgot that.
How about removing trampoline_pg_dir totally and using
early_pg_dir/swapper_pg_dir for relocate directly?
>
> Regards,
> Anup
>
> > ---
> > arch/riscv/mm/init.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> > index 24b2b8044602..097bb3bc4020 100644
> > --- a/arch/riscv/mm/init.c
> > +++ b/arch/riscv/mm/init.c
> > @@ -241,9 +241,9 @@ unsigned long riscv_pfn_base __ro_after_init;
> > EXPORT_SYMBOL(riscv_pfn_base);
> >
> > pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
> > -pgd_t trampoline_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
> > static pte_t fixmap_pte[PTRS_PER_PTE] __page_aligned_bss;
> >
> > +pgd_t trampoline_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
> > pgd_t early_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
> > static pmd_t __maybe_unused early_dtb_pmd[PTRS_PER_PMD] __initdata __aligned(PAGE_SIZE);
> >
> > --
> > 2.25.1
> >
--
Best Regards
Guo Ren
ML: https://lore.kernel.org/linux-csky/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] riscv: Fixup one-page wasting
2021-11-24 7:22 ` Guo Ren
@ 2021-11-24 7:56 ` Anup Patel
2021-11-24 11:09 ` Guo Ren
0 siblings, 1 reply; 5+ messages in thread
From: Anup Patel @ 2021-11-24 7:56 UTC (permalink / raw)
To: Guo Ren
Cc: linux-kernel@vger.kernel.org List, linux-riscv, linux-csky,
Guo Ren, Alexandre Ghiti, Atish Patra
On Wed, Nov 24, 2021 at 12:52 PM Guo Ren <guoren@kernel.org> wrote:
>
> On Wed, Nov 24, 2021 at 2:55 PM Anup Patel <anup@brainfault.org> wrote:
> >
> > On Wed, Nov 24, 2021 at 11:35 AM <guoren@kernel.org> wrote:
> > >
> > > From: Guo Ren <guoren@linux.alibaba.com>
> > >
> > > For small memory systems(Allwinner D1s/F133), one page size memory
> > > cannot be ignored.
> > >
> > > Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
> > > Cc: Alexandre Ghiti <alex@ghiti.fr>
> > > Cc: Anup Patel <anup@brainfault.org>
> > > Cc: Atish Patra <Atish.Patra@wdc.com>
> >
> > This PATCH breaks the CPU hotplug functionality.
> >
> > When a CPU/HART is turned off and turned on at runtime, the
> > low-level relocate() will be called to enable MMU on the CPU
> > being brought-up which in-turn uses trampoline_pg_dir.
> Yeah, I forgot that.
>
> How about removing trampoline_pg_dir totally and using
> early_pg_dir/swapper_pg_dir for relocate directly?
The trampoline_pg_dir is to handle the case when RAM is
large enough such that RAM physical address range overlaps
kernel virtual address range (i.e. VA >= PAGE_OFFSET). This
is overlap of virtual address range and physical address range
can be problematic for low-level code which is trying to enable
MMU (such as the relocate() function).
Here's a old kernel thread which tries to summarize this:
https://lore.kernel.org/lkml/CAAhSdy3URWHVY_GPNb2yRBuctRELRtTTWPM2OpwUVSRFAyXyiA@mail.gmail.com/
Regards,
Anup
>
> >
> > Regards,
> > Anup
> >
> > > ---
> > > arch/riscv/mm/init.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> > > index 24b2b8044602..097bb3bc4020 100644
> > > --- a/arch/riscv/mm/init.c
> > > +++ b/arch/riscv/mm/init.c
> > > @@ -241,9 +241,9 @@ unsigned long riscv_pfn_base __ro_after_init;
> > > EXPORT_SYMBOL(riscv_pfn_base);
> > >
> > > pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
> > > -pgd_t trampoline_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
> > > static pte_t fixmap_pte[PTRS_PER_PTE] __page_aligned_bss;
> > >
> > > +pgd_t trampoline_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
> > > pgd_t early_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
> > > static pmd_t __maybe_unused early_dtb_pmd[PTRS_PER_PMD] __initdata __aligned(PAGE_SIZE);
> > >
> > > --
> > > 2.25.1
> > >
>
>
>
> --
> Best Regards
> Guo Ren
>
> ML: https://lore.kernel.org/linux-csky/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] riscv: Fixup one-page wasting
2021-11-24 7:56 ` Anup Patel
@ 2021-11-24 11:09 ` Guo Ren
0 siblings, 0 replies; 5+ messages in thread
From: Guo Ren @ 2021-11-24 11:09 UTC (permalink / raw)
To: Anup Patel
Cc: linux-kernel@vger.kernel.org List, linux-riscv, linux-csky,
Guo Ren, Alexandre Ghiti, Atish Patra
On Wed, Nov 24, 2021 at 3:56 PM Anup Patel <anup@brainfault.org> wrote:
>
> On Wed, Nov 24, 2021 at 12:52 PM Guo Ren <guoren@kernel.org> wrote:
> >
> > On Wed, Nov 24, 2021 at 2:55 PM Anup Patel <anup@brainfault.org> wrote:
> > >
> > > On Wed, Nov 24, 2021 at 11:35 AM <guoren@kernel.org> wrote:
> > > >
> > > > From: Guo Ren <guoren@linux.alibaba.com>
> > > >
> > > > For small memory systems(Allwinner D1s/F133), one page size memory
> > > > cannot be ignored.
> > > >
> > > > Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
> > > > Cc: Alexandre Ghiti <alex@ghiti.fr>
> > > > Cc: Anup Patel <anup@brainfault.org>
> > > > Cc: Atish Patra <Atish.Patra@wdc.com>
> > >
> > > This PATCH breaks the CPU hotplug functionality.
> > >
> > > When a CPU/HART is turned off and turned on at runtime, the
> > > low-level relocate() will be called to enable MMU on the CPU
> > > being brought-up which in-turn uses trampoline_pg_dir.
> > Yeah, I forgot that.
> >
> > How about removing trampoline_pg_dir totally and using
> > early_pg_dir/swapper_pg_dir for relocate directly?
>
> The trampoline_pg_dir is to handle the case when RAM is
> large enough such that RAM physical address range overlaps
> kernel virtual address range (i.e. VA >= PAGE_OFFSET). This
> is overlap of virtual address range and physical address range
> can be problematic for low-level code which is trying to enable
> MMU (such as the relocate() function).
>
> Here's a old kernel thread which tries to summarize this:
> https://lore.kernel.org/lkml/CAAhSdy3URWHVY_GPNb2yRBuctRELRtTTWPM2OpwUVSRFAyXyiA@mail.gmail.com/
Got it. Thank you so much for sharing.
I would use the patch as private for F133 memory saving.
>
> Regards,
> Anup
>
> >
> > >
> > > Regards,
> > > Anup
> > >
> > > > ---
> > > > arch/riscv/mm/init.c | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> > > > index 24b2b8044602..097bb3bc4020 100644
> > > > --- a/arch/riscv/mm/init.c
> > > > +++ b/arch/riscv/mm/init.c
> > > > @@ -241,9 +241,9 @@ unsigned long riscv_pfn_base __ro_after_init;
> > > > EXPORT_SYMBOL(riscv_pfn_base);
> > > >
> > > > pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
> > > > -pgd_t trampoline_pg_dir[PTRS_PER_PGD] __page_aligned_bss;
> > > > static pte_t fixmap_pte[PTRS_PER_PTE] __page_aligned_bss;
> > > >
> > > > +pgd_t trampoline_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
> > > > pgd_t early_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
> > > > static pmd_t __maybe_unused early_dtb_pmd[PTRS_PER_PMD] __initdata __aligned(PAGE_SIZE);
> > > >
> > > > --
> > > > 2.25.1
> > > >
> >
> >
> >
> > --
> > Best Regards
> > Guo Ren
> >
> > ML: https://lore.kernel.org/linux-csky/
--
Best Regards
Guo Ren
ML: https://lore.kernel.org/linux-csky/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-11-24 11:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-24 6:05 [PATCH] riscv: Fixup one-page wasting guoren
2021-11-24 6:55 ` Anup Patel
2021-11-24 7:22 ` Guo Ren
2021-11-24 7:56 ` Anup Patel
2021-11-24 11:09 ` Guo Ren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox