* [PATCH] riscv: mm: Remove the copy operation of pmd
@ 2020-03-30 11:53 Chuanhua Han
2021-02-24 12:34 ` Alex Ghiti
0 siblings, 1 reply; 5+ messages in thread
From: Chuanhua Han @ 2020-03-30 11:53 UTC (permalink / raw)
To: paul.walmsley, palmer, aou
Cc: akpm, sfr, peterx, shihpo.hung, ebiederm, schwab, tglx,
Anup.Patel, 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@fishsemi.com>
---
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 be84e32adc4c..24f4ebfd2df8 100644
--- a/arch/riscv/mm/fault.c
+++ b/arch/riscv/mm/fault.c
@@ -208,9 +208,9 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
vmalloc_fault:
{
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;
@@ -234,12 +234,10 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
goto no_context;
set_pgd(pgd, *pgd_k);
- p4d = p4d_offset(pgd, addr);
p4d_k = p4d_offset(pgd_k, addr);
if (!p4d_present(*p4d_k))
goto no_context;
- pud = pud_offset(p4d, addr);
pud_k = pud_offset(p4d_k, addr);
if (!pud_present(*pud_k))
goto no_context;
@@ -248,11 +246,9 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
* 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))
goto no_context;
- set_pmd(pmd, *pmd_k);
/*
* Make sure the actual PTE exists as well to
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] riscv: mm: Remove the copy operation of pmd
2020-03-30 11:53 [PATCH] riscv: mm: Remove the copy operation of pmd Chuanhua Han
@ 2021-02-24 12:34 ` Alex Ghiti
0 siblings, 0 replies; 5+ messages in thread
From: Alex Ghiti @ 2021-02-24 12:34 UTC (permalink / raw)
To: Chuanhua Han, paul.walmsley, palmer, aou
Cc: sfr, schwab, Anup.Patel, linux-kernel, peterx, linux-riscv,
ebiederm, akpm, shihpo.hung, tglx
Le 3/30/20 à 7:53 AM, Chuanhua Han a écrit :
> 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@fishsemi.com>
> ---
> 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 be84e32adc4c..24f4ebfd2df8 100644
> --- a/arch/riscv/mm/fault.c
> +++ b/arch/riscv/mm/fault.c
> @@ -208,9 +208,9 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
> vmalloc_fault:
> {
> 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;
>
> @@ -234,12 +234,10 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
> goto no_context;
> set_pgd(pgd, *pgd_k);
>
> - p4d = p4d_offset(pgd, addr);
> p4d_k = p4d_offset(pgd_k, addr);
> if (!p4d_present(*p4d_k))
> goto no_context;
>
> - pud = pud_offset(p4d, addr);
> pud_k = pud_offset(p4d_k, addr);
> if (!pud_present(*pud_k))
> goto no_context;
> @@ -248,11 +246,9 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
> * 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))
> goto no_context;
> - set_pmd(pmd, *pmd_k);
>
> /*
> * Make sure the actual PTE exists as well to
>
Better late than never: I do agree with this patch, once the PGD is
copied into the user page table, it "comes with all its mappings" so
there is no need to copy PMD, the only thing left to do is to make sure
the mapping does exists in the kernel page table.
So feel free to add:
Reviewed-by: Alexandre Ghiti <alex@ghiti.fr>
Tested-by: Alexandre Ghiti <alex@ghiti.fr>
Thanks,
Alex
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] riscv: mm: Remove the copy operation of pmd
2022-02-22 21:25 ` Palmer Dabbelt
@ 2022-02-23 2:58 ` hanchuanhua
0 siblings, 0 replies; 5+ messages in thread
From: hanchuanhua @ 2022-02-23 2:58 UTC (permalink / raw)
To: Palmer Dabbelt
Cc: Paul Walmsley, aou, jszhang, alexandre.ghiti, wangkefeng.wang,
zhengqi.arch, ebiederm, liushixin2, linux-riscv, linux-kernel
On 2022/2/23 5:25, Palmer Dabbelt wrote:
> On Thu, 27 Jan 2022 02:06:22 PST (-0800), 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: hanchuanhua <hanchuanhua@oppo.com>
>> ---
>> 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 4e9efbe..40694f0 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
> This looks good, but "Signed off by" lines are supposed to have real
> names associated with them and this looks like a handle to me. There
> also seems to be something broken with the email, as this is causing git
> to blow up, but for a small patch like this that's OK as I can resurrect
> it by hand.
>
> Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com> # aside from the name
>
> Please send a v2 with the proper Signed off by line, as that's not
> something I'm supposed to just fix up myself.
>
> Thanks!
First of all, thank you for your review and reply. I don't quite
understand what's wrong with the line "Signed off by"?
Thanks!
________________________________
OPPO
本电子邮件及其附件含有OPPO公司的保密信息,仅限于邮件指明的收件人使用(包含个人及群组)。禁止任何人在未经授权的情况下以任何形式使用。如果您错收了本邮件,请立即以电子邮件通知发件人并删除本邮件及其附件。
This e-mail and its attachments contain confidential information from OPPO, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] riscv: mm: Remove the copy operation of pmd
2022-01-27 10:06 hanchuanhua
@ 2022-02-22 21:25 ` Palmer Dabbelt
2022-02-23 2:58 ` hanchuanhua
0 siblings, 1 reply; 5+ messages in thread
From: Palmer Dabbelt @ 2022-02-22 21:25 UTC (permalink / raw)
To: hanchuanhua
Cc: Paul Walmsley, aou, jszhang, alexandre.ghiti, wangkefeng.wang,
zhengqi.arch, ebiederm, liushixin2, linux-riscv, linux-kernel,
hanchuanhua
On Thu, 27 Jan 2022 02:06:22 PST (-0800), 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: hanchuanhua <hanchuanhua@oppo.com>
> ---
> 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 4e9efbe..40694f0 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
This looks good, but "Signed off by" lines are supposed to have real
names associated with them and this looks like a handle to me. There
also seems to be something broken with the email, as this is causing git
to blow up, but for a small patch like this that's OK as I can resurrect
it by hand.
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com> # aside from the name
Please send a v2 with the proper Signed off by line, as that's not
something I'm supposed to just fix up myself.
Thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] riscv: mm: Remove the copy operation of pmd
@ 2022-01-27 10:06 hanchuanhua
2022-02-22 21:25 ` Palmer Dabbelt
0 siblings, 1 reply; 5+ messages in thread
From: hanchuanhua @ 2022-01-27 10:06 UTC (permalink / raw)
To: paul.walmsley, palmer, aou
Cc: jszhang, alexandre.ghiti, wangkefeng.wang, zhengqi.arch,
ebiederm, liushixin2, linux-riscv, linux-kernel, hanchuanhua
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: hanchuanhua <hanchuanhua@oppo.com>
---
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 4e9efbe..40694f0 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.7.4
________________________________
OPPO
本电子邮件及其附件含有OPPO公司的保密信息,仅限于邮件指明的收件人使用(包含个人及群组)。禁止任何人在未经授权的情况下以任何形式使用。如果您错收了本邮件,请立即以电子邮件通知发件人并删除本邮件及其附件。
This e-mail and its attachments contain confidential information from OPPO, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-02-23 2:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-30 11:53 [PATCH] riscv: mm: Remove the copy operation of pmd Chuanhua Han
2021-02-24 12:34 ` Alex Ghiti
2022-01-27 10:06 hanchuanhua
2022-02-22 21:25 ` Palmer Dabbelt
2022-02-23 2:58 ` hanchuanhua
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).