From patchwork Wed Apr 3 08:38:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13615369 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 F2EA8CD1288 for ; Wed, 3 Apr 2024 08:38:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7537C6B0089; Wed, 3 Apr 2024 04:38:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6DCA86B008A; Wed, 3 Apr 2024 04:38:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57C926B008C; Wed, 3 Apr 2024 04:38:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 1EEE56B008A for ; Wed, 3 Apr 2024 04:38:31 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D2A91A0D6D for ; Wed, 3 Apr 2024 08:38:30 +0000 (UTC) X-FDA: 81967569180.06.2FA1834 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf09.hostedemail.com (Postfix) with ESMTP id AFEB814001C for ; Wed, 3 Apr 2024 08:38:28 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712133509; 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=dnCIzWeY1qqTgbyWio8O1U8KrwKcOC13DqOIgOib+lg=; b=EpM/uE9yH7ReM9NgibaeYjW/trGYWBWJB9vOQWu3VkN4SsC7WSLKEcF6AlaesfH24ZPYjV KTFCk/jiSlGeKAe6tHTBaePVPqIswvsLGZRxWTdbE+qHIzCWwoVQWsSPsXKu4ijGN06twJ pqvTbKfZSWseUI1RMHzhVh25k1c/9e8= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712133509; a=rsa-sha256; cv=none; b=qLPucekvanikOM36QM8SuU8eKqnq8XC9eeG3eywLg7RkvegfIUF2PiLX1fcLk7LzlZQLBp sHgb5wgCppskkHy9iw4v32ejhFt+s/C9m4kfTgMejJo8HnEpEVMZXweBWW18NVctuisyeK /STXVs4m6OlU4Xt8GA4XTMlStymSnIM= Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4V8dP72twYz1h5XQ; Wed, 3 Apr 2024 16:35:39 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id D79AA18001A; Wed, 3 Apr 2024 16:38:24 +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:23 +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 2/7] arm64: mm: accelerate pagefault when VM_FAULT_BADACCESS Date: Wed, 3 Apr 2024 16:38:00 +0800 Message-ID: <20240403083805.1818160-3-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-Rspam-User: X-Stat-Signature: z64kuww8buijym596xhkazt6o5br4s39 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: AFEB814001C X-HE-Tag: 1712133508-813244 X-HE-Meta: U2FsdGVkX1/ihPxq7gbdmE+tkXA1esyrddlOJ0R1Nm/VNRACPXUNXG7KRvg1qQ2sx3OT4aWUukvpxs/b9BZLigN2qzKqIpdbFunbDtN8NZrhw7ldMbUPLgEIlLgwTYlHCdyMX3gbMbYvbfeEEkLI3JAFyDeOoCio9oMB4/PdsTbA0V1eUnK3k2mjLQ5joNwzTyk4Ai9ZsusOTGDEzYo7VFb7rYX7OZMcVMvdjuGt+yJ4NpPyzJD8oenioUpa/ThAN7eNu2Puf7W7QV6Y0bdTd3WPNpXvr3b4ztIfMhpYJEgNv2acjeil9M9fy5Et2D/UOmzoyMgF4r8FNRsgtlzIvJiEPWEF42NU22g342zFO121r8MEhFFf0nXgWjVG875cm9VlNLCI99poSvXQiYzaK/TrSdUsjbATWk4s5hS1WtcrWrPIy0xgn/q9xeHJP3I4JrjlWbW3Zpqksp6QdJo4Qh5FVblNVLGrTbnnl9hSmcn5VG/RAp/H7iogONN4SESrbhipiOvpPLTa7OI3q/3xQG6v3zgwJqpuq0xq3eLZscsYIDpblrsC6x6TC51F54wV69gnhdR3INYRYdgWTGYYdsMdewwUeJ+8ef2PFJ0f2vWlYmI30J8ll59oUCyJajMP75ZxXx7KYatscAjyBCa0BMMb26ZewmUdKUBb84x1/eyDd+NgzDAupPOwqpEQpDlQbcKzRJ8lZDJSqAW5o42HcD209abUmTaxYqhYoxbXLo8CsOJ57/b/EXtCZbqIEAM8QvXbmpGZvxGhYtKS+B4rLAvSIOWFQOmn7Mak9aW74HXV2Ble7jeMaia9obUPkwYHu8G/isgn/OS4psymrdiyvu1pp6R2QWuOPSyOyh0lPgLcEHeL+py5ciIuureKIRJa9eSgi8zkvwT4GW08fnM02TCqsvxJ49EQHzQG5FRXjC9wBu2YTkrZJAQc0n623yu7FxCkoE4uD8hgXX/lyB2 NtEJQQlk APDiTm1dEPY6/Ld4H/0cUXQQTObf1TJC3rW/jCBeQBQ7ebtfRVQNCxiAPkyFO0ZPI+crPEn88LOYBZPxS7H0a6UvOCmQlnoC/J4vdfAWPurPPw9aY7uEt5Tu+/Xs0dKId216s+62gLcEEivj50voD2hdRbSmXq7Gb7pQi3aIteY6S5m8M02nM8klaE0btWYi3/DscCKJZQGz1Ij3a5KJ+yPkR9Q== 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 vm_flags of vma already checked under per-VMA lock, if it is a bad access, directly set fault to VM_FAULT_BADACCESS and handle error, no need to retry with mmap_lock again, the latency time reduces 34% in 'lat_sig -P 1 prot lat_sig' from lmbench testcase. 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: Catalin Marinas --- arch/arm64/mm/fault.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 9bb9f395351a..405f9aa831bd 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -572,7 +572,9 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, if (!(vma->vm_flags & vm_flags)) { vma_end_read(vma); - goto lock_mmap; + fault = VM_FAULT_BADACCESS; + count_vm_vma_lock_event(VMA_LOCK_SUCCESS); + goto done; } fault = handle_mm_fault(vma, addr, mm_flags | FAULT_FLAG_VMA_LOCK, regs); if (!(fault & (VM_FAULT_RETRY | VM_FAULT_COMPLETED)))