2021-05-26 07:53:41

by Guo Ren

[permalink] [raw]
Subject: [PATCH V4 1/2] riscv: Fixup _PAGE_GLOBAL in _PAGE_KERNEL

From: Guo Ren <[email protected]>

Kernel virtual address translation should avoid to use ASIDs or it'll
cause more TLB-miss and TLB-refill. Because the current ASID in satp
belongs to the current process, but the target kernel va TLB entry's
ASID still belongs to the previous process.

Signed-off-by: Guo Ren <[email protected]>
Reviewed-by: Anup Patel <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Cc: Palmer Dabbelt <[email protected]>
---
arch/riscv/include/asm/pgtable.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index 9469f46..346a3c6 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -134,7 +134,8 @@
| _PAGE_WRITE \
| _PAGE_PRESENT \
| _PAGE_ACCESSED \
- | _PAGE_DIRTY)
+ | _PAGE_DIRTY \
+ | _PAGE_GLOBAL)

#define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
#define PAGE_KERNEL_READ __pgprot(_PAGE_KERNEL & ~_PAGE_WRITE)
--
2.7.4


2021-05-29 23:45:09

by Palmer Dabbelt

[permalink] [raw]
Subject: Re: [PATCH V4 1/2] riscv: Fixup _PAGE_GLOBAL in _PAGE_KERNEL

On Tue, 25 May 2021 22:49:20 PDT (-0700), [email protected] wrote:
> From: Guo Ren <[email protected]>
>
> Kernel virtual address translation should avoid to use ASIDs or it'll
> cause more TLB-miss and TLB-refill. Because the current ASID in satp
> belongs to the current process, but the target kernel va TLB entry's
> ASID still belongs to the previous process.

Sorry, I still can't quite figure out what this is trying to say. I
went ahead and re-wrote the commit text to

riscv: Use global mappings for kernel pages

We map kernel pages into all addresses spages, so they can be marked as
global. This allows hardware to avoid flushing the kernel mappings when
moving between address spaces.

LMK if I'm misunderstanding something here, it's on for-next.

>
> Signed-off-by: Guo Ren <[email protected]>
> Reviewed-by: Anup Patel <[email protected]>
> Reviewed-by: Christoph Hellwig <[email protected]>
> Cc: Palmer Dabbelt <[email protected]>
> ---
> arch/riscv/include/asm/pgtable.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
> index 9469f46..346a3c6 100644
> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h
> @@ -134,7 +134,8 @@
> | _PAGE_WRITE \
> | _PAGE_PRESENT \
> | _PAGE_ACCESSED \
> - | _PAGE_DIRTY)
> + | _PAGE_DIRTY \
> + | _PAGE_GLOBAL)
>
> #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
> #define PAGE_KERNEL_READ __pgprot(_PAGE_KERNEL & ~_PAGE_WRITE)

2021-05-30 05:37:22

by Guo Ren

[permalink] [raw]
Subject: Re: [PATCH V4 1/2] riscv: Fixup _PAGE_GLOBAL in _PAGE_KERNEL

On Sun, May 30, 2021 at 7:42 AM <[email protected]> wrote:
>
> On Tue, 25 May 2021 22:49:20 PDT (-0700), [email protected] wrote:
> > From: Guo Ren <[email protected]>
> >
> > Kernel virtual address translation should avoid to use ASIDs or it'll
> > cause more TLB-miss and TLB-refill. Because the current ASID in satp
> > belongs to the current process, but the target kernel va TLB entry's
> > ASID still belongs to the previous process.
>
> Sorry, I still can't quite figure out what this is trying to say. I
> went ahead and re-wrote the commit text to
>
> riscv: Use global mappings for kernel pages
>
> We map kernel pages into all addresses spages, so they can be marked as
> global. This allows hardware to avoid flushing the kernel mappings when
> moving between address spaces.
Okay

>
> LMK if I'm misunderstanding something here, it's on for-next.
>
> >
> > Signed-off-by: Guo Ren <[email protected]>
> > Reviewed-by: Anup Patel <[email protected]>
> > Reviewed-by: Christoph Hellwig <[email protected]>
> > Cc: Palmer Dabbelt <[email protected]>
> > ---
> > arch/riscv/include/asm/pgtable.h | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
> > index 9469f46..346a3c6 100644
> > --- a/arch/riscv/include/asm/pgtable.h
> > +++ b/arch/riscv/include/asm/pgtable.h
> > @@ -134,7 +134,8 @@
> > | _PAGE_WRITE \
> > | _PAGE_PRESENT \
> > | _PAGE_ACCESSED \
> > - | _PAGE_DIRTY)
> > + | _PAGE_DIRTY \
> > + | _PAGE_GLOBAL)
> >
> > #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
> > #define PAGE_KERNEL_READ __pgprot(_PAGE_KERNEL & ~_PAGE_WRITE)



--
Best Regards
Guo Ren

ML: https://lore.kernel.org/linux-csky/