From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Alexandre Ghiti <alex@ghiti.fr>, <akpm@linux-foundation.org>
Cc: Russell King <linux@armlinux.org.uk>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>, <x86@kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linuxppc-dev@lists.ozlabs.org>,
<linux-riscv@lists.infradead.org>, <linux-s390@vger.kernel.org>,
<surenb@google.com>, <linux-mm@kvack.org>
Subject: Re: [PATCH v2 5/7] riscv: mm: accelerate pagefault when badaccess
Date: Thu, 11 Apr 2024 09:17:56 +0800 [thread overview]
Message-ID: <ddb260bc-c4fc-4c42-b10f-0f459cf965e6@huawei.com> (raw)
In-Reply-To: <3493a2f4-9cae-4773-a6a1-2eeb2d23f0c8@ghiti.fr>
On 2024/4/11 1:28, Alexandre Ghiti wrote:
> On 10/04/2024 10:07, Kefeng Wang wrote:
>>
>>
>> On 2024/4/10 15:32, Alexandre Ghiti wrote:
>>> Hi Kefeng,
>>>
>>> On 03/04/2024 10:38, Kefeng Wang wrote:
>>>> The access_error() of vma already checked under per-VMA lock, if it
>>>> is a bad access, directly handle error, no need to retry with mmap_lock
>>>> again. Since the page faut is handled under per-VMA lock, count it as
>>>> a vma lock event with VMA_LOCK_SUCCESS.
>>>>
>>>> Reviewed-by: Suren Baghdasaryan <surenb@google.com>
>>>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>>>> ---
>>>> arch/riscv/mm/fault.c | 5 ++++-
>>>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
>>>> index 3ba1d4dde5dd..b3fcf7d67efb 100644
>>>> --- a/arch/riscv/mm/fault.c
>>>> +++ b/arch/riscv/mm/fault.c
>>>> @@ -292,7 +292,10 @@ void handle_page_fault(struct pt_regs *regs)
>>>> if (unlikely(access_error(cause, vma))) {
>>>> vma_end_read(vma);
>>>> - goto lock_mmap;
>>>> + count_vm_vma_lock_event(VMA_LOCK_SUCCESS);
>>>> + tsk->thread.bad_cause = SEGV_ACCERR;
>>>
>>>
>>> I think we should use the cause variable here instead of SEGV_ACCERR,
>>> as bad_cause is a riscv internal status which describes the real
>>> fault that happened.
>>
>> Oh, I see, it is exception causes on riscv, so it should be
>>
>> diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
>> index b3fcf7d67efb..5224f3733802 100644
>> --- a/arch/riscv/mm/fault.c
>> +++ b/arch/riscv/mm/fault.c
>> @@ -293,8 +293,8 @@ void handle_page_fault(struct pt_regs *regs)
>> if (unlikely(access_error(cause, vma))) {
>> vma_end_read(vma);
>> count_vm_vma_lock_event(VMA_LOCK_SUCCESS);
>> - tsk->thread.bad_cause = SEGV_ACCERR;
>> - bad_area_nosemaphore(regs, code, addr);
>> + tsk->thread.bad_cause = cause;
>> + bad_area_nosemaphore(regs, SEGV_ACCERR, addr);
>> return;
>> }
>>
>> Hi Alex, could you help to check it?
>>
>> Hi Andrew, please help to squash it after Alex ack it.
>>
>> Thanks both.
>
>
> So I have just tested Kefeng's fixup on my usual CI and with a simple
> program that triggers such bad access, everything went fine so with the
> fixup applied:
>
> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> Tested-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Great, thanks.
>
> Thanks,
>
> Alex
>
>
>
>>
>>
>>>
>>> Thanks,
>>>
>>> Alex
>>>
>>>
>>>> + bad_area_nosemaphore(regs, code, addr);
>>>> + return;
>>>> }
>>>> fault = handle_mm_fault(vma, addr, flags |
>>>> FAULT_FLAG_VMA_LOCK, regs);
next prev parent reply other threads:[~2024-04-11 1:18 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-03 8:37 [PATCH v2 0/7] arch/mm/fault: accelerate pagefault when badaccess Kefeng Wang
2024-04-03 8:37 ` [PATCH v2 1/7] arm64: mm: cleanup __do_page_fault() Kefeng Wang
2024-04-09 11:14 ` Catalin Marinas
2024-04-03 8:38 ` [PATCH v2 2/7] arm64: mm: accelerate pagefault when VM_FAULT_BADACCESS Kefeng Wang
2024-04-09 11:15 ` Catalin Marinas
2024-04-03 8:38 ` [PATCH v2 3/7] arm: " Kefeng Wang
2024-04-03 8:38 ` [PATCH v2 4/7] powerpc: mm: accelerate pagefault when badaccess Kefeng Wang
2024-04-09 8:56 ` Michael Ellerman
2024-04-03 8:38 ` [PATCH v2 5/7] riscv: " Kefeng Wang
2024-04-10 7:32 ` Alexandre Ghiti
2024-04-10 8:07 ` Kefeng Wang
2024-04-10 17:28 ` Alexandre Ghiti
2024-04-11 1:17 ` Kefeng Wang [this message]
2024-04-03 8:38 ` [PATCH v2 6/7] s390: " Kefeng Wang
2024-04-07 17:19 ` Heiko Carstens
2024-04-03 8:38 ` [PATCH v2 7/7] x86: " Kefeng Wang
2024-04-03 20:45 ` [PATCH v2 0/7] arch/mm/fault: " Andrew Morton
2024-04-07 7:49 ` Kefeng Wang
2024-04-07 17:19 ` Heiko Carstens
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=ddb260bc-c4fc-4c42-b10f-0f459cf965e6@huawei.com \
--to=wangkefeng.wang@huawei.com \
--cc=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=catalin.marinas@arm.com \
--cc=christophe.leroy@csgroup.eu \
--cc=dave.hansen@linux.intel.com \
--cc=gerald.schaefer@linux.ibm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mm@kvack.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=luto@kernel.org \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=peterz@infradead.org \
--cc=surenb@google.com \
--cc=will@kernel.org \
--cc=x86@kernel.org \
/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 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 read-only IMAP folder(s) and NNTP newsgroup(s).