From patchwork Tue Mar 14 13:28:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Carstens X-Patchwork-Id: 13174435 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 BAB2CC6FD1D for ; Tue, 14 Mar 2023 13:28:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DA056B0072; Tue, 14 Mar 2023 09:28:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 48A698E0003; Tue, 14 Mar 2023 09:28:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 378E68E0002; Tue, 14 Mar 2023 09:28:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 2A6B26B0072 for ; Tue, 14 Mar 2023 09:28:19 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0CD7B1C0181 for ; Tue, 14 Mar 2023 13:28:19 +0000 (UTC) X-FDA: 80567582718.09.7CFBDB3 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf01.hostedemail.com (Postfix) with ESMTP id 9DDEF4000B for ; Tue, 14 Mar 2023 13:28:16 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=GWE0qkC5; spf=pass (imf01.hostedemail.com: domain of hca@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=hca@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678800496; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=T9E/WAjs5Rl68PedpiTdn1i4MUKfeBqmE4rYwE6ISEw=; b=HINeC0eLr9oIXoBSRUV1OoPFAgT1xhZNCizK2rsTeXfkNJ6PAHRJzehyxmt5ajAVYHT6ad RHfeD7EzyY+Lv0OYRUApKhqByDqFKEssa9XFKLQxWeBu+7XivWWmG9mE+jtR4QGQ/5AqZ8 yxZCDZ0W794AVnX5EeHDdTPMgimrzpY= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=GWE0qkC5; spf=pass (imf01.hostedemail.com: domain of hca@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=hca@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678800496; a=rsa-sha256; cv=none; b=cq2s/JbvPoX8oV0hhILLUz6k6G/isePHgrHrighntQlnjSiEez8qtzOz/BmhACfhI5XgNG odYGdH8JrR0qwcXpDwjefAcy8+GYSxh4CusDl8DVhIJr/Vhfgs4wACyQA3q0NJgQ0LMTdU NqZHWONHmG1nyMySLl2OkibWIFK6KZ8= Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32EC0GP4016896; Tue, 14 Mar 2023 13:28:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=T9E/WAjs5Rl68PedpiTdn1i4MUKfeBqmE4rYwE6ISEw=; b=GWE0qkC5NoVqS5vbWyj/bwUkR4obs1x7mbLe/ShPnL6/muRxYK1Tt3KxJQnGP/giNIUz r6M69F5Q9ufk9j0WMkumYfzekGNg9/mCjXCXYz/9xrNbs7+TvW4YuZ/gqvNEmcO9XUJs 9KY6ca3PrcqCkxNiDyjgPHBThpdvcxAp8nmYNvMuB4cJ2akvkQadDOYe8cx9yb709aOr 4Ym94ZFYmKR1iyRK2QCsqYrezYhaJ5wlMttTWe33bbTEIq8WtioMtkKEq8HOWKAhC+N4 DfsQVI0O8v8I1PG027vG/ovd3uqmTIqVxCzpIK8IB/AMCNbmihM2aTeJPHQ9CDOgCJnO pg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3paph269dr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Mar 2023 13:28:15 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32ECXefN030864; Tue, 14 Mar 2023 13:28:14 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3paph269d5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Mar 2023 13:28:14 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32E7jONF001023; Tue, 14 Mar 2023 13:28:12 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma03ams.nl.ibm.com (PPS) with ESMTPS id 3p8h96muxu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Mar 2023 13:28:12 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32EDS8mP38797768 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Mar 2023 13:28:08 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 77DDE2004B; Tue, 14 Mar 2023 13:28:08 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 383ED20040; Tue, 14 Mar 2023 13:28:08 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 14 Mar 2023 13:28:08 +0000 (GMT) From: Heiko Carstens To: Andrew Morton , Suren Baghdasaryan Cc: Vasily Gorbik , Alexander Gordeev , Sven Schnelle , Christian Borntraeger , Gerald Schaefer , linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH -next] s390/mm: try VMA lock-based page fault handling first Date: Tue, 14 Mar 2023 14:28:08 +0100 Message-Id: <20230314132808.1266335-1-hca@linux.ibm.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ew7MVjDN4tjxh4RhkGpyYpIg78MJuw9D X-Proofpoint-GUID: SOJQ3uWi9qO_GS7CuxvEIUnoftenHTE2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-14_06,2023-03-14_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 malwarescore=0 suspectscore=0 adultscore=0 phishscore=0 bulkscore=0 mlxscore=0 mlxlogscore=803 spamscore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303140112 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 9DDEF4000B X-Stat-Signature: 1fexx3t7dxus7y76b7pysgn9n1zwhud8 X-Rspam-User: X-HE-Tag: 1678800496-353826 X-HE-Meta: U2FsdGVkX18rYYLGyuQ6LAfuMon3HfX1cyvMVneb9DDM2EBx933hNvuZj3f0eGLs4+Ftm2GTylU63c0oCB6I6Rn9UBzXUUGDxMl9dqtSHuKrFC3+DpduWU6gWqwJlnzjQbWcgPeYpGV+ttLay1VPs1Rzlwbs2mcRttEXYpMeyDTbYWAnsFIo/4sEJCzuoq8dcG7G05e3fhJDZ1yq5Y1ZmpnqwZnp3/mBQ52sj2IvOszS5u4HjMM2sUXey0Jb0hnU3CSaqKNpKhRJsHUwGU9+kzndytLKszbwbswyWznT2I7n0bBX+UnevrL9SUtEeh7G4fLNpAxxwYjrNUyUOzmDBM01MG36JWrorCCwPHk9AUx54Vb9U6HQNCaBmr1S10jUd5a21GqtbDSqRLLW7mGhgH/oOik+QF+O1I6gCPaTqDaSJLb43GHB/2OWTxSlcS9iqar6XvBK58a/jDAuUxn57eGnuDkdPe/1osa2jYQE85r+yD7LIrYE/PnYDqQDFPylDc+ZU1EfYOpcnp7H6yQC6qiotiwLPwzTUHQzfIm/L7D4RI0QnQTqGaIBEXNd406ZLpk/BT3DkgzyiAJpPAC5aUE5n1DbNTdm1tMyH7/HijMQz69qjNC024DZqygQUKolvRNKRp5coAgOu+xZE81HzUMgXQEY5yfIwa/6TH7zctR2yN5Wbl5Q1FIUIo+ogqAGYLDu/W+dASPnWjVGNXJpbW1rre6ADi/MWk/ZUvib08f1bBWFTRGAXBoroc5uaohvrqwjZD6CuOvpYQlGOAwiB2ZAAvYCLvXjDq4es/+vaulSUGRMShirp58ZMGOl6n4XdPc+fgEdMqhCW2Pq6QQ63bcBTz4o/QY4YeT0IX0HV5A+x7j9qu79l+KoqvTDF2KE+To9ZdEuOZBfa2KrLStKR858NXy74js/pIRHJ6jlIKfIZLYaf9zzVaUenPVKGHPOw8QmlKO89Kz7nRe3wmk kKcRisFq zjBMwO5EPAwbFpxDzOgEiupnSskxb3LWKWRNCCqlDMDWzl6tikbRhTKOybcIZmG88n3M1RDj0qMCBA+nYnz0TeOt1B4FnN6Fzm+vme7MofU1pinH76JlveFRBogYqDz6BZSFpMkd8aGnWcLscDKMSgDTsFGvNM3ZoZhzT 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: Attempt VMA lock-based page fault handling first, and fall back to the existing mmap_lock-based handling if that fails. This is the s390 variant of "x86/mm: try VMA lock-based page fault handling first". Signed-off-by: Heiko Carstens --- arch/s390/Kconfig | 1 + arch/s390/mm/fault.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 9809c74e1240..548b5b587003 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -120,6 +120,7 @@ config S390 select ARCH_SUPPORTS_DEBUG_PAGEALLOC select ARCH_SUPPORTS_HUGETLBFS select ARCH_SUPPORTS_NUMA_BALANCING + select ARCH_SUPPORTS_PER_VMA_LOCK select ARCH_USE_BUILTIN_BSWAP select ARCH_USE_CMPXCHG_LOCKREF select ARCH_WANTS_DYNAMIC_TASK_STRUCT diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index a2632fd97d00..b65144c392b0 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -407,6 +407,30 @@ static inline vm_fault_t do_exception(struct pt_regs *regs, int access) access = VM_WRITE; if (access == VM_WRITE) flags |= FAULT_FLAG_WRITE; +#ifdef CONFIG_PER_VMA_LOCK + if (!(flags & FAULT_FLAG_USER)) + goto lock_mmap; + vma = lock_vma_under_rcu(mm, address); + if (!vma) + goto lock_mmap; + if (!(vma->vm_flags & access)) { + vma_end_read(vma); + goto lock_mmap; + } + fault = handle_mm_fault(vma, address, flags | FAULT_FLAG_VMA_LOCK, regs); + vma_end_read(vma); + if (!(fault & VM_FAULT_RETRY)) { + count_vm_vma_lock_event(VMA_LOCK_SUCCESS); + goto out; + } + count_vm_vma_lock_event(VMA_LOCK_RETRY); + /* Quick path to respond to signals */ + if (fault_signal_pending(fault, regs)) { + fault = VM_FAULT_SIGNAL; + goto out; + } +lock_mmap: +#endif /* CONFIG_PER_VMA_LOCK */ mmap_read_lock(mm); gmap = NULL;