Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2479903rwr; Fri, 28 Apr 2023 10:53:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7jsRjv4jtsdbJXzQJ33nU7SqA7mNR4QJyT9fMgqfUB0659pTn6m3qvF0Fsoj5anU09rX1W X-Received: by 2002:a17:90a:65c3:b0:23b:3422:e78a with SMTP id i3-20020a17090a65c300b0023b3422e78amr6142831pjs.6.1682704385530; Fri, 28 Apr 2023 10:53:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1682704385; cv=pass; d=google.com; s=arc-20160816; b=mTvJ1d7vYmNx8FFLa4WJ/MyZsp29MhbuMmwnhhHf3akDCpV8+vuqXNKWoB9+oSeB1j +kPdZ2u1LHpucfaHjye6e6XFDojgYknSMjQdYMthkBjxN18TTzM9vj54MMXeJYly8Ki9 zXXUvXZ32Vf6r5NQklv5mCmKw0TTupN8HPdTfOgGQf2Ox+UDlkt3BhF8dNeXsttFWHF8 0q6DMRKPbBW9cvEWxqinmY5Nn68RPtAOMMTbF1xQV73+EWOb08L7XO+MuAp4X9KxrU3+ BK8ujT4iFLgRvnWvwWtnpVcZFfl/pdU+lfuqiTohcBk8z5bKZAQpbLH6SSmp80b3MNlx JZeg== 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=GJa63KtyRFABesTYtUUJFXxLYeNRMQJG6Pgt8pm6Z+A=; b=DwpmQqE6pGw5+zcAnvPm+Dj0lCcmoaSzOZ64fzDXCp1Mm67aUymYSrTVFKGLvS1KT7 udRDHXZoRwO5uCsK2lBeuN+2dCmD4YtUWRbDF7BtRwof75fmCcBR7E9hYdbyHaw2lKDW Ks4/r0A7DPH+zF35YHZuDStRzIB3o75cf6qJSARZe9B0h1RiOkQh2FoU2UbHL3hVr2SR OTEkwO5P3ZFu3KOx5dJ9hcnzCjv6OwK54Oz8StR9idUz2FiFBxz9EKtX5YHIskGrpNnj 9hlsODQPdvr7P2Z7XYNASTCP1Nn/x053XabAmBl1KV3SQrGXHXohckCpbPPWCSwCXtFl 1x5A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="Y+/G/jZM"; 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:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mh14-20020a17090b4ace00b002476173727fsi25937503pjb.26.2023.04.28.10.52.51; Fri, 28 Apr 2023 10:53:05 -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=@Nvidia.com header.s=selector2 header.b="Y+/G/jZM"; 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346076AbjD1Rt3 (ORCPT + 99 others); Fri, 28 Apr 2023 13:49:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230149AbjD1Rt1 (ORCPT ); Fri, 28 Apr 2023 13:49:27 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5CE71B6; Fri, 28 Apr 2023 10:49:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZumSbkXfELOkQoNRDbqxb9KL7oqpLSXVuBZSuI9ymtZ+xaGbwzgLMjCr1IO1UWxM514pq/ati94h7uTN2cBpBsIDyVxSOJQAbDqtlhrcqsPwEukVf1U7ZmIT22AXreo6AqqWAPmtoxIqqvUeCXg8537SL6O5wn4BMltmX45LFkuKJ/IxpPwXKjYMai2EAKIJHu2lSLjBUGAU7uds38TBeZJVzRpD3mt4mHZYsKdLCEHtU1bWRF+W/llLVG243oQ0LMVkXrbOw8TOTgdpOenvUtqUD46PqQznLfNqvjTR/czFFadVtBGIDN77t5zoKrvCoXP/8X0HW9VJkpjZr52Rag== 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=GJa63KtyRFABesTYtUUJFXxLYeNRMQJG6Pgt8pm6Z+A=; b=gqUfiAmjwrUOsKBOag4rzO1BCkeMQWHe4iOEbiOPHoCrYtDnIscazSWAwHqVOdpKR2ekbwpPOw6bkokxZU07vaBl7g6Pdxsuo4lMFExPJ2Z/kFPVjeslhmWn3AmihzZieQ8mUPYsnPTWUeSJq50N1W6OVf+GIly9Qq2SnUVJO8XA331QupWnLq6O5qBKSG0t2/1JqXZMJzooHab+F8bvEfqYpESGBXqr6vbpvbUZEwQL/m8eSCl9WN25s/rsh1xGZaJtlDLdyY8Wrn01jUcc9ZGTM5A+EFG/PpPIfxHxCx+XZjOBzv4O2DrjFBnNJrja+KQa8aXMwMkWSM1BzHh4QA== 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=GJa63KtyRFABesTYtUUJFXxLYeNRMQJG6Pgt8pm6Z+A=; b=Y+/G/jZMRei9UiazqukLGeqhtyWl0ahjfQOimyIjH4DYffZpz2awJr+o8WLBp3fkMZ45DXuuOTnEwcaVsPuFaxLOk6HNL2RjoFqxf6A2SEweL/CHpRfhkiAaHkRq3rHF5ymD9n2xR8BvGAEbD4msoG85QFQvYWj3WKhZiQXyT3Bod43q8eFeq9OcoXfuUzWtSyKFrZXiihIiqkvIbphGPiYkJFye4RMmq79ow/JqjitY6IiF7FgAiydYDdRgX0MGvwOmP6yJ4ES1ZOUsx/F4YPqB8h5L+LBcqT0TGfiTUbaMOKHW1DWwD6u9/nvkWpAFbC1EmI8GKAuFNTcOmwXCvQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by PH0PR12MB8005.namprd12.prod.outlook.com (2603:10b6:510:26c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.21; Fri, 28 Apr 2023 17:49:23 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f7a7:a561:87e9:5fab]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f7a7:a561:87e9:5fab%6]) with mapi id 15.20.6340.024; Fri, 28 Apr 2023 17:49:23 +0000 Date: Fri, 28 Apr 2023 14:49:22 -0300 From: Jason Gunthorpe To: Lorenzo Stoakes Cc: David Hildenbrand , "Kirill A . Shutemov" , Peter Xu , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Jens Axboe , Matthew Wilcox , Dennis Dalessandro , Leon Romanovsky , Christian Benvenuti , Nelson Escobar , Bernard Metzler , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Bjorn Topel , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christian Brauner , Richard Cochran , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , linux-fsdevel@vger.kernel.org, linux-perf-users@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, Oleg Nesterov , John Hubbard , Jan Kara , Pavel Begunkov , Mika Penttila , David Howells , Christoph Hellwig Subject: Re: [PATCH v5] mm/gup: disallow GUP writing to file-backed mappings by default Message-ID: References: <6ddc7ac4-4091-632a-7b2c-df2005438ec4@redhat.com> <20230428160925.5medjfxkyvmzfyhq@box.shutemov.name> <39cc0f26-8fc2-79dd-2e84-62238d27fd98@redhat.com> <20230428162207.o3ejmcz7rzezpt6n@box.shutemov.name> <173337c0-14f4-3246-15ff-7fbf03861c94@redhat.com> <20230428165623.pqchgi5gtfhxd5b5@box.shutemov.name> <1039c830-acec-d99b-b315-c2a6e26c34ca@redhat.com> <34bc4f3c-8dfe-46ec-9f9b-358cdf4c37e3@lucifer.local> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <34bc4f3c-8dfe-46ec-9f9b-358cdf4c37e3@lucifer.local> X-ClientProxiedBy: MN2PR12CA0005.namprd12.prod.outlook.com (2603:10b6:208:a8::18) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|PH0PR12MB8005:EE_ X-MS-Office365-Filtering-Correlation-Id: 72b2c12d-896a-4501-ef50-08db4810e6d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wWvn8t3um7cc2+H3qketfS8kdNeBJnXehi4b9SI6HXAdEQ88/ff2yH5kR1YEWev1erAdnZnbfThNWupqPFmmm4j2VIMWgWodtdBplXmLuVam7MvzP8lWWQ3vDhd9Vyq7l28GK5TuNTx4s56wRA+tt3dbtu/U3pRnVlQ0DnZVffDYt1QC8puYIgX/EB/hl1ZGlhaDRATN7l+XQvVU1rgR/87Pse8JppZLFYZd720lH9a3yQGRVYohcGmFhM2Yb02TOyjHh6ZYGtFLACIO1rZkYU4/4q0NxMfSTGmfdCklC9o1fMU3/rGSU02qbYpN2dt1OkmdRlxhqByNFufCsKjh4KnPDoIfm9X7B7/AhiBEQESwoLL6nj7sxdKpgEeIQthA0o00EjpUftkFv5CArbgtme878Ng1D0lfAt6DqYAvrd7/GyDgX/m9EaJAoLPnlowcE6Y/g86wgZbmfXIK4BZvj8pehf4V2qAja+4nOCvSnSZRyReN8dAwDxmPRHInNX1uO9R2BXnroLbKz7ei2eE1H+jXE2vxX0JD2OR3vJmS/huxlju04T1vB47aXZ7y12aTQ38H/6KNELi5iagpDqVUfKyIo0tyRRMyw0Uoc08UtXc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(136003)(376002)(39860400002)(346002)(366004)(396003)(451199021)(316002)(4326008)(6916009)(66476007)(66946007)(66556008)(54906003)(6486002)(8676002)(86362001)(478600001)(36756003)(186003)(6506007)(6512007)(26005)(5660300002)(2616005)(41300700001)(7406005)(2906002)(4744005)(38100700002)(83380400001)(7416002)(8936002)(67856001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-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ascii?Q?4O3kOiF3e8dp0a852ARjiqixNryFmWqhTN3UyUcwfRixxXb9TEOad+NnY38T?= =?us-ascii?Q?xjzfxV4KifPyFxClUCX9ozFZCrGtB5k8Ld65qwM8J5vwVHkXzHvXOPUJsZOV?= =?us-ascii?Q?vhd4cCqlFsKB36Wmh4ZCYvuL1Ia5zjazk+uJGUnQXNkagoLv7kAjCJ03tzZU?= =?us-ascii?Q?cUsKs9sY9sbfSZvvW7XOLNquh3EJRkz+BvgzF9coULboN7xgA0nWuWQppF8t?= =?us-ascii?Q?hJbaUO8rsP2g1/oYFUMuYB6vCktSFJSqFhEHDVwNpsTJ6OSCvoR/IhoIVv6m?= =?us-ascii?Q?/0nA1VTVegF51dsHP+L2IvgrZJi8EMzsLmkVqzCvvFXNtZusufG6wuJUhR9P?= =?us-ascii?Q?fTwcBAMW4vRXdSQuRqVeFFxziIFZ17PSovv0SynWPoTum2l2NeGHHfqSrJ+w?= =?us-ascii?Q?6FSRkjRu3cQsfmgAEHtZ5gXLrtuC3V70JWDUUGOSL4f6dQG1b33Is30eLN6P?= =?us-ascii?Q?xrCy7BuEQsa9zNSLWMW/wkNHeS//3/5Dee6Esy8Fi8YZlVf5qV+zo1axfn1R?= =?us-ascii?Q?/tfVo+1K/P4ofLZwlH/tuj90vxN+74ZCREiFDGScwS59ii6S7XaPnDV+hcZi?= =?us-ascii?Q?J/Bwq4rLOdUXLPf39ZV6QQM6KjBEaBYfHRPQqg9goBoi3E462ts2yA2nunHW?= =?us-ascii?Q?Ib1x1eQUnDrZEb19FvPslRt8VxsoMvjzylAR0BjKmA/pvKzl0CD4ivq2YC3i?= =?us-ascii?Q?6Pkhu5vuz0VxpdiqFj2LaVjCHC59/hnSDVj6Uu3L?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72b2c12d-896a-4501-ef50-08db4810e6d5 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2023 17:49:23.4788 (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: 3WOBSiHeSxMV2cuSvzlpDBAZOq2fi6pWOIFx0rSG04SlWpRxM9b4j/qTglsJoA8+ X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8005 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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, Apr 28, 2023 at 06:42:41PM +0100, Lorenzo Stoakes wrote: > On Fri, Apr 28, 2023 at 02:31:38PM -0300, Jason Gunthorpe wrote: > > On Fri, Apr 28, 2023 at 07:02:22PM +0200, David Hildenbrand wrote: > > > > > > No. VMA cannot get away before PTEs are unmapped and TLB is flushed. And > > > > TLB flushing is serialized against GUP_fast(). > > > > > > The whole CONFIG_MMU_GATHER_RCU_TABLE_FREE handling makes the situation more > > > complicated. > > > > Yeah, you have to think of gup_fast as RCU with a hacky pre-RCU implementation > > on most architectures. > > > > We could make page->mapping safe under RCU, for instance. > > > > Jason > > Does it really require a change though? I might be missing some details, > but afaict with interrupts disabled we should be ok to deref page->mapping > to check PageAnon and a_ops before handing back a page right? AFAIK not on all architectures Jason