From patchwork Fri Apr 12 16:04:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10898653 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 04BB217E6 for ; Fri, 12 Apr 2019 16:04:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD7DA28E2C for ; Fri, 12 Apr 2019 16:04:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CEDAF28EB6; Fri, 12 Apr 2019 16:04:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5037B28EAC for ; Fri, 12 Apr 2019 16:04:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 726486B000D; Fri, 12 Apr 2019 12:04:21 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6AE816B0010; Fri, 12 Apr 2019 12:04:21 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52C206B026A; Fri, 12 Apr 2019 12:04:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by kanga.kvack.org (Postfix) with ESMTP id 2E1B76B000D for ; Fri, 12 Apr 2019 12:04:21 -0400 (EDT) Received: by mail-yb1-f198.google.com with SMTP id d193so1136913ybh.13 for ; Fri, 12 Apr 2019 09:04:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:thread-topic :thread-index:date:message-id:references:in-reply-to:accept-language :content-language:content-id:content-transfer-encoding:mime-version; bh=RnalLb37tdOT68e+z6j3AK56+aLKTY24jeQrFgWRkh4=; b=p6LDBm/oIG5/PzEMGnigPu0AwKcW8Ama586WyrYJHt7NjUM1jczuyDsUl05obRmF6F Xrp4kv05NKmGZhkxKv76yVfgYPeza+09vKUBgGIY+K1OwYWJl6x/VJb+IYW/j1/n1biL xUNQ/Kg7Mec8H42/Dh6z8n5ytnAHz1gs4TD8hMf6ldJoWq5s9SBafdprVT6gHOvLu0dP BiePRBKTNjO+alWuKcO3q3RIKshkbntyWW8Zsni12WC7QEywkvPTxVdrt6DpNBReFSaR bPOktXkKTLUo+AK7U3VaRjlE0e+R+n32twTBP5DS5aj5ysKNHK1SP5t3HeHKtqyS936R ot9A== X-Gm-Message-State: APjAAAWLm+wWrZqaWrDr22Qa7HzbFx3TnSpCnOTgAsFmxx4U5YHUO+u7 G5GFOLovb83Eorfud9N36x1pWYnHh2yt3D7DQYD+NgQ/PfJW2O5GXE+WSynXmpDGHWU1pL3dcq4 fD0eFJtsSK88dSzNTacLVAFeUa9m9GSCF0QtMrJZha4UkOf9ED85GJKX0lURNRTt2SA== X-Received: by 2002:a81:4fcb:: with SMTP id d194mr46641885ywb.171.1555085060859; Fri, 12 Apr 2019 09:04:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqwsnh4OdPJ3Ke09CT6b5L+lR2CVvifmACyBWAsm0p2EEOTbIo1eRKt0KRerlzTdcXQBmcOu X-Received: by 2002:a81:4fcb:: with SMTP id d194mr46641813ywb.171.1555085060103; Fri, 12 Apr 2019 09:04:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555085060; cv=none; d=google.com; s=arc-20160816; b=sjrA0XgGJ8ON0kTzfrh490lr10n4UYpcVF2IP83jmKxgR7GlHgp9gzYpytHVhaXLdS yg0L+8FBlJ41DENLIOyzrBRBgZgUNFsPvMQ9Udz0QO4h4rt8tFj1vhbFG1ykamA9jpoS v8rlEpUEt/+erydwKOMpbG4aHIyrSpZF343DK1UEptlgVNkJqe/lRzxcB8AqX2eC8+t3 FBY2T80eK8Z6mQBtHuq+fQhq5EJu8gdgQMGk/OfV0i43zg1BHqSFzizwTrYZWBF53z6Y lZj42gbyBiRzGb+M1GnQlJmFqpmkSP9C/feJv0OL2NCyWPulIdS9xYnDQaPXne02lySa JIAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-transfer-encoding:content-id:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature; bh=RnalLb37tdOT68e+z6j3AK56+aLKTY24jeQrFgWRkh4=; b=XvxEI9SF9jmrHx6+K8Vp8HgB7T84MwVWHSdMQIrU1rYD6cZMZkbb0DvdelWEIeBcR2 j8NNbo0GYFswQ61q7FZM6s35qsL/sGGr5GU1wrT8zB/CDO/yN6dIfo9oAHoZm8Ty+SrD MM2V0/1UsAVdHOVHpFJhyuCVuI83dUv6MDprHuG81THnIBneJdl7xWAOnP3IN8zQL/j/ 84lTTOqIs7uwZ6VAcbpQIzL66xHpZcwsZm8Y7MsJsCcEGM3J4LjKvff0g0vNxErqRxGJ 9tmqSQqJTCy4A6z5hAGhRgswc/UhSb490fIHvdVknJqtQSFIKe4zJBMpmSA1Nq7xvsFJ Nw9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vmware.com header.s=selector1 header.b="hz/XNTXv"; spf=pass (google.com: domain of thellstrom@vmware.com designates 40.107.80.72 as permitted sender) smtp.mailfrom=thellstrom@vmware.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vmware.com Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-eopbgr800072.outbound.protection.outlook.com. [40.107.80.72]) by mx.google.com with ESMTPS id 126si26257606ywp.465.2019.04.12.09.04.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Apr 2019 09:04:20 -0700 (PDT) Received-SPF: pass (google.com: domain of thellstrom@vmware.com designates 40.107.80.72 as permitted sender) client-ip=40.107.80.72; Authentication-Results: mx.google.com; dkim=pass header.i=@vmware.com header.s=selector1 header.b="hz/XNTXv"; spf=pass (google.com: domain of thellstrom@vmware.com designates 40.107.80.72 as permitted sender) smtp.mailfrom=thellstrom@vmware.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vmware.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RnalLb37tdOT68e+z6j3AK56+aLKTY24jeQrFgWRkh4=; b=hz/XNTXv2Mz6ivglj2+apTuLe+XDDBBclwzmHnvuefg5lMSWSVjlc13uq490Tx++otEPwpPtBROcCWsxHrxoMtF0cFQBqDdPMB5x4wobsx4yq848EULhOQ9C2+ajrx8QtNMvAKiMGCdfdpafLNh+vhALjh5W1BnrAVyed6btBQk= Received: from MN2PR05MB6141.namprd05.prod.outlook.com (20.178.241.217) by MN2PR05MB6030.namprd05.prod.outlook.com (20.178.241.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1813.9; Fri, 12 Apr 2019 16:04:16 +0000 Received: from MN2PR05MB6141.namprd05.prod.outlook.com ([fe80::91e:292d:e304:78ad]) by MN2PR05MB6141.namprd05.prod.outlook.com ([fe80::91e:292d:e304:78ad%7]) with mapi id 15.20.1792.009; Fri, 12 Apr 2019 16:04:16 +0000 From: Thomas Hellstrom To: "dri-devel@lists.freedesktop.org" , Linux-graphics-maintainer , "linux-kernel@vger.kernel.org" CC: Thomas Hellstrom , Andrew Morton , Matthew Wilcox , Will Deacon , Peter Zijlstra , Rik van Riel , Minchan Kim , Michal Hocko , Huang Ying , Souptick Joarder , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , "linux-mm@kvack.org" Subject: [PATCH 1/9] mm: Allow the [page|pfn]_mkwrite callbacks to drop the mmap_sem Thread-Topic: [PATCH 1/9] mm: Allow the [page|pfn]_mkwrite callbacks to drop the mmap_sem Thread-Index: AQHU8UlgUqBNZlsCAEaA+wc3NiIS7Q== Date: Fri, 12 Apr 2019 16:04:15 +0000 Message-ID: <20190412160338.64994-2-thellstrom@vmware.com> References: <20190412160338.64994-1-thellstrom@vmware.com> In-Reply-To: <20190412160338.64994-1-thellstrom@vmware.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VE1PR03CA0023.eurprd03.prod.outlook.com (2603:10a6:802:a0::35) To MN2PR05MB6141.namprd05.prod.outlook.com (2603:10b6:208:c7::25) authentication-results: spf=none (sender IP is ) smtp.mailfrom=thellstrom@vmware.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [155.4.205.35] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 10f9a846-1d8b-4495-f803-08d6bf6082ec x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600139)(711020)(4605104)(2017052603328)(7193020);SRVR:MN2PR05MB6030; x-ms-traffictypediagnostic: MN2PR05MB6030: x-ld-processed: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0,ExtAddr x-microsoft-antispam-prvs: x-forefront-prvs: 0005B05917 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(366004)(346002)(376002)(39860400002)(396003)(199004)(189003)(110136005)(25786009)(476003)(2616005)(71190400001)(6512007)(2906002)(186003)(486006)(316002)(54906003)(68736007)(1076003)(6486002)(6436002)(446003)(478600001)(3846002)(71200400001)(6116002)(11346002)(66574012)(99286004)(256004)(14444005)(14454004)(2501003)(8676002)(66066001)(7736002)(4326008)(6506007)(81166006)(36756003)(81156014)(386003)(97736004)(102836004)(50226002)(106356001)(52116002)(5660300002)(53936002)(8936002)(7416002)(305945005)(76176011)(26005)(86362001)(105586002);DIR:OUT;SFP:1101;SCL:1;SRVR:MN2PR05MB6030;H:MN2PR05MB6141.namprd05.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: sWkyFCpQHafy3Wcw2aH9xrkAISUryjWv/yjF9No2JxMuwgTKhzm5tTypuA8/dDl2souKvun/0Rtx9zYY6YMpUbschdES/dmx1oIrTnRJJ35umFk2p1LIpJhXVNXDftd5uuI/ERYu8ZTZ2cDX0oepv1R6oiabE41cuMJat0HTb1HWq8dqJ/NmJPDV+7IYc+iYJ5gkfquGxR/RWXCkCnQQsSZsVPjE8M8T97tqIAIAJK2C8df3/YPRPAFTexsxQ2VXYW7hk4i82IfTSXFehlLeFswVhpJaF42ENV7nZr9uF5HJ0F2wzSlA3uqdiMLgrpOwyd8Lwa3RTXjYz0fLbvaM7URP2PmAelcs51l84YxmkOf65dpPH0pKVXZlLDx13j+USjg/vR7DCgQOKJNxzNZ4J0CaZR8umzvhL44LveIyeY4= Content-ID: <97BDAE19231BEF48BCE613AF38370D78@namprd05.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10f9a846-1d8b-4495-f803-08d6bf6082ec X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Apr 2019 16:04:15.9011 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR05MB6030 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: X-Virus-Scanned: ClamAV using ClamSMTP Driver fault callbacks are allowed to drop the mmap_sem when expecting long hardware waits to avoid blocking other mm users. Allow the mkwrite callbacks to do the same by returning early on VM_FAULT_RETRY. In particular we want to be able to drop the mmap_sem when waiting for a reservation object lock on a GPU buffer object. These locks may be held while waiting for the GPU. Cc: Andrew Morton Cc: Matthew Wilcox Cc: Will Deacon Cc: Peter Zijlstra Cc: Rik van Riel Cc: Minchan Kim Cc: Michal Hocko Cc: Huang Ying Cc: Souptick Joarder Cc: "Jérôme Glisse" Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Thomas Hellstrom Reviewed-by: Ralph Campbell --- mm/memory.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index e11ca9dd823f..a95b4a3b1ae2 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2144,7 +2144,7 @@ static vm_fault_t do_page_mkwrite(struct vm_fault *vmf) ret = vmf->vma->vm_ops->page_mkwrite(vmf); /* Restore original flags so that caller is not surprised */ vmf->flags = old_flags; - if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE))) + if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_RETRY | VM_FAULT_NOPAGE))) return ret; if (unlikely(!(ret & VM_FAULT_LOCKED))) { lock_page(page); @@ -2419,7 +2419,7 @@ static vm_fault_t wp_pfn_shared(struct vm_fault *vmf) pte_unmap_unlock(vmf->pte, vmf->ptl); vmf->flags |= FAULT_FLAG_MKWRITE; ret = vma->vm_ops->pfn_mkwrite(vmf); - if (ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)) + if (ret & (VM_FAULT_ERROR | VM_FAULT_RETRY | VM_FAULT_NOPAGE)) return ret; return finish_mkwrite_fault(vmf); } @@ -2440,7 +2440,8 @@ static vm_fault_t wp_page_shared(struct vm_fault *vmf) pte_unmap_unlock(vmf->pte, vmf->ptl); tmp = do_page_mkwrite(vmf); if (unlikely(!tmp || (tmp & - (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) { + (VM_FAULT_ERROR | VM_FAULT_RETRY | + VM_FAULT_NOPAGE)))) { put_page(vmf->page); return tmp; } @@ -3494,7 +3495,8 @@ static vm_fault_t do_shared_fault(struct vm_fault *vmf) unlock_page(vmf->page); tmp = do_page_mkwrite(vmf); if (unlikely(!tmp || - (tmp & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) { + (tmp & (VM_FAULT_ERROR | VM_FAULT_RETRY | + VM_FAULT_NOPAGE)))) { put_page(vmf->page); return tmp; }