From patchwork Wed Apr 24 12:00:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10914643 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 0E2BD1515 for ; Wed, 24 Apr 2019 12:00:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0D1F28A11 for ; Wed, 24 Apr 2019 12:00:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EED3028A25; Wed, 24 Apr 2019 12:00:38 +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 A4A0C28A11 for ; Wed, 24 Apr 2019 12:00:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 15C346B0006; Wed, 24 Apr 2019 08:00:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 106336B0008; Wed, 24 Apr 2019 08:00:32 -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 E4B9E6B000A; Wed, 24 Apr 2019 08:00:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.70]) by kanga.kvack.org (Postfix) with ESMTP id BBDC16B0006 for ; Wed, 24 Apr 2019 08:00:31 -0400 (EDT) Received: by mail-ot1-f70.google.com with SMTP id q23so10663165otk.10 for ; Wed, 24 Apr 2019 05:00:31 -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=SoHkp5gsl9DN4Hd13XTXMAdh4moT6hIRFvzZcADO0t8=; b=Y6kWSETcw7DUgqCdDEtBg+AG1JjDH9EJwswsJjrUGlBNij/XlD8XAgUE2MUqgVroSb /65xZWvkrEJIyRwKq3FKOZuu3iUlpUj4aqjgU+nOj1sOoc0vLDCKNMAcuqu25k4/Zmxu 6pjOxzLHmpUta1+CPsjw6XS4FOuNid6mBxSNeCRAzvcKUK2AHBDeClXMMQr//oT/DU7E 0GkWKp0EUoRY9sGQ042wpEgN76AwPYiRwxRPdCPZWom7OfM09i1/Lg3iC2CR3poi3Kfr BOuuwK2Zaa4nWnzJDDu9ZaCSNGjgtulhLPeoT/mJvrkOcwtGdn903OjRslp4njDcweWg /FwA== X-Gm-Message-State: APjAAAU1fhyhzMJqERtpt6vGF0BFDVLG0WlfVrFyUK1iNuRVVIV5/6IO i2E/NA6dStfvrevO1sIKUx7V+sbTJbx+HNOoQ88yKUznhhNUtqbdChdcwKEuoRYnNGioRiz76Px 7Tv5FFLaJ2c3Y8KcRdfc0vbeTHgz29JJ8dLBZST84wmo8SWlJSk+ee9tIo7SHjXOjiA== X-Received: by 2002:aca:da43:: with SMTP id r64mr5135481oig.11.1556107231198; Wed, 24 Apr 2019 05:00:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFLP5qbHp6YBHdVhPf/R7ozSceg+oiwPNfQcXYI0m4h+Yj/YZ4rhJQ/TSZT4DkMHF252sY X-Received: by 2002:aca:da43:: with SMTP id r64mr5135428oig.11.1556107230259; Wed, 24 Apr 2019 05:00:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556107230; cv=none; d=google.com; s=arc-20160816; b=g8ZoCkPRHubVKD3QVITqMr3qgT7kFHytyhL+aBlngDnkloSQkJ6nSCI+3jO3G5Fpkq s6MEBlnM6zswmd7NmJXv9A87o5aVEcvxJPOb8FTKxXbFNwyWF2PyN51WuoB7zumDnnck QpvOaesLMHv47leo2SmsP62MTwyWhwwwbj4qHb2XRDaS7CwLwZ0A52mYhvciAVIzaEyg KpXQninaCwfTeWDtDnf6zjzEwELESOeT30ZOq8a7VktsZPdewjBTpJ1wX1QP2c0Qo676 hOEk2xdColSBnT9ARNUyULETT4jeR1jQKr+zcLw0TMAueze8ZJA0bPLONOE4RQQkmHMC 1grA== 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=SoHkp5gsl9DN4Hd13XTXMAdh4moT6hIRFvzZcADO0t8=; b=NPKLdyuFAYE4ESkZk8TYtSK0RWuTxQ6DTzU8oKiDbKPB33G8IXlFjt5jF2CzaHMwjK MwURKoHhfLd6v4624MOJq2hGeWVagNWNVKlB5rhDzPZyeDlrpV7F8A69pZRANSZGC/xJ Mq0D52jHCB5AKeZQllq5xv/tD1wDlmxBAYBCLpMYNlLtfJmJaxLFINvlIwL3/+O1pPKJ VKJ4WPZz/Ip+Rxj80GTi05c6JLn7WqzHTkuVaEVgu9qnDO8ROn2ABHS1+fmXyH9a3bzK VtVgUjF3k0kBzKGiW+pToIIKzFBoKoUtrcK6gGPpGknphsHqSc+ZtC0hJVs9zmkTBsdn tJ3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vmware.com header.s=selector1 header.b=NcpECmww; spf=pass (google.com: domain of thellstrom@vmware.com designates 40.107.81.48 as permitted sender) smtp.mailfrom=thellstrom@vmware.com; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=vmware.com Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-eopbgr810048.outbound.protection.outlook.com. [40.107.81.48]) by mx.google.com with ESMTPS id k204si416748oib.181.2019.04.24.05.00.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Apr 2019 05:00:30 -0700 (PDT) Received-SPF: pass (google.com: domain of thellstrom@vmware.com designates 40.107.81.48 as permitted sender) client-ip=40.107.81.48; Authentication-Results: mx.google.com; dkim=pass header.i=@vmware.com header.s=selector1 header.b=NcpECmww; spf=pass (google.com: domain of thellstrom@vmware.com designates 40.107.81.48 as permitted sender) smtp.mailfrom=thellstrom@vmware.com; dmarc=pass (p=QUARANTINE sp=NONE 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=SoHkp5gsl9DN4Hd13XTXMAdh4moT6hIRFvzZcADO0t8=; b=NcpECmwwletj95HiTJ9bpikBF3RMuaK9UNscgw/COHFUzfO92YZzZon+MKrJs4QekJQIkagEHzjiskH4GZPBH5BK+UUkAYuV+91/dceaHIUkG36dd/R2YdVNS+TvMbbTyXhbiQzOP5qQqf9xuW/zmJnPTifmdtIrRSw7DGB+CXI= Received: from MN2PR05MB6141.namprd05.prod.outlook.com (20.178.241.217) by MN2PR05MB6272.namprd05.prod.outlook.com (20.178.240.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1835.6; Wed, 24 Apr 2019 12:00:12 +0000 Received: from MN2PR05MB6141.namprd05.prod.outlook.com ([fe80::441b:ef64:e316:b294]) by MN2PR05MB6141.namprd05.prod.outlook.com ([fe80::441b:ef64:e316:b294%5]) with mapi id 15.20.1835.010; Wed, 24 Apr 2019 12:00:12 +0000 From: Thomas Hellstrom To: Linux-graphics-maintainer , "dri-devel@lists.freedesktop.org" CC: Pv-drivers , "linux-kernel@vger.kernel.org" , 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" , Ralph Campbell Subject: [PATCH 1/9] mm: Allow the [page|pfn]_mkwrite callbacks to drop the mmap_sem v2 Thread-Topic: [PATCH 1/9] mm: Allow the [page|pfn]_mkwrite callbacks to drop the mmap_sem v2 Thread-Index: AQHU+pVFpIoNyabDrUq+mablu5W5Jw== Date: Wed, 24 Apr 2019 12:00:12 +0000 Message-ID: <20190424115918.3380-2-thellstrom@vmware.com> References: <20190424115918.3380-1-thellstrom@vmware.com> In-Reply-To: <20190424115918.3380-1-thellstrom@vmware.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR07CA0208.eurprd07.prod.outlook.com (2603:10a6:802:3f::32) 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: 3e7e466c-4a1d-4825-7ce5-08d6c8ac67b4 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020);SRVR:MN2PR05MB6272; x-ms-traffictypediagnostic: MN2PR05MB6272: x-ld-processed: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0,ExtAddr x-microsoft-antispam-prvs: x-forefront-prvs: 00179089FD x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(376002)(136003)(396003)(366004)(39860400002)(199004)(189003)(64756008)(66476007)(71200400001)(66446008)(86362001)(66556008)(305945005)(7416002)(14444005)(50226002)(478600001)(256004)(8936002)(81156014)(7736002)(81166006)(2906002)(66066001)(66946007)(71190400001)(8676002)(4326008)(25786009)(1076003)(66574012)(73956011)(186003)(26005)(6116002)(6512007)(486006)(6486002)(53936002)(110136005)(102836004)(6506007)(386003)(316002)(99286004)(54906003)(5660300002)(11346002)(2616005)(68736007)(14454004)(36756003)(6436002)(446003)(476003)(76176011)(3846002)(52116002)(97736004)(2501003);DIR:OUT;SFP:1101;SCL:1;SRVR:MN2PR05MB6272;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: P55ZQkkMq+fvDR7dqCGUOJwKa5c9q48YjNeF4zlf41jt3c1ucZgc0uSnPKCnyioyaRLhKeOVoHNuQzqdxubXDb+9LMWDV3NZEw2fKIrd6Bg6uqxRTMIi/wLVhZ/S6STpBl716Qu9K0Vx47WB8on/UZewJUvOWPP0m+38Ua/sDzEsl3GKl478kd56gJwS5r0KAoluiFQ2fKeXsNBmw3QzSuMgjowzoZCuqyn747saO8jgLHBNo7uvWWpYKPJRkYZGUo3CpkMJe3t/MuRFf2t9W/OXlrhIzMBCVNrpcocUyK3zvPfiXCpnpziwt300Q8PgOQrRG7ZJWvXbrC0Bk8J7nsSHMBniIYi7SM2ToDwMlFTr1Q05FGQaBDlaM2zmkH6DDS8ADkpcbtYTQlLXHVL6mJ6kNf91dpuj1LpePYie2Jc= Content-ID: <85C7C1DA7782054E8800582057FBFE3C@namprd05.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e7e466c-4a1d-4825-7ce5-08d6c8ac67b4 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Apr 2019 12:00:12.7251 (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: MN2PR05MB6272 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 --- v2: Make the order error codes we check for consistent with the order used in the rest of the file. --- mm/memory.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index e11ca9dd823f..9580d894f963 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_NOPAGE | VM_FAULT_RETRY))) 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_NOPAGE | VM_FAULT_RETRY)) 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_NOPAGE | + VM_FAULT_RETRY)))) { 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_NOPAGE | + VM_FAULT_RETRY)))) { put_page(vmf->page); return tmp; }