From patchwork Wed May 29 18:00:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schubert X-Patchwork-Id: 13679351 Received: from outbound-ip168a.ess.barracuda.com (outbound-ip168a.ess.barracuda.com [209.222.82.36]) (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 1B08AFC18 for ; Wed, 29 May 2024 18:01:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=209.222.82.36 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717005685; cv=fail; b=Hy1N7pmUOb/b+qEuSM0/93VyMXIfmDudBwp1knEVFHFkePxlBB5WiCXNFn1A+B3VhmvUnhfNsFgUxllgw0ycybEApK/pxiYJJ7boqSvPM53p4PoOqj/CIeNdZ18I01n7pCAqqoKf7so2o5lFWEwlNficClFgXuwz1ZGkYP6TLJA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717005685; c=relaxed/simple; bh=MEK1vbj5ymTp2LNfUE+mfKARrGzFvVGkw7vWcp91zlQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=utUtLqm7AlAGeXeUMyrx6DJMv4G2Eh+RNNoA5xEK/6KUQVPk0WQV2laRTamoIhu5MdrTcOJDnCq1Dzn01fPYfQuEl2Bq5KAz7uKXajdiE5oRR9Yk3lD1+NlwgiBXDqy7zmz8miMmKhAJAFQg+Qfji2AgtDO4IBOVeRvtY0XVx2A= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ddn.com; spf=pass smtp.mailfrom=ddn.com; dkim=pass (1024-bit key) header.d=ddn.com header.i=@ddn.com header.b=jncKEe5e; arc=fail smtp.client-ip=209.222.82.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ddn.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ddn.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ddn.com header.i=@ddn.com header.b="jncKEe5e" Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by mx-outbound15-162.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 May 2024 18:01:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l91R9yQOgcqDwAUY3a6CpDNcbTl1fI/N9ie8EnMl9ziTKvhGBTh3XdfrETJ35b7jup/bREwsk2PIOp51hPFBU77e7ag6vy7cbhH/My6s6LcYHzhy6bpuYpfcdV0uXS18fAS0mA+LfzOfnqHgu7B7HJfUHpMNe2VwaHs09hYZ0B7rhGc0+49YRsQnF45NNm2TyJzcQmTbN7bDDOi924r7SYZosxnu6Dp/2HQ0P9Q/zWhKgDVWsG7syCjTS7VcgKfKwMSKeL2n7AKhoKksgGtNMTsHC20NAOW24GqD3AJGiJFz77AbHrJ1COwA/gcAxBLxDv6MjV+sIu8gMZe6ZZkFJw== 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=aSDWP2yoy4IFjpUm+Q8LhV3ckwRUXFIc/vCejQP3TmA=; b=N61dVFT2GElBIjsDgtefBKVsyF11tVmhLX8zFMBSdcxfG/s7rF3yh8kCTIZwuzaxcn9ktZFTYRRFsj/OUC40qyGMkc3JxZTcqCuZyeY8E0DWxI5ku8Ee+PtPuV9lHL+bQhYPHXoFWHNppfAkWVxq/dPgnMwKDaEopPW+boCU3yYX0VvJZ0Q4XWFLqsqT0Wywv+tZwv+tkrak8Ln0DlA2TCZ+jP3kTWjBU71nMYQt1+PsqvQjDl5VEodM7E9uT6dCQ7gOsT1WnsaUHEDNwW8O9RYgB3kZFWgs/bIp+CgQJ4bhDJUQV8bePWZmnGVVX/ERIV52GwXEm5/8riXfbMNHww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 50.222.100.11) smtp.rcpttodomain=ddn.com smtp.mailfrom=ddn.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ddn.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ddn.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aSDWP2yoy4IFjpUm+Q8LhV3ckwRUXFIc/vCejQP3TmA=; b=jncKEe5exS+Lj7juLD8tRH8/iE8mF6LtnDbljszqXWR3iHxz4d75wpGOAeLspxnJf+Z7XMI+jIOJSWDLitQOh10jJcQu7aBXFLI6lr5LII6Gs/lyBrn9mLzYEBAnoiHqziDNzEZAoXIxuK7qbvXLk170Oz/0tkgr1gU1fylu0zk= Received: from PH8PR20CA0009.namprd20.prod.outlook.com (2603:10b6:510:23c::23) by CH3PR19MB8408.namprd19.prod.outlook.com (2603:10b6:610:1ce::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Wed, 29 May 2024 18:00:56 +0000 Received: from SN1PEPF000252A2.namprd05.prod.outlook.com (2603:10b6:510:23c:cafe::f1) by PH8PR20CA0009.outlook.office365.com (2603:10b6:510:23c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.19 via Frontend Transport; Wed, 29 May 2024 18:00:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 50.222.100.11) smtp.mailfrom=ddn.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ddn.com; Received-SPF: Pass (protection.outlook.com: domain of ddn.com designates 50.222.100.11 as permitted sender) receiver=protection.outlook.com; client-ip=50.222.100.11; helo=uww-mrp-01.datadirectnet.com; pr=C Received: from uww-mrp-01.datadirectnet.com (50.222.100.11) by SN1PEPF000252A2.mail.protection.outlook.com (10.167.242.9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 29 May 2024 18:00:55 +0000 Received: from localhost (unknown [10.68.0.8]) by uww-mrp-01.datadirectnet.com (Postfix) with ESMTP id 2085A27; Wed, 29 May 2024 18:00:55 +0000 (UTC) From: Bernd Schubert Date: Wed, 29 May 2024 20:00:41 +0200 Subject: [PATCH RFC v2 06/19] Add a vmalloc_node_user function Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240529-fuse-uring-for-6-9-rfc2-out-v1-6-d149476b1d65@ddn.com> References: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> In-Reply-To: <20240529-fuse-uring-for-6-9-rfc2-out-v1-0-d149476b1d65@ddn.com> To: Miklos Szeredi , Amir Goldstein , linux-fsdevel@vger.kernel.org, Bernd Schubert , bernd.schubert@fastmail.fm Cc: Andrew Morton , linux-mm@kvack.org X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1717005648; l=3644; i=bschubert@ddn.com; s=20240529; h=from:subject:message-id; bh=MEK1vbj5ymTp2LNfUE+mfKARrGzFvVGkw7vWcp91zlQ=; b=wvvWf+kh5GtFI/JGVzigS1TQbbczThjg3WJf1TqAJdEr6uffBA+v6LPQ0OKHxRlWpdp1EaBs1 k8Y4k4nEqlBBCHQgv87hXfFlemn57LisBD045TRX2i99U3l3zIH2iyo X-Developer-Key: i=bschubert@ddn.com; a=ed25519; pk=EZVU4bq64+flgoWFCVQoj0URAs3Urjno+1fIq9ZJx8Y= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF000252A2:EE_|CH3PR19MB8408:EE_ X-MS-Office365-Filtering-Correlation-Id: 992e47e7-78f3-4c09-0c89-08dc800949d8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|376005|1800799015|36860700004; X-Microsoft-Antispam-Message-Info: =?utf-8?q?3P9cuVbhdMYYUo7tD1MbRJOmwAIOA2N?= =?utf-8?q?C2M7jBYptqVjoDo/8N6k+95TjVSZZ/kK6OWJXrODiPWbZ5n3T4+BL6aCO1zNs2NrS?= =?utf-8?q?Kh6dYCMI+pPRmzqOsKs9xpsLFdcFVp0uPoF0Gem7TkPY63SENtiYn+8n8iUcEoPAK?= =?utf-8?q?WeSP0Xdq2K0zKL4td7syRLxLPMw1pH1k2kfdL5FFyBkF3a0oohqJ/diK0ke0P8uew?= =?utf-8?q?YKwI2VN6kZGVfnCInByxxfUA5+/jO37weCYzmkyJ+eZQ75JKLPAH35SYTB35mqnAd?= =?utf-8?q?q/t+mEGqa9h0VoZ9EZAuislTAct3VQfttuTOHBPdlQGXwJJlG/uJvbRyXzQtSbPwR?= =?utf-8?q?4JY4t/Du+dqhF01qG8UMCkesfSzskpjScynk2GPnl9ugiMgycuEIgLIcL4H2rF5D+?= =?utf-8?q?VH5mX1bNMTBbwC/649ZjQExwZsU+IP2GzQ0+fTb8AlU01+8hhl0MY+zullQiuQTMS?= =?utf-8?q?3gV9dWwdWqbXLg49nXzia4ljzhXIqc9bLJz80O8yT814KGd3qyf+IDs68L8I6zSxd?= =?utf-8?q?HhYRHcHovKtyMG1+5l08vdNXmqVVTpKbND7htie5uR1dEmp4u5pf0JjXdqr6r/Md6?= =?utf-8?q?uB6bfF+GZC7ApOygnoH2A2pBFKddrzXZNvFf6RZLeEStQvQJhUnpam36AcFRrO2SR?= =?utf-8?q?r5Pd3HUC32SWUi2kUVbr6TmE9YW1k+DlqdqJTYTOrQl4sbRKPe8xOUzIr0ERwfIet?= =?utf-8?q?UifviOUhM94LBkOQ084qF1afV/yagv4Za6dD24yc29odKqhVRCqsUJg3tr+MqW+/E?= =?utf-8?q?nSQBztBTgnUD/tZ7mbTtCS3tj4aa+KFTONAAOZYafjlunSzl8Eo9Kn55zEmYGxY6i?= =?utf-8?q?ZQln8E2zk1U/tJOqhm7HckZKvUcTsH/KG+GefK/Qa741isCABoZdv6q7+0j+6FW8y?= =?utf-8?q?JvI2pT5/rAMvYzU+q7lhghyup3fMmx3C4cwVHgNDkrLrhCEuKUPvZpfJQ2M9ZvyTS?= =?utf-8?q?ykOKG+FbsjBuH923rCJUpqJMze+mEg1GBAMdWtt/K5+ObI+UOrrRU6f78xrrUUEB1?= =?utf-8?q?U3YbGsyo0u5SrTzFzYFcQ5KneL3azc+bcbiLn6F3VusttecsCCRXcMfmvdlypkbdh?= =?utf-8?q?y4X96xgqWl1jAwDnxatKuuPzdhuxhi8J+X9TOBm+vlDGj0f9c5HNcBqxztcd00ayZ?= =?utf-8?q?R+7YA11YRWLnlYZQWt54KDH13nfdNFvxhytTTjyvjSqA+0lkMAmQSrxwW18Bm2Xxs?= =?utf-8?q?zKQrGiOLvvhP7m1QgpbdMK+JGP7LREdR+cbByusz+OR3qeb890GZvMisuO5v2Et+B?= =?utf-8?q?6CGk4yT/ept+sBPlQ/kxxZqSSg5hyz6VzfsebtWRUHp/9CQ0Kcm922J0lzOOjxE+s?= =?utf-8?q?W2BgWCvSpGiQ?= X-Forefront-Antispam-Report: CIP:50.222.100.11;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:uww-mrp-01.datadirectnet.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(82310400017)(376005)(1800799015)(36860700004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: LbQwQzfuSAD7NMDJn4H5TnjJWrGEx+QMwvSaAzShxa13Rp+0YXLpgdwxYTxytDUgzxuAx4WGuZyzRt6Ki6WrfTCjNb99cUJwUX6MpAD3vK7ED+P/BY8WHzMhIRYk89hMnhQSgaUKMD3c5X1dnedsr0oz/GO9cXOQLmnCQobO97ofMiPB2UkyoE7+4v6fODzth3DL+7jPYZy5/sZ5MQGlxrB7/0JYr323I1retzZy+VGkcTCutVtROJshM/xRGGOFRGUtcGCyhS8x2MhzbefMRlREb1vGIJckOjTYogW1a2KrYNv+TLh9SyRqUaiVQ70JQa0TERWBSro8YEDRSvborx4/pKaFs16jYJWAqqFXU5GxQpdXYFtYW6+upznC42jjB4qqpjv/qJQX8lZyTluqCVvShp/XHI1LWhmBIgGoOrsmBTTMxp0ejoKOkzOnh9TUQ8yWlI8zNHxujZLfOEnrevue0KFw7KJ43j8IV+Tv/VYticK5MCx33mZXQSDEEED5aJiCjVZ+cjG2tPXYbwSHSwUlUZasL2uuQ6vfjwaFQqXaUw07BQHdmAxa8N8L6XOeCxBKgT2bAwOXJwh+UV+wJjk4T/MuXF1B5cQTq64DhYYnMXYyM2tdjIk2yzPbtqOiXLPfFUqVP8z6GgEybbe18Q== X-OriginatorOrg: ddn.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 18:00:55.8130 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 992e47e7-78f3-4c09-0c89-08dc800949d8 X-MS-Exchange-CrossTenant-Id: 753b6e26-6fd3-43e6-8248-3f1735d59bb4 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=753b6e26-6fd3-43e6-8248-3f1735d59bb4;Ip=[50.222.100.11];Helo=[uww-mrp-01.datadirectnet.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF000252A2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR19MB8408 X-BESS-ID: 1717005661-104002-12629-48742-1 X-BESS-VER: 2019.1_20240429.2309 X-BESS-Apparent-Source-IP: 104.47.55.168 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVsamxuZAVgZQMDXVODExzcTE2N DUNDE11SLNJMnYNM3MIMnQ0MzMwixJqTYWANJkkRJBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.256584 [from cloudscan10-209.us-east-2a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 This is to have a numa aware vmalloc function for memory exposed to userspace. Fuse uring will allocate queue memory using this new function. Signed-off-by: Bernd Schubert cc: Andrew Morton cc: linux-mm@kvack.org Acked-by: Andrew Morton --- include/linux/vmalloc.h | 1 + mm/nommu.c | 6 ++++++ mm/vmalloc.c | 41 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 98ea90e90439..e7645702074e 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -141,6 +141,7 @@ static inline unsigned long vmalloc_nr_pages(void) { return 0; } extern void *vmalloc(unsigned long size) __alloc_size(1); extern void *vzalloc(unsigned long size) __alloc_size(1); extern void *vmalloc_user(unsigned long size) __alloc_size(1); +extern void *vmalloc_node_user(unsigned long size, int node) __alloc_size(1); extern void *vmalloc_node(unsigned long size, int node) __alloc_size(1); extern void *vzalloc_node(unsigned long size, int node) __alloc_size(1); extern void *vmalloc_32(unsigned long size) __alloc_size(1); diff --git a/mm/nommu.c b/mm/nommu.c index 5ec8f44e7ce9..207ddf639aa9 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -185,6 +185,12 @@ void *vmalloc_user(unsigned long size) } EXPORT_SYMBOL(vmalloc_user); +void *vmalloc_node_user(unsigned long size, int node) +{ + return __vmalloc_user_flags(size, GFP_KERNEL | __GFP_ZERO); +} +EXPORT_SYMBOL(vmalloc_node_user); + struct page *vmalloc_to_page(const void *addr) { return virt_to_page(addr); diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 68fa001648cc..0ac2f44b2b1f 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3958,6 +3958,25 @@ void *vzalloc(unsigned long size) } EXPORT_SYMBOL(vzalloc); +/** + * _vmalloc_node_user - allocate zeroed virtually contiguous memory for userspace + * on the given numa node + * @size: allocation size + * @node: numa node + * + * The resulting memory area is zeroed so it can be mapped to userspace + * without leaking data. + * + * Return: pointer to the allocated memory or %NULL on error + */ +static void *_vmalloc_node_user(unsigned long size, int node) +{ + return __vmalloc_node_range(size, SHMLBA, VMALLOC_START, VMALLOC_END, + GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL, + VM_USERMAP, node, + __builtin_return_address(0)); +} + /** * vmalloc_user - allocate zeroed virtually contiguous memory for userspace * @size: allocation size @@ -3969,13 +3988,27 @@ EXPORT_SYMBOL(vzalloc); */ void *vmalloc_user(unsigned long size) { - return __vmalloc_node_range(size, SHMLBA, VMALLOC_START, VMALLOC_END, - GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL, - VM_USERMAP, NUMA_NO_NODE, - __builtin_return_address(0)); + return _vmalloc_node_user(size, NUMA_NO_NODE); } EXPORT_SYMBOL(vmalloc_user); +/** + * vmalloc_user - allocate zeroed virtually contiguous memory for userspace on + * a numa node + * @size: allocation size + * @node: numa node + * + * The resulting memory area is zeroed so it can be mapped to userspace + * without leaking data. + * + * Return: pointer to the allocated memory or %NULL on error + */ +void *vmalloc_node_user(unsigned long size, int node) +{ + return _vmalloc_node_user(size, node); +} +EXPORT_SYMBOL(vmalloc_node_user); + /** * vmalloc_node - allocate memory on a specific node * @size: allocation size