* [PATCH v4] riscv: mm: Remove the copy operation of pmd
@ 2022-04-01 2:43 ` Chuanhua Han
0 siblings, 0 replies; 4+ messages in thread
From: Chuanhua Han @ 2022-04-01 2:43 UTC (permalink / raw)
To: paul.walmsley, palmer, aou
Cc: alexandre.ghiti, jszhang, mhiramat, akpm, zhengqi.arch, ebiederm,
liushixin2, linux-riscv, linux-kernel, Chuanhua Han
Since all processes share the kernel address space,
we only need to copy pgd in case of a vmalloc page
fault exception, the other levels of page tables are
shared, so the operation of copying pmd is unnecessary.
Signed-off-by: Chuanhua Han <hanchuanhua@oppo.com>
---
Changes in v4:
-Modify incorrect author name.
Changes in v3:
-Change the real name of signed-off-by.
Changes in v2:
-Delete incorrect default signatures.
arch/riscv/mm/fault.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
index 4e9efbe46d5f..40694f0cab9e 100644
--- a/arch/riscv/mm/fault.c
+++ b/arch/riscv/mm/fault.c
@@ -102,9 +102,9 @@ static inline void bad_area(struct pt_regs *regs, struct mm_struct *mm, int code
static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long addr)
{
pgd_t *pgd, *pgd_k;
- pud_t *pud, *pud_k;
- p4d_t *p4d, *p4d_k;
- pmd_t *pmd, *pmd_k;
+ pud_t *pud_k;
+ p4d_t *p4d_k;
+ pmd_t *pmd_k;
pte_t *pte_k;
int index;
unsigned long pfn;
@@ -132,14 +132,12 @@ static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long a
}
set_pgd(pgd, *pgd_k);
- p4d = p4d_offset(pgd, addr);
p4d_k = p4d_offset(pgd_k, addr);
if (!p4d_present(*p4d_k)) {
no_context(regs, addr);
return;
}
- pud = pud_offset(p4d, addr);
pud_k = pud_offset(p4d_k, addr);
if (!pud_present(*pud_k)) {
no_context(regs, addr);
@@ -150,13 +148,11 @@ static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long a
* Since the vmalloc area is global, it is unnecessary
* to copy individual PTEs
*/
- pmd = pmd_offset(pud, addr);
pmd_k = pmd_offset(pud_k, addr);
if (!pmd_present(*pmd_k)) {
no_context(regs, addr);
return;
}
- set_pmd(pmd, *pmd_k);
/*
* Make sure the actual PTE exists as well to
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v4] riscv: mm: Remove the copy operation of pmd
@ 2022-04-01 2:43 ` Chuanhua Han
0 siblings, 0 replies; 4+ messages in thread
From: Chuanhua Han @ 2022-04-01 2:43 UTC (permalink / raw)
To: paul.walmsley, palmer, aou
Cc: alexandre.ghiti, jszhang, mhiramat, akpm, zhengqi.arch, ebiederm,
liushixin2, linux-riscv, linux-kernel, Chuanhua Han
Since all processes share the kernel address space,
we only need to copy pgd in case of a vmalloc page
fault exception, the other levels of page tables are
shared, so the operation of copying pmd is unnecessary.
Signed-off-by: Chuanhua Han <hanchuanhua@oppo.com>
---
Changes in v4:
-Modify incorrect author name.
Changes in v3:
-Change the real name of signed-off-by.
Changes in v2:
-Delete incorrect default signatures.
arch/riscv/mm/fault.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
index 4e9efbe46d5f..40694f0cab9e 100644
--- a/arch/riscv/mm/fault.c
+++ b/arch/riscv/mm/fault.c
@@ -102,9 +102,9 @@ static inline void bad_area(struct pt_regs *regs, struct mm_struct *mm, int code
static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long addr)
{
pgd_t *pgd, *pgd_k;
- pud_t *pud, *pud_k;
- p4d_t *p4d, *p4d_k;
- pmd_t *pmd, *pmd_k;
+ pud_t *pud_k;
+ p4d_t *p4d_k;
+ pmd_t *pmd_k;
pte_t *pte_k;
int index;
unsigned long pfn;
@@ -132,14 +132,12 @@ static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long a
}
set_pgd(pgd, *pgd_k);
- p4d = p4d_offset(pgd, addr);
p4d_k = p4d_offset(pgd_k, addr);
if (!p4d_present(*p4d_k)) {
no_context(regs, addr);
return;
}
- pud = pud_offset(p4d, addr);
pud_k = pud_offset(p4d_k, addr);
if (!pud_present(*pud_k)) {
no_context(regs, addr);
@@ -150,13 +148,11 @@ static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long a
* Since the vmalloc area is global, it is unnecessary
* to copy individual PTEs
*/
- pmd = pmd_offset(pud, addr);
pmd_k = pmd_offset(pud_k, addr);
if (!pmd_present(*pmd_k)) {
no_context(regs, addr);
return;
}
- set_pmd(pmd, *pmd_k);
/*
* Make sure the actual PTE exists as well to
--
2.25.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v4] riscv: mm: Remove the copy operation of pmd
2022-04-01 2:43 ` Chuanhua Han
@ 2022-04-21 17:05 ` Palmer Dabbelt
-1 siblings, 0 replies; 4+ messages in thread
From: Palmer Dabbelt @ 2022-04-21 17:05 UTC (permalink / raw)
To: hanchuanhua
Cc: Paul Walmsley, aou, alexandre.ghiti, jszhang, mhiramat, akpm,
zhengqi.arch, ebiederm, liushixin2, linux-riscv, linux-kernel,
hanchuanhua
On Thu, 31 Mar 2022 19:43:20 PDT (-0700), hanchuanhua@oppo.com wrote:
> Since all processes share the kernel address space,
> we only need to copy pgd in case of a vmalloc page
> fault exception, the other levels of page tables are
> shared, so the operation of copying pmd is unnecessary.
>
> Signed-off-by: Chuanhua Han <hanchuanhua@oppo.com>
> ---
> Changes in v4:
> -Modify incorrect author name.
>
> Changes in v3:
> -Change the real name of signed-off-by.
>
> Changes in v2:
> -Delete incorrect default signatures.
>
>
> arch/riscv/mm/fault.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
> index 4e9efbe46d5f..40694f0cab9e 100644
> --- a/arch/riscv/mm/fault.c
> +++ b/arch/riscv/mm/fault.c
> @@ -102,9 +102,9 @@ static inline void bad_area(struct pt_regs *regs, struct mm_struct *mm, int code
> static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long addr)
> {
> pgd_t *pgd, *pgd_k;
> - pud_t *pud, *pud_k;
> - p4d_t *p4d, *p4d_k;
> - pmd_t *pmd, *pmd_k;
> + pud_t *pud_k;
> + p4d_t *p4d_k;
> + pmd_t *pmd_k;
> pte_t *pte_k;
> int index;
> unsigned long pfn;
> @@ -132,14 +132,12 @@ static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long a
> }
> set_pgd(pgd, *pgd_k);
>
> - p4d = p4d_offset(pgd, addr);
> p4d_k = p4d_offset(pgd_k, addr);
> if (!p4d_present(*p4d_k)) {
> no_context(regs, addr);
> return;
> }
>
> - pud = pud_offset(p4d, addr);
> pud_k = pud_offset(p4d_k, addr);
> if (!pud_present(*pud_k)) {
> no_context(regs, addr);
> @@ -150,13 +148,11 @@ static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long a
> * Since the vmalloc area is global, it is unnecessary
> * to copy individual PTEs
> */
> - pmd = pmd_offset(pud, addr);
> pmd_k = pmd_offset(pud_k, addr);
> if (!pmd_present(*pmd_k)) {
> no_context(regs, addr);
> return;
> }
> - set_pmd(pmd, *pmd_k);
>
> /*
> * Make sure the actual PTE exists as well to
Thanks, this is on for-next (it was last night, but looks like I forgot
to send the email).
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4] riscv: mm: Remove the copy operation of pmd
@ 2022-04-21 17:05 ` Palmer Dabbelt
0 siblings, 0 replies; 4+ messages in thread
From: Palmer Dabbelt @ 2022-04-21 17:05 UTC (permalink / raw)
To: hanchuanhua
Cc: Paul Walmsley, aou, alexandre.ghiti, jszhang, mhiramat, akpm,
zhengqi.arch, ebiederm, liushixin2, linux-riscv, linux-kernel,
hanchuanhua
On Thu, 31 Mar 2022 19:43:20 PDT (-0700), hanchuanhua@oppo.com wrote:
> Since all processes share the kernel address space,
> we only need to copy pgd in case of a vmalloc page
> fault exception, the other levels of page tables are
> shared, so the operation of copying pmd is unnecessary.
>
> Signed-off-by: Chuanhua Han <hanchuanhua@oppo.com>
> ---
> Changes in v4:
> -Modify incorrect author name.
>
> Changes in v3:
> -Change the real name of signed-off-by.
>
> Changes in v2:
> -Delete incorrect default signatures.
>
>
> arch/riscv/mm/fault.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
> index 4e9efbe46d5f..40694f0cab9e 100644
> --- a/arch/riscv/mm/fault.c
> +++ b/arch/riscv/mm/fault.c
> @@ -102,9 +102,9 @@ static inline void bad_area(struct pt_regs *regs, struct mm_struct *mm, int code
> static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long addr)
> {
> pgd_t *pgd, *pgd_k;
> - pud_t *pud, *pud_k;
> - p4d_t *p4d, *p4d_k;
> - pmd_t *pmd, *pmd_k;
> + pud_t *pud_k;
> + p4d_t *p4d_k;
> + pmd_t *pmd_k;
> pte_t *pte_k;
> int index;
> unsigned long pfn;
> @@ -132,14 +132,12 @@ static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long a
> }
> set_pgd(pgd, *pgd_k);
>
> - p4d = p4d_offset(pgd, addr);
> p4d_k = p4d_offset(pgd_k, addr);
> if (!p4d_present(*p4d_k)) {
> no_context(regs, addr);
> return;
> }
>
> - pud = pud_offset(p4d, addr);
> pud_k = pud_offset(p4d_k, addr);
> if (!pud_present(*pud_k)) {
> no_context(regs, addr);
> @@ -150,13 +148,11 @@ static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long a
> * Since the vmalloc area is global, it is unnecessary
> * to copy individual PTEs
> */
> - pmd = pmd_offset(pud, addr);
> pmd_k = pmd_offset(pud_k, addr);
> if (!pmd_present(*pmd_k)) {
> no_context(regs, addr);
> return;
> }
> - set_pmd(pmd, *pmd_k);
>
> /*
> * Make sure the actual PTE exists as well to
Thanks, this is on for-next (it was last night, but looks like I forgot
to send the email).
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-04-21 17:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-01 2:43 [PATCH v4] riscv: mm: Remove the copy operation of pmd Chuanhua Han
2022-04-01 2:43 ` Chuanhua Han
2022-04-21 17:05 ` Palmer Dabbelt
2022-04-21 17:05 ` Palmer Dabbelt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.