From patchwork Wed Apr 3 08:38:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13615372 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B13DACD1288 for ; Wed, 3 Apr 2024 08:38:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D72496B0092; Wed, 3 Apr 2024 04:38:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CD1FD6B0093; Wed, 3 Apr 2024 04:38:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9EBAD6B0095; Wed, 3 Apr 2024 04:38:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7BF3C6B0092 for ; Wed, 3 Apr 2024 04:38:33 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4E4F7A1269 for ; Wed, 3 Apr 2024 08:38:33 +0000 (UTC) X-FDA: 81967569306.06.979FEEE Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf09.hostedemail.com (Postfix) with ESMTP id 1887C14000F for ; Wed, 3 Apr 2024 08:38:30 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712133511; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Myv/h7kbb21tl1+xfuWM9tOyrAQENAdc7X/Z/48zHSM=; b=Ej2Pyvm2GQrZs1wSAQfghNn+I1hH7pxnFBgpALVeDagrbdY9oFyspViy+zj/XTOhkBRPoO owJAVMZl7OIZfg7hE8VLf8zia5gp6LO1THzhIGtGb2ESqVoWBF78/mlfHL6zaKmmXXAKhn ThSBtec56DKL/fJe+PXWmC+PBchiml8= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712133511; a=rsa-sha256; cv=none; b=oZXQEnBT5BhwEqzYCnfSF6/pSELeQBFWCPLXD19KslBYNvOKrXWZfXPxJgxJEB9B+5mM3M XCfPHF3HfI390kZNpW7JfEq5L/nT/MRkGd2IhgKjnB4ji5NtPT7/+f8VOMb1R42Abz1dbF qHgcEKnZ/T5E8ksjbGftDpFL6MngREU= Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4V8dRJ4hz5zbf6r; Wed, 3 Apr 2024 16:37:32 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 97DF218007C; Wed, 3 Apr 2024 16:38:27 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 3 Apr 2024 16:38:26 +0800 From: Kefeng Wang To: CC: Russell King , Catalin Marinas , Will Deacon , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Gordeev , Gerald Schaefer , Dave Hansen , Andy Lutomirski , Peter Zijlstra , , , , , , , , Kefeng Wang Subject: [PATCH v2 5/7] riscv: mm: accelerate pagefault when badaccess Date: Wed, 3 Apr 2024 16:38:03 +0800 Message-ID: <20240403083805.1818160-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240403083805.1818160-1-wangkefeng.wang@huawei.com> References: <20240403083805.1818160-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 1887C14000F X-Rspam-User: X-Stat-Signature: mtakfqxxqihkm61nwxqctrt7qiz1dcks X-Rspamd-Server: rspam01 X-HE-Tag: 1712133510-722024 X-HE-Meta: U2FsdGVkX19xyk5sbmEVSrdNBWFmzJLU8+96T6fYd48IJHSVK2AbxJBqMb7uXV+th5KPopiGkiDFe0Thauog8u06vzYRWVGPjDTm84xeP+CZ8lsohki/f69K+m6HuU9GBMqXt3/2NAyDh2glRW5Q7pmjs0SSOcpUNiL48UZ1Lo5lOsjs20ofTZIbjnumOTP6T+Xhb+lD1R/bDDx0e5V6zQkgbEfYJ+bAHKOA8nSh/64Ndtf4UPA3cRghXbBbUPJ8GHadalOwDKr1Z4aeHbk/SexlAlHmCRGQsUd/8XYZjJAnMKYkzflUtTd35YSz2FYpSxfN9eJehTFh/47Uvz2iZiETegg6f6GEQR1emgrd8w5tNvup1qTj5nRW1Vp1zPP6tmBfXYFJIw3N0IoTdDmWeD7XzorV0QxrVVsPnRCcVJuyRV1RZ3/Qv+HVNp/ERDc4OO7ckF2gLnUqPbqlHq7JlN3T6m8xLiFsPsDJ1ghPJLA5EVtAicLD9gdqb+G3LYZsRmDRvwPAhkvG8PWzvCOMuRYcAdM6QUrHBQuXp/MQaRSIAEONGzADSLQLt3nUK+FA+mKbZ8bY78SjddJqNGi7iKtDrbmdK62HsZD2b1o/tEFur+cQLmDWv6sjLLnjvpQY4ri531L2EKxhDt0XhwxVEul2NsP99XmdZ/l8kZh8/kW9MAFZ8gvmB6YoGThGv8ygPdU4USg9unK32IWQm+H4c6kteYF3zO+1iybLRLoZOfMaJEMKbt3/KUHZRb8ma/SVZxRl/ZrwTsnm1HCsZvqD0nBas+GxWSxdKXkNOBydp4cMGBmCcp7Cdb+Hx241JE5WW4J0FXCQ6tj12Erq6O/ppDcTdXjAerYV X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 Signed-off-by: Kefeng Wang Reviewed-by: Alexandre Ghiti Tested-by: Alexandre Ghiti --- 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; + bad_area_nosemaphore(regs, code, addr); + return; } fault = handle_mm_fault(vma, addr, flags | FAULT_FLAG_VMA_LOCK, regs);