Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6965458yba; Tue, 14 May 2019 17:34:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzn1XXBrX203qVzk34UxZT0IgfJ0o0P9kzGPer0at3M68xuESlUI17zb9qcUmShZ+kSn/pj X-Received: by 2002:a62:1b8a:: with SMTP id b132mr43506358pfb.19.1557880440739; Tue, 14 May 2019 17:34:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557880440; cv=none; d=google.com; s=arc-20160816; b=pkkbi7t7m90dz1Jp9LIBENCYkg0cCapGt0mnMddr9A+JoOzgXBlJWPZmX/V8nCuTgS cbTrODGXQpefT5Ng9cob79ow0gjCBo8eTnDDLHXBPA1q0/8OEcmldWd+9EI3y4+cs9yx 3rrZyKrBtMcUy7gNL2nKOmZCv/9CK4ublCt4m3HrkJhFriAKEnTqhdP17yxXbtxXpbGZ goeiSp/TnT3w842b+9jsmGlbCwCEjsNcWrMlBPfmSfHBS9T3QDJgl9ueUUajofRpavSX 4Gm9/o33ExD4NnwCtx7EBJTxapmtG1YxcojffC1q9V1Vo0PJRWtBJaCAVSPdmpO08fWa 0gHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=d2ZQwrmj5fp18+PORm7UCCSUWR7QUQjZxYdzFGxqyZA=; b=j8bE9QTdS/BuL7/13D//OlH6o3OEzI2JA/e8vS68VrSLGa2G2nqvbUhnbcn2LpH/Xq ks3L++FVbJi3fyuZ8Us19D6hC7FAftdoENa7oC1GxSGDbT5OgU4alNEWPEG1ojIVwqq/ S7W7IgRFGm+e6qKmu1UgYU+MJZMaiHf8ICJSj69aT7ZimymX8kfV6hQ8tMN/XMhkxQPa S6uQn9F4we0lKKeXBWxoO8Sg+3s8WbZ8hW/vYpRReYZIfhhTub+WGRHeOOrMxc+yju7U Lrpp8IahjflPSP28G5XQevyY/GWEaovc5CPKVKLOVStLaXzgnjIqnfWPQ3jb8VLlCj4c jNXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=dxUetF3q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q4si541011pfb.272.2019.05.14.17.33.46; Tue, 14 May 2019 17:34:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=dxUetF3q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726959AbfEOAa6 (ORCPT + 99 others); Tue, 14 May 2019 20:30:58 -0400 Received: from smtprelay-out1.synopsys.com ([198.182.61.142]:38852 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726841AbfEOAac (ORCPT ); Tue, 14 May 2019 20:30:32 -0400 Received: from mailhost.synopsys.com (dc8-mailhost2.synopsys.com [10.13.135.210]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id D57C2C0A77; Wed, 15 May 2019 00:30:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1557880222; bh=5nGJv3FYZ4K8QvJw3tH/+4ah4G8NKr7npBJJdtbIcCU=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=dxUetF3qUJUHHlevAE6m9jwQCZvx5OOcNg2+jVz5i7cLUOBRhCAhkOzlgeHBt4WDS RHLDjZKA8FU3rDUPnI3vhurYt4wOt6bcBiLfDdMlSMThKlTtlpc90jQY9G3KpXeGsM LPnjSyUJn4h+LP1QkcLiIPRyqBVC87QFt/J4odXpi+Ufu8DhByVj9kpVzgCnCiP1RM QTF7fSscMqlWfHE3VOOyBqq2xtUyqSa/IRDB83We81ZdEBEg7yX+indgkT3S1+ph/W tOrT4Z9gSBRlLv8Zd0X6g75pP8t3JeGYZSRoFGZfwwCHBttf4YZD1u1kpmmg1CwNQ6 usCyvNyjo7jrQ== Received: from us01wehtc1.internal.synopsys.com (us01wehtc1-vip.internal.synopsys.com [10.12.239.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPS id 380E6A0068; Wed, 15 May 2019 00:30:32 +0000 (UTC) Received: from IN01WEHTCB.internal.synopsys.com (10.144.199.106) by us01wehtc1.internal.synopsys.com (10.12.239.235) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 14 May 2019 17:30:26 -0700 Received: from IN01WEHTCA.internal.synopsys.com (10.144.199.103) by IN01WEHTCB.internal.synopsys.com (10.144.199.105) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 15 May 2019 06:00:23 +0530 Received: from vineetg-Latitude-E7450.internal.synopsys.com (10.13.182.230) by IN01WEHTCA.internal.synopsys.com (10.144.199.243) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 15 May 2019 06:00:34 +0530 From: Vineet Gupta To: CC: , , Vineet Gupta , Peter Zijlstra Subject: [PATCH 9/9] ARC: mm: do_page_fault refactor #8: release mmap_sem sooner Date: Tue, 14 May 2019 17:29:36 -0700 Message-ID: <1557880176-24964-10-git-send-email-vgupta@synopsys.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1557880176-24964-1-git-send-email-vgupta@synopsys.com> References: <1557880176-24964-1-git-send-email-vgupta@synopsys.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.13.182.230] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case of successful page fault handling, this patch releases mmap_sem before updating the perf stat event for major/minor faults. So even though the contention reduction is NOT supe rhigh, it is still an improvement. There's an additional code size improvement as we only have 2 up_read() calls now. Note to myself: -------------- 1. Given the way it is done, we are forced to move @bad_area label earlier causing the various "goto bad_area" cases to hit perf stat code. - PERF_COUNT_SW_PAGE_FAULTS is NOW updated for access errors which is what arm/arm64 seem to be doing as well (with slightly different code) - PERF_COUNT_SW_PAGE_FAULTS_{MAJ,MIN} must NOT be updated for the error case which is guarded by now setting @fault initial value to VM_FAULT_ERROR which serves both cases when handle_mm_fault() returns error or is not called at all. 2. arm/arm64 use two homebrew fault flags VM_FAULT_BAD{MAP,MAPACCESS} which I was inclined to add too but seems not needed for ARC - given that we have everything is 1 function we cabn stil use goto - we setup si_code at the right place (arm* do that in the end) - we init fault already to error value which guards entry into perf stats event update Cc: Peter Zijlstra Signed-off-by: Vineet Gupta --- arch/arc/mm/fault.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c index 20402217d9da..e93ea06c214c 100644 --- a/arch/arc/mm/fault.c +++ b/arch/arc/mm/fault.c @@ -68,7 +68,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs) struct mm_struct *mm = tsk->mm; int sig, si_code = SEGV_MAPERR; unsigned int write = 0, exec = 0, mask; - vm_fault_t fault; /* handle_mm_fault() output */ + vm_fault_t fault = VM_FAULT_ERROR; /* handle_mm_fault() output */ unsigned int flags; /* handle_mm_fault() input */ /* @@ -155,6 +155,9 @@ void do_page_fault(unsigned long address, struct pt_regs *regs) } } +bad_area: + up_read(&mm->mmap_sem); + /* * Major/minor page fault accounting * (in case of retry we only land here once) @@ -173,13 +176,9 @@ void do_page_fault(unsigned long address, struct pt_regs *regs) } /* Normal return path: fault Handled Gracefully */ - up_read(&mm->mmap_sem); return; } -bad_area: - up_read(&mm->mmap_sem); - if (!user_mode(regs)) goto no_context; -- 2.7.4