Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3208829ioo; Sun, 29 May 2022 17:18:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzD9S1zd7FBSsb47nQtAKo/gVeSrSXau4byhC+yuNA5fNnJwqYCLtl+PNSsaiHiTPWdUpuM X-Received: by 2002:a05:6a00:1952:b0:518:9fbd:ff7a with SMTP id s18-20020a056a00195200b005189fbdff7amr35641326pfk.77.1653869923529; Sun, 29 May 2022 17:18:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653869923; cv=none; d=google.com; s=arc-20160816; b=jPH/nOrF+7Sr/mXu3z6hy/wlhiGdlMvvhE8XG/8Jkqe326js8dEyFH9V/LXy5a0w6/ sUHMLCpZhiFu5iQcKw/QO4PG/cTyd/dAVy+8P2YgitqxvnKRCmh+Nt+qTqQQRXDemZE1 9YMMV7tIYZCChM7/rCrSjQF+vjuzwreWp/kV/m5nmweyVeU83lKJKDIokiDpsGNyGWXI 4jiNJXPE8cKNPUVkUU7rIL4428JLByJyI8cTQpsV1gEiJMdlNgN5nWGhVNd6VbVK86Lo SseQ6cEQXLQEl/IsNW99HxJvOB8xuNxCv3soj4cD3q/U6HZgh8l08rHpPzRf4rqecC2O 6/Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=x4N7bX0DRRebDZ+llHBEoOO1y8RqkpeB+Jlf+Vx+ui4=; b=Gwmcqt04qsXxBUf4nx2UeW7oxajFWCYjGlwTMKOPkTfndaGk8EFzh60MYcHX3GyEXI 5VJJLuFycc8oc7uWkAFQ5J2e+jfDGiIAoPCueoHqoDO2ug0C8iU3zq5MpoPgUvdq4/gh wBLiYTuGuTxAcMjZwzSN0lW1kHrDfE+AVoIOOxWoFt6KKUDnHGLw35FF7byZoNynpubL D+cxcvI6DuOA3Vs0t6h58r5FUztmOD0ZRTEH8I9H/jqTSSCyhwJDn9VFM9WrbWJ1WWIw F9dVoe36+w8UmwKZkMiCLedaQrKMmc67SyhDoWFNyyScfeuAFdSKLk/nIxTZLNxsKlFQ hKEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="hakF/8aP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 190-20020a6301c7000000b003fbc20f595esi9217163pgb.505.2022.05.29.17.18.28; Sun, 29 May 2022 17:18:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="hakF/8aP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231817AbiE2UhB (ORCPT + 99 others); Sun, 29 May 2022 16:37:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229999AbiE2Ug6 (ORCPT ); Sun, 29 May 2022 16:36:58 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 585DC6327; Sun, 29 May 2022 13:36:57 -0700 (PDT) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24TJMjwU012617; Sun, 29 May 2022 20:33:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=pp1; bh=x4N7bX0DRRebDZ+llHBEoOO1y8RqkpeB+Jlf+Vx+ui4=; b=hakF/8aPF5DH3ICHAn7P7Q7xBA4KtdA0je0+nJRBs+xaI2hHDxgItX2ciwK19sCxk0JA lJnlqKta8jHKJkMqJ1rgWh3qDwM1i/TtlTQ6ooSKLwvTWHLC31BcYNAGC/G9N1aAutXV V/4AJkKs1JGbbdy51HbI6h6b7Z42larzwd7F8tbvXbgPaisrk9ryWS8vf9H7FU54t9UR 0Eo3hWRTOOaJavYhxG1gVT9JHKnOc8gKYbkkKxn8voKk4y3jdzUzhrmCMfV05FMX0fA5 j1Oa7gTPBzc3qIRMostgXnmcMPZVXypM3JAAZSk7OQxWvEnIL9TkJkNVyyqJFOQLb2Mf xw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3gby3esrdj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 29 May 2022 20:33:34 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 24TKP7nu010580; Sun, 29 May 2022 20:33:33 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3gby3esrd9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 29 May 2022 20:33:33 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 24TKLpBX018675; Sun, 29 May 2022 20:33:31 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma01fra.de.ibm.com with ESMTP id 3gbcakh5ud-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 29 May 2022 20:33:30 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 24TKXR4r17105322 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 May 2022 20:33:27 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5933511C04C; Sun, 29 May 2022 20:33:27 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EEE2A11C04A; Sun, 29 May 2022 20:33:24 +0000 (GMT) Received: from osiris (unknown [9.145.39.236]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Sun, 29 May 2022 20:33:24 +0000 (GMT) Date: Sun, 29 May 2022 22:33:23 +0200 From: Heiko Carstens To: Peter Xu Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Will Deacon , Matt Turner , linux-s390@vger.kernel.org, Andrew Morton , Brian Cain , Borislav Petkov , linux-alpha@vger.kernel.org, Alistair Popple , Jonas Bonn , linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, Michael Ellerman , Stefan Kristiansson , linux-snps-arc@lists.infradead.org, Vineet Gupta , Vasily Gorbik , Vlastimil Babka , Ivan Kokshaysky , Rich Felker , sparclinux@vger.kernel.org, Russell King , David Hildenbrand , Benjamin Herrenschmidt , Nicholas Piggin , "James E . J . Bottomley" , linux-xtensa@linux-xtensa.org, linux-sh@vger.kernel.org, Paul Walmsley , linux-m68k@lists.linux-m68k.org, linuxppc-dev@lists.ozlabs.org, Richard Henderson , Guo Ren , linux-parisc@vger.kernel.org, Andrea Arcangeli , Helge Deller , Al Viro , Albert Ou , linux-um@lists.infradead.org, "H . Peter Anvin" , Janosch Frank , Sven Schnelle , Anton Ivanov , openrisc@lists.librecores.org, Thomas Bogendoerfer , linux-hexagon@vger.kernel.org, Andy Lutomirski , Stafford Horne , linux-csky@vger.kernel.org, Thomas Gleixner , linux-mips@vger.kernel.org, Paul Mackerras , Alexander Gordeev , Dinh Nguyen , Palmer Dabbelt , "David S . Miller" , Johannes Weiner , Hugh Dickins , Ingo Molnar , Peter Zijlstra , linux-riscv@lists.infradead.org, Max Filippov , Catalin Marinas , Geert Uytterhoeven , Christian Borntraeger , Johannes Berg , Chris Zankel , Michal Simek , x86@kernel.org, Yoshinori Sato , Dave Hansen , Richard Weinberger , Ingo Molnar Subject: Re: [PATCH v4] mm: Avoid unnecessary page fault retires on shared memory types Message-ID: References: <20220527193936.30678-1-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220527193936.30678-1-peterx@redhat.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: oFSau6Dj_1rg8rX4SeOfmoPaYp5LEgWy X-Proofpoint-GUID: M6Ru04-Ir3Ey8vHF11WRaj0WUz41oFky X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-29_05,2022-05-27_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 clxscore=1011 phishscore=0 impostorscore=0 lowpriorityscore=0 mlxlogscore=818 suspectscore=0 mlxscore=0 adultscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2205290119 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 27, 2022 at 03:39:36PM -0400, Peter Xu wrote: > diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c > index e173b6187ad5..4608cc962ecf 100644 > --- a/arch/s390/mm/fault.c > +++ b/arch/s390/mm/fault.c > @@ -433,6 +433,17 @@ static inline vm_fault_t do_exception(struct pt_regs *regs, int access) > goto out_up; > goto out; > } > + > + /* The fault is fully completed (including releasing mmap lock) */ > + if (fault & VM_FAULT_COMPLETED) { > + /* > + * Gmap will need the mmap lock again, so retake it. TODO: > + * only conditionally take the lock when CONFIG_PGSTE set. > + */ > + mmap_read_lock(mm); > + goto out_gmap; > + } > + > if (unlikely(fault & VM_FAULT_ERROR)) > goto out_up; > Guess the patch below on top of your patch is what we want. Just for clarification: if gmap is not NULL then the process is a kvm process. So, depending on the workload, this optimization makes sense. diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index 4608cc962ecf..e1d40ca341b7 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -436,12 +436,11 @@ static inline vm_fault_t do_exception(struct pt_regs *regs, int access) /* The fault is fully completed (including releasing mmap lock) */ if (fault & VM_FAULT_COMPLETED) { - /* - * Gmap will need the mmap lock again, so retake it. TODO: - * only conditionally take the lock when CONFIG_PGSTE set. - */ - mmap_read_lock(mm); - goto out_gmap; + if (gmap) { + mmap_read_lock(mm); + goto out_gmap; + } + goto out; } if (unlikely(fault & VM_FAULT_ERROR))