All of lore.kernel.org
 help / color / mirror / Atom feed
From: hanchuanhua <hanchuanhua@oppo.com>
To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu
Cc: jszhang@kernel.org, alexandre.ghiti@canonical.com,
	wangkefeng.wang@huawei.com, zhengqi.arch@bytedance.com,
	ebiederm@xmission.com, liushixin2@huawei.com,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	hanchuanhua <hanchuanhua@oppo.com>
Subject: [PATCH] riscv: mm: Remove the copy operation of pmd
Date: Thu, 27 Jan 2022 18:06:22 +0800	[thread overview]
Message-ID: <20220127100622.11856-1-hanchuanhua@oppo.com> (raw)

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!

WARNING: multiple messages have this Message-ID (diff)
From: hanchuanhua <hanchuanhua@oppo.com>
To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu
Cc: jszhang@kernel.org, alexandre.ghiti@canonical.com,
	wangkefeng.wang@huawei.com, zhengqi.arch@bytedance.com,
	ebiederm@xmission.com, liushixin2@huawei.com,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	hanchuanhua <hanchuanhua@oppo.com>
Subject: [PATCH] riscv: mm: Remove the copy operation of pmd
Date: Thu, 27 Jan 2022 18:06:22 +0800	[thread overview]
Message-ID: <20220127100622.11856-1-hanchuanhua@oppo.com> (raw)

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!

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

             reply	other threads:[~2022-01-27 10:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-27 10:06 hanchuanhua [this message]
2022-01-27 10:06 ` [PATCH] riscv: mm: Remove the copy operation of pmd hanchuanhua
2022-02-22 21:25 ` Palmer Dabbelt
2022-02-22 21:25   ` Palmer Dabbelt
2022-02-23  2:58   ` hanchuanhua
2022-02-23  2:58     ` hanchuanhua
  -- strict thread matches above, loose matches on Subject: below --
2020-03-30 11:53 Chuanhua Han
2020-03-30 11:53 ` Chuanhua Han
2021-02-24 12:34 ` Alex Ghiti
2021-02-24 12:34   ` Alex Ghiti

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=20220127100622.11856-1-hanchuanhua@oppo.com \
    --to=hanchuanhua@oppo.com \
    --cc=alexandre.ghiti@canonical.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=ebiederm@xmission.com \
    --cc=jszhang@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=liushixin2@huawei.com \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=zhengqi.arch@bytedance.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 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.