Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp306601pxm; Wed, 2 Mar 2022 15:59:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJyKCgUjgA5vPGWq3RsDG7fWRQTeXAuB+4UzRhixBRuUsbKj2mizcuBsr3xbYgQxldyHfAHg X-Received: by 2002:a05:6a00:238a:b0:4f3:fbf3:e611 with SMTP id f10-20020a056a00238a00b004f3fbf3e611mr22262075pfc.11.1646265547004; Wed, 02 Mar 2022 15:59:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1646265546; cv=pass; d=google.com; s=arc-20160816; b=eVqgyb/Iz4GaDUO/CucYf9W4HZTsBSUbjRyrG4beKpRm8hJ9NR90ZFgp9/qX/c//qF D/804s6xML/TdubtTSozCdM8k6jl6RnMTybrYNbhn9dEOLyEdMVjsSg5SEyGZfYxHNwg K78UaTHUn3W6JO76A4kOA3UjvYbbCMKLgefRZGDl/2wx2f7o7OH89gclkcEUj28dGOXY Cc7SFkLuI1LKbUMdvSI95vLuoiTgD7OuUBTpqXwhfRyhTbgnu/6cT+qEc0i/aJjSW98n uPfR/lBkfCoDFnV0wQTpZD3xp00jSFurov3g40yMHX0W+rT3Y7kuOvH7xeBQkhTz2bnI 7K6Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=D3Gxvrl2nAYrnSi4OIcaJuTcFNV6uIW8oT7cONq8pnM=; b=htpb/vmV/8kWHCErZHoKal/8Qfgz51cJqn/mErUleE0fTepKVbR6ZTX6RfakrIxmsV IyS7ZTIdDa6tFnEujtpfbGMDsuEW4egMXZBes8EfQu6/c8FBo5t0uLqL3ya/h8lfsAkF 2z9su2/xBYPFDhTjw21gRC98no9Owh2NUHQVwZbt96BcyRrhUXTMzq2pQm8YSQXcZV4k Sft3GQQ41bEUqzJWfLFBaCo6f/0tQ6u0Am7BvFv7NTlzfW/L7JxQTgOyIIISqXBtLgF0 7gAq/fELzTm3DZkYa1jpKbGld/UY5Gi0Er01sOKoILwikuoNJAq8JjOCfrfXwU39jTzj 45xg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=emcgUdGw; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n128-20020a632786000000b0037462d8c54esi411112pgn.378.2022.03.02.15.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 15:59:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=emcgUdGw; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3352D199E01; Wed, 2 Mar 2022 15:19:12 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242669AbiCBQ4u (ORCPT + 99 others); Wed, 2 Mar 2022 11:56:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235475AbiCBQ4s (ORCPT ); Wed, 2 Mar 2022 11:56:48 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2041.outbound.protection.outlook.com [40.107.237.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B34A355BDD for ; Wed, 2 Mar 2022 08:56:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iYvJmM4GE0Vmnk/vM9B9Uvt2Vys05/zx7KedrC/OttA1bxntg34nMLY4g8XErfrJm3E8rH9rZCaDOwGcTJoxEaL75cxjJhqj3P06iJKIzr0bcon3wS53Jakrau8sHWeuAq935UZdjEME9PbvA2Z4KdRFJ+suaG65RrfSZetvpcPlnSBJHo11Fzn9uZE1U5eDxCxttnstbwZDK5ILpZqWQTqabhqA/JmUTbLTXzxRPhg4yFEjRmCFd8y96kIp9LVIAUQIwcooyYsnG6ELI93ysfmEPUXxs1TvfiLnZXyqMVrgNMn20FvcHr5CVPCuuUlmgekDiIgtvJR+/X3ZqxmfpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=D3Gxvrl2nAYrnSi4OIcaJuTcFNV6uIW8oT7cONq8pnM=; b=WcZB0aKoOZOGRQps3dPh1KCLzt3zvTeDugGniXoHpPVXgP0i01vAzHsr6EgVT1Dnqa7TZNr1ERJOUyoXKCXE31rtJcYStVGPuIEkYpapm2HmBVlkHl+1k7hN577YLG+ZdLvIzmTWADYETBOR9EwVNJAZlV5jRiHX7rFxNtfrU11lbjcAbAuvDszmJrmjg+jUWCa88r3JMC15fHYoUb7bicCynxZOWaKe31AQgrX3SnuniPDk/q/Q8/eNpbEgrXB0/9YL9VlKXMJzRanvaEf0JmyHgQdFU2Bu1ZObVqWSEeJCVc/6+cgb83CucOzUxOAOZ3FhWRYnVhBXJAJQ5pCpPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D3Gxvrl2nAYrnSi4OIcaJuTcFNV6uIW8oT7cONq8pnM=; b=emcgUdGwj3Q7MEyD4Cw83zpeAE6IAn9SZFRLWhwcvWhWfYg+mQzGlZhlOsLpfBwdKbqECnGf/nmQcff6TqaGrMyH7mgVuZH5w4uzX8cgOYXjqU/PlTl6p5VR6X0xt5yrYjbbtr51FXMgPQS2P9mlVr55j1qYCL2ix3bwXnfzbrtcoe+1amXprf8eeW+oYPfcGZTh+nyj1zYAwm5UluS7G/XL1SDf/DgdnLrHIxuD4x4Sqhkjq9fGdkclCslC1MwaMzKw/L1PnOgpvYEI/Y1LyqPEMFYf7hqtQoho8ltSODvlV536DLIqCV4v2OSvXPvwcVk3IUlQXr8mfg+3T4Uwlg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from MN2PR12MB4192.namprd12.prod.outlook.com (2603:10b6:208:1d5::15) by BL1PR12MB5802.namprd12.prod.outlook.com (2603:10b6:208:392::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Wed, 2 Mar 2022 16:56:01 +0000 Received: from MN2PR12MB4192.namprd12.prod.outlook.com ([fe80::51a0:4aee:2b4c:ca28]) by MN2PR12MB4192.namprd12.prod.outlook.com ([fe80::51a0:4aee:2b4c:ca28%4]) with mapi id 15.20.5038.015; Wed, 2 Mar 2022 16:56:01 +0000 Date: Wed, 2 Mar 2022 12:55:59 -0400 From: Jason Gunthorpe To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, Andrew Morton , Hugh Dickins , Linus Torvalds , David Rientjes , Shakeel Butt , John Hubbard , Mike Kravetz , Mike Rapoport , Yang Shi , "Kirill A . Shutemov" , Matthew Wilcox , Vlastimil Babka , Jann Horn , Michal Hocko , Nadav Amit , Rik van Riel , Roman Gushchin , Andrea Arcangeli , Peter Xu , Donald Dutile , Christoph Hellwig , Oleg Nesterov , Jan Kara , Liang Zhang , Pedro Gomes , Oded Gabbay , linux-mm@kvack.org Subject: Re: [PATCH RFC 12/13] mm/gup: trigger FAULT_FLAG_UNSHARE when R/O-pinning a possibly shared anonymous page Message-ID: <20220302165559.GU219866@nvidia.com> References: <20220224122614.94921-1-david@redhat.com> <20220224122614.94921-13-david@redhat.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220224122614.94921-13-david@redhat.com> X-ClientProxiedBy: BL1PR13CA0111.namprd13.prod.outlook.com (2603:10b6:208:2b9::26) To MN2PR12MB4192.namprd12.prod.outlook.com (2603:10b6:208:1d5::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5d8e84b5-aa7d-48e3-acf4-08d9fc6d87a1 X-MS-TrafficTypeDiagnostic: BL1PR12MB5802:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5XzcdjVRWnhnLIxhzKrznjiSLV55HSEFwQu+vGH0+hRI9amPG5RHQamLsgmdQ3/1F1uI7g7fVQPn4CT2VRVD95d6djZoPWL0+PACEJLP0MYP1Rpdoe2+fRfm+Opkn9q3CXJWx3GNTQBoRcAFAE3OahFi3j5JT6u3gh61KT4mw0soH91yIM++DJw/z+yKANKwaOT6enX63IXiupj0pqJ6lA+YSxPNjN0ZV/5200uioE0sNzpY6QyJiTuPjL7ZbunanM8QYqXDcveNwqfnwJrhZFComLiGtRECDzHzwdedY9O+LZvAKnRfkVVXcBH6Ec4LMevR0nHp2VAKIMSN1KMlZ6d1RpbXI6CDfU3/kDMo1a1rz30ISEsW6DhwCbXaV/iVP29H0bTImjoHGecsvAiGJ8WNBmiPYSHtpQqQS8NyDiz9k0/szSnW608P/zEykpwclfsCf7jrl/7fzaS6VTO1WAlwx3RrEPb1QF/veCnhRa+J5DY6yuM8hQsp4mkRkh+bIBB0ZFxT3lr+2rrC8lKmT3EpGA8jXQDDevx5E+v9k7ANptErLCyUtK2JoTRqnOMTEK/nnk261LO5AkNZuK3R9AHafm1EsaPXpi+jJ31OzLxutj2WdLXcpuTNn2tP1wyqFfCMf5LmtJA0kEWX2IAok+YuWImPaMjUbaynN9ratzvbH1HoNGFNKTm8fBDSTPfCa9mvzsoICkUOjvsl32wayA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB4192.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(26005)(186003)(33656002)(6512007)(2906002)(2616005)(6506007)(1076003)(86362001)(38100700002)(83380400001)(54906003)(6916009)(4744005)(5660300002)(4326008)(8936002)(508600001)(6486002)(66556008)(316002)(66946007)(66476007)(36756003)(8676002)(7416002)(27376004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?7IxB3Y2X62mvld8wBfa3dL83y0B0Ljmeo4p4s5QBVvqMSODfQErjkDB7jD3m?= =?us-ascii?Q?oewDzo5v1rvcl+GhF9HErPhikgcMsng5gXpdwPyE2Uj3AWC9Lry+G3xZNJND?= =?us-ascii?Q?vxUpOugA7c4wBEF4SdEvmMHh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ascii?Q?mRStlBBIWAjiFH/wwENedOBXPjt4TM1M+YCKhh4sorGEK5HI+1CX/RamzWeJ?= =?us-ascii?Q?6jtF7RmjTd8jIlH7V2c/3Aqynqw1PaTzsNE0a1WsKKAep9pI0jB3ZiYI0YzQ?= =?us-ascii?Q?cSFBz/dH8/Y3a7bsiciEKjGyzJl5wQXPSxdyR2rJrtHTq7elYBlENWfG9sz0?= =?us-ascii?Q?hOWbM/eIg8rB5kSvk2j8+YyuTXByTVCu2BTiU/Fu2fRxUDZajEu2FYlhOgkA?= =?us-ascii?Q?tlfH929ejLcezVyI0r8FYGsfUlinXXcfvv7+hVHpX3PXO896FIRtu11Nks0q?= =?us-ascii?Q?OMRG7pQvjDSZZ9P47qPyqj1diKXlmG97eFlJUogOUgUnzJpssEFS91vmN9q4?= =?us-ascii?Q?6PeYRiax/XS0wd/E+8dJenSeBQw/JeFlDx0K9aGeQuhoq6VkWsM8Ww0HCsz4?= =?us-ascii?Q?6TiG1Nd6lGZtOGOoxiFRBETUM+KCEUT83XmpbKVp5/xH41zZ79nRE3D5iZBZ?= =?us-ascii?Q?qHlu3BSNFi9Cq8JMyjDpSlP0Qcr87nvIRbuTrdzlncdG0OTp+jnHcYhE1wcW?= =?us-ascii?Q?s2W387ioOc5TZAke1x0=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d8e84b5-aa7d-48e3-acf4-08d9fc6d87a1 X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4192.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2022 16:56:01.0084 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: M8FD0XXZ12c5nsSGB1g8h/3w2jkKtKIOfJRMsrTe2QV7hnC4ZVp6qybWvIW+ndnE X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5802 X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,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 Thu, Feb 24, 2022 at 01:26:13PM +0100, David Hildenbrand wrote: > Whenever GUP currently ends up taking a R/O pin on an anonymous page that > might be shared -- mapped R/O and !PageAnonExclusive() -- any write fault > on the page table entry will end up replacing the mapped anonymous page > due to COW, resulting in the GUP pin no longer being consistent with the > page actually mapped into the page table. > > The possible ways to deal with this situation are: > (1) Ignore and pin -- what we do right now. > (2) Fail to pin -- which would be rather surprising to callers and > could break user space. > (3) Trigger unsharing and pin the now exclusive page -- reliable R/O > pins. How does this mesh with the common FOLL_FORCE|FOLL_WRITE|FOLL_PIN pattern used for requesting read access? Can they be converted to just FOLL_WRITE|FOLL_PIN after this? Jason