From patchwork Tue Jun 11 18:27:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Oliveira X-Patchwork-Id: 13694128 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2103.outbound.protection.outlook.com [40.107.94.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D90814F132; Tue, 11 Jun 2024 18:28:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.103 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718130488; cv=fail; b=YkopSyTHqkkcdA2wMjBKxL5XIUYe3VWgoQ8snj72CCsTfRYRWNaa6bwi0rnAVcuYCaD1Sta5Nb4XvG65Zgp0aCwkEjMmSDIPbZelFqnSrSIvVadCQ/Fatb0hkWOxemWdN58Lo8jwxOkJhHsC7Bl5JL1iGdiA+cmJsDiLrLDHWoQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718130488; c=relaxed/simple; bh=WoNHH5duUhzgG0Stfsj480woqqSsl+cFqhXTFMZm/5A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=nkwNwOwsmIfiFPrOKkL54hrj0d309YlOhz4aPcMCyjSqENKOlbpQrrx6Wm+Xt3Ukq3/jTe/lwlBFYHm6mcy3Wninz/Ttyh+SMEu4wJYFaU+fzRzrN7jkxHhbHvOrotpkwtQ6bjdU1T+9/t6LnTZ8z7+v+VpvxBkfd2MsqISv5oA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=eideticom.com; spf=pass smtp.mailfrom=eideticom.com; dkim=pass (1024-bit key) header.d=eideticcom.onmicrosoft.com header.i=@eideticcom.onmicrosoft.com header.b=sKhC/y/y; arc=fail smtp.client-ip=40.107.94.103 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=eideticom.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=eideticom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=eideticcom.onmicrosoft.com header.i=@eideticcom.onmicrosoft.com header.b="sKhC/y/y" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FEM2l2idObSV7aTl8dFjanVABjMsQRPxvuM0XM3oLFRp80eZSood5FAABcZ+BuTNcIugdVlj5tTl0hPEr+bUIOp6s2+fF8sxFKsKcFnLYKHscOlPcHFVM8LUfHuP6pSVaumfu7mbiAGzHe4laqQBA22ZGOqgzcw7QEM/+HivMy5yVZ3K9m15Xer6eeZtqhRg9E6BoQwDSRSJ52HSRCojr49G8sWahCFaku7VgH17QVvu+eRRdeg7E2IK+L7rxh/f5jvV3iu7s/AvPjEwUKiET0pmlCINRVjPXbzaHHZPYIIHyMrQv9HjSV2g4AH4LQfyHzIbHgegsxfDDs57dF8mGw== 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=egpQP0BDXYyrYjOSywdL1sJt7M8DqRDf4NFqGyAHqgw=; b=fOrHqNHaP6h1juK8bd8cG3ceOGDwScuDnp0x2MhCdssxN69+fBViqrQ7EbT/fJM1Z6RVna6P2KkAv68omX2iy4qtDiJ7frsbtZO8dvgGtBsCYHOPyX356ygfyi+zZY4UZxK/MzDVHCZFla7HCBaoCpB74vn5wQHZ79Qz8SObZT1WOUuwFJF5rx4x4pWgtrnjipR7AF0fJCv/+tVwCAGuvw+WEzWGq5CREelEU1npIcR03aMSuxPfX74b5QLijDHzboCe+Y3ztCd4d+OvkFWOxVlzQtbXLHzdESU7BM1ioL39crrKXcrpUoPb83D4iwDm81I1qiA7p1Z2Zobt3nto3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eideticom.com; dmarc=pass action=none header.from=eideticom.com; dkim=pass header.d=eideticom.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eideticcom.onmicrosoft.com; s=selector2-eideticcom-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=egpQP0BDXYyrYjOSywdL1sJt7M8DqRDf4NFqGyAHqgw=; b=sKhC/y/yl1oMmZVZbF0L6LFSZstZS3C3NsRYboja29e7YYprCvucDqv7SeyJk2GZAJ4XLeZTB45P9pWU/i1e34kF3AyeapLusl3gq8G8mRUCGuPUiKi1lhnpG7E5Q9L5J19IM3Xf0fAKTnVj9cWP+Ns85qApwKXLc3qL77YawdA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eideticom.com; Received: from MW3PR19MB4250.namprd19.prod.outlook.com (2603:10b6:303:46::16) by BL1PR19MB6105.namprd19.prod.outlook.com (2603:10b6:208:39c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.37; Tue, 11 Jun 2024 18:27:59 +0000 Received: from MW3PR19MB4250.namprd19.prod.outlook.com ([fe80::3280:d8d:de43:6376]) by MW3PR19MB4250.namprd19.prod.outlook.com ([fe80::3280:d8d:de43:6376%6]) with mapi id 15.20.7633.037; Tue, 11 Jun 2024 18:27:59 +0000 From: Martin Oliveira To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Jason Gunthorpe , Leon Romanovsky , Greg Kroah-Hartman , Tejun Heo , Andrew Morton , Logan Gunthorpe , Martin Oliveira , Mike Marciniszyn , Shiraz Saleem , Michael Guralnik , Artemy Kovalyov Subject: [PATCH v2 1/4] kernfs: remove page_mkwrite() from vm_operations_struct Date: Tue, 11 Jun 2024 12:27:29 -0600 Message-ID: <20240611182732.360317-2-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611182732.360317-1-martin.oliveira@eideticom.com> References: <20240611182732.360317-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4PR04CA0113.namprd04.prod.outlook.com (2603:10b6:303:83::28) To MW3PR19MB4250.namprd19.prod.outlook.com (2603:10b6:303:46::16) Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW3PR19MB4250:EE_|BL1PR19MB6105:EE_ X-MS-Office365-Filtering-Correlation-Id: 81a4b7ca-b8aa-44c5-03a7-08dc8a4438d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230032|52116006|376006|7416006|366008|1800799016|38350700006; X-Microsoft-Antispam-Message-Info: YCJajgWDQyWZTP3DQAv+qUaoNx9aV5drFpQgU4ZY3CfIVtlB24s2JlsIyUBsEbnnj6EzeKJVXHSKqSU8CdbnGIPZvI/hdV+Nh8akksywCbjYxYrlXyxzEnJ2JQgRSJBmx6lMbRYYTGHZbwuU9/1HcSdgSvnk5R82wF8kKpxZlgwz8iB8MYfdnJfSWI2b52WFH6sm5JH99/zi42IKfZ7qhJjSrSHSe13dnNGmVJ48fdMb3sytyTvRmqKN6o1RCoa8KvLcx8TUkJeaBlrxXFSwMqIEfb8JwwaSsDStdTLTd4RF8G3WcTTLvZtIWPkRYB+1CSDiEnqijxvRDXfpl44SpxwzAEkRt61kVVQUJ5JF/WHjJeVWOiGD3lNKzyStlb5DZJgQ0uEpanROcGWqaBvCcBHYkQEc53G+n2SRTlh2bmvH9dIMp7amTsx4a0oYazHcmW0r2NJ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/J3+JXwiIuCKfWrD64ceBSbrIrM6fhstQatIDZJD9jL32HqV7lFGaQolxTN8QPEnAOk6eiC3x5kpkVFuX0grY9rEGtjmePSRlvVueSOV4rs4h6YJkcHi2eq6o59yEdPp3BqOyoNCxD7JT0XqUgv+esO/xs+xkL4jZRX+uVrHS6B9w70/pyOeP2CsXJHrW1J0qy28/tHmsZEDegE8gFGVgzKHpne0uWchi7dl3Ssjkj5A556/enKcGIhZuOEQen/qZR+dppwpYDpJh5gDZ/TvnemYS6FXHnh9QJL6QUIByka59POHkJOS1/vkUiYiouH8rn/pUDzt1KpdD2pWOVQXMGErYLKGNfrOevFgCMCSx98Dfi8JaaNpxDv9euNIvJj37+8K7N6IIhQOhTXERdMcTo+MA6v9ut2AWRZSmZP8Iewjn9oP734mBwaa5DCZbG59G4FdOpoC/dRODA14vrEI4o2VV/QsDvSTVlPIES+0sIV9U6KdMstpVBLWJGsxT+L8b0n92+CU6pxgDE1gSaS71t7P56q5//JTIEVDUM/IRCmkM4DZVzkWpzgLrhlkDvxJe1VldeNSR65DZPebILySktodKBI5WTDezb5b1VleFwfAogwNyTBHczQTt08WrqYumOi776YSqWX6+rctC42gpRw95gs= X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81a4b7ca-b8aa-44c5-03a7-08dc8a4438d5 X-MS-Exchange-CrossTenant-AuthSource: MW3PR19MB4250.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2024 18:27:59.6764 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3490cd4b-0360-4377-abb1-15f8c5af8fc2 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EnirLeYvlppbgpUVSXko/D+lRAutQq/Zf8NzJpbZTnDh4YryJzpTnYiR2icHv0LL3PvEftfMb4bt43wJUrXcu/fIvfDHXohJtP40drGiHXc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR19MB6105 The .page_mkwrite operator of kernfs just calls file_update_time(). This is the same behaviour that the fault code does if .page_mkwrite is not set. Furthermore, having the page_mkwrite() operator causes writable_file_mapping_allowed() to fail due to vma_needs_dirty_tracking() on the gup flow, which is a pre-requisite for enabling P2PDMA over RDMA. There are no users of .page_mkwrite and no known valid use cases, so just remove the .page_mkwrite from kernfs_ops and return -EINVAL if an mmap() implementation sets .page_mkwrite. Co-developed-by: Logan Gunthorpe Signed-off-by: Logan Gunthorpe Signed-off-by: Martin Oliveira Acked-by: Greg Kroah-Hartman Acked-by: Tejun Heo --- fs/kernfs/file.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index 8502ef68459b9..a198cb0718772 100644 --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c @@ -386,28 +386,6 @@ static vm_fault_t kernfs_vma_fault(struct vm_fault *vmf) return ret; } -static vm_fault_t kernfs_vma_page_mkwrite(struct vm_fault *vmf) -{ - struct file *file = vmf->vma->vm_file; - struct kernfs_open_file *of = kernfs_of(file); - vm_fault_t ret; - - if (!of->vm_ops) - return VM_FAULT_SIGBUS; - - if (!kernfs_get_active(of->kn)) - return VM_FAULT_SIGBUS; - - ret = 0; - if (of->vm_ops->page_mkwrite) - ret = of->vm_ops->page_mkwrite(vmf); - else - file_update_time(file); - - kernfs_put_active(of->kn); - return ret; -} - static int kernfs_vma_access(struct vm_area_struct *vma, unsigned long addr, void *buf, int len, int write) { @@ -432,7 +410,6 @@ static int kernfs_vma_access(struct vm_area_struct *vma, unsigned long addr, static const struct vm_operations_struct kernfs_vm_ops = { .open = kernfs_vma_open, .fault = kernfs_vma_fault, - .page_mkwrite = kernfs_vma_page_mkwrite, .access = kernfs_vma_access, }; @@ -482,6 +459,9 @@ static int kernfs_fop_mmap(struct file *file, struct vm_area_struct *vma) if (vma->vm_ops && vma->vm_ops->close) goto out_put; + if (vma->vm_ops->page_mkwrite) + goto out_put; + rc = 0; if (!of->mmapped) { of->mmapped = true;