Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.56.15 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796236036; b=gBkMVTpZuJ85siJkiULjaitvYovg1y2rhnzuP3TOurHWNT7dPcXY9Sm1t5W8okwz0F3e TyOR7e8MEz9xFCrXouHrm+dyMObuUy1VnqlWjuV/LcaAY5/IY1AJfCZVw16s2ub+0hka9 jGtJJbyhV9LKJLoeyZwAbKGoo3E9GDQBvpznJu1zU1uiiT6o339NPnbkUGeNjDyt8Sx9h TXIhEDVSy43KcYZgMVyYqO1ve9t+ojA8YRP4URI0pai0vh0XgO6NhO5n6oH6yRiqKo8w3 VrqZs3XAcqVMAw4J6JTOpj48cWGYKD3iZhQptsLhxBdCasLBUcIDA/W+xMrHzNbevbw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796236036; h=DMARC-Filter:DKIM-Signature:Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:Content-Transfer-Encoding:Content-Type: X-ClientProxiedBy:MIME-Version:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=Qdv74NHGCgYJqPSMJ3z9ixUJz2pQNDlVnin+i5w9ALY=; b=PM2mhIDgLF2DrXawenGUt2Zk1x7RSmFenzWDgXm2CsLFAo7budicpsPANbvN16zRwo/i dL545o7Dq9IdNAoEMM9TVykQSfa8usuPd10xHy+o5knWRmMl88ARKybhqlVy2O1AGaHPy /iahLNvWuCLhc2O/XGARWGtJobMdtW0NDQkLscjzd2HX6cnt7zCnAwSAsfWMYXT1uTD36 pDm3uvyLYSYjFoPWgcPlKuc6Rnz+xcFqlcQibDCMnGrL7C5GgAnIfl5jKjYouf43z+rjF b+9Zrg5ZtCPoumN699ogEOMK7uCThPje+QieQACjH2XhThZxtW1eFlwP8XMMZtRpkmw== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=VA5JWEfT; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.56.15 Received: from BN1PR04CU002.outbound.protection.outlook.com (mail-eastus2azon11010015.outbound.protection.outlook.com [52.101.56.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC2AF606A322; Wed, 2 Dec 2026 18:27:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BC2AF606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=VA5JWEfT ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d8vzM32rrQdeRbWil/5OwO8XZE2nsCStrJFikyBDfwD0wSI09PgHUf15AaWslg/Tv6l8kJOkLF5HCxFs3mn781SiAHkiXfPz/pEylMFuIDWF6IxEyPzg426gfs31QIgA1slR4AYF6nrqvdSIFJmsK4ZwchCtXJEkTL+Q28cexjN4uZbDKZGJHMXQ80VaEeQ9X9r8nNkICsKoBecNozvoHfR/TC6y55149Ghwwv5TxgumVExNmevJPwKJskq7YfpQZKVlCBjVrHzP1/LzHWzBdETT1KGFmFh0ufqyGHL5tYogB2pzwG1DZw4uG8v49W0faTLCEbjA8ygwthqjzKWERg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Qdv74NHGCgYJqPSMJ3z9ixUJz2pQNDlVnin+i5w9ALY=; b=D5qRDGWbLyNRRT35R1neJDphplq9Snss8OXqncT9X6nD+JmK6c2vx3U/+ayxDlzuuziGasVHCUQSIjhUCmPBUeAJKqTezldphUQa+E3W8BXIE2SsLOh1nKbX32PSyMA6jxldVBKEEXpIh0B3Udjwyn5XmVEAK81Gp9NDRQS7+5JUDqVADs0sVsxc2RJnGXUG1uopw4RyUAkE8OLFTz49xKr1QXUO10XPkTCWTuzqgGUU6Fe406GGCbcYQSNhibvecrGVzO6GcXWpLIEq5j5R8kIELQfxHeEDb15NyCAfiqt+UcDOH9J3CDoWJ1s1os5FrtJ9atlY7ilUBv5dKkKyxg== 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=Qdv74NHGCgYJqPSMJ3z9ixUJz2pQNDlVnin+i5w9ALY=; b=VA5JWEfT3q9cGRW2EYWh2pF47OSyNt53p4Z9q5onLNDbn/Sirig7T2/H+z+p++k+31vkUJ708Xgl7wI6D2d65e4zEbYbluUc+tsct7fs03qZqjr87EX/qIw/Cc0/A8y2CRL2iHo/HGYa1uTyCGzXsx693+M4Hi/38evkArYBkORLHityuuC4MdwsSesQAKbN04CCZ5Fvw2EFdnF0mu+z9LYSBp9aGn0l1SizVo81XhhWNov0zE6gVDk6a1hOnTNqXYiJbS1HGvbbNvzkJupG/Yq9jyBSHSH6ibAAyeG1YmfGVKBiRHsPkcF+q4xp2vZsq5GG3wgmJ3lqKi/DPc4UIw== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BL1PR12MB5174.namprd12.prod.outlook.com (2603:10b6:208:31c::19) by CH4PR12MB635819.namprd12.prod.outlook.com (2603:10b6:610:509::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Wed, 2 Dec 2026 18:27:07 +0000 Received: from BL1PR12MB5174.namprd12.prod.outlook.com ([fe80::58de:822b:868:96e9]) by BL1PR12MB5174.namprd12.prod.outlook.com ([fe80::58de:822b:868:96e9%6]) with mapi id 15.21.0662.012; Wed, 2 Dec 2026 18:27:07 +0000 From: Andrea Righi To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi Cc: Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , John Fastabend , Vishal Verma , Dave Jiang , Alison Schofield , Matthew Wilcox , Jan Kara , Tejun Heo , David Vernet , Changwoo Min , Josh Don , Vineeth Pillai , Peilin Ye , Zhi Wang , Lee Trager , Balbir Singh , Shameer Kolothum , Himadri Chhaya-Shailesh , NchangRoy , bpf@vger.kernel.org, sched-ext@lists.linux.dev, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 bpf-next 0/5] bpf: Import external pages into an arena Date: Wed, 2 Dec 2026 19:23:12 +0100 Message-ID: <20261202182648.2239421-1-arighi@nvidia.com> X-Mailer: git-send-email 2.56.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MIXP293CA0009.ITAP293.PROD.OUTLOOK.COM (2603:10a6:290:8c::7) To BL1PR12MB5174.namprd12.prod.outlook.com (2603:10b6:208:31c::19) X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL1PR12MB5174:EE_|CH4PR12MB635819:EE_ X-MS-Office365-Filtering-Correlation-Id: 448b83b7-46af-4989-3779-08df50a1def2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|366016|1800799024|7416014|376014|18002099003|10067099003|56012099006|261102130727099003|261028144727099003|261021135927099003|261102123227099003|261022075727099003|261021121427099003|261022105027099003|261021123027099003|261026121527099003|261026140227099003|261009223027099003|11063799006|6133799003|4133799003; X-Microsoft-Antispam-Message-Info: lNRUHnX+1MkiozFOR/uo64g0vFB3l2YDLogZ5dzKWnogh78S1RIVW8N7F/cmYmU30gtMlQmx55wBZsbgYPSSbVb6frOnf1mUv2/5Q9upZy6nbZgC55zOYC/1SnJKyt8aTn2Q0gbydkmlQrsE9GB4pxmfhAitsewsZy4LdM13U8K1Z7TbbkT3gD+TPqT4W8vOIBh3e0xDczyCCi2cnHclfRzJApIQVgPdRiLuHW41FWHE4kB2xyU5rGryGMjcjlpDCjFicoIzEkt822kWN+LPA84B3+ckiFs1fzk1s0wR8JAUU09Vz8ZE4IkgKwzE8//vImVtedyhXnIBJJ0qAXhPTtMcS8aFyUquq4JU4AM/P/rxBxBN9FN+SXG6SGcUXyDuWRdCZmcfE8OWsv9zZS+eIbmL4WwOSPycmL357xrsSySiSpdRjmVu4+D8j7Fos2nm4by7ZUk0G3toVF4Vdqx92P4VddkUSsd30lptjDu7D8Vz7aQCGzub3wVW5Czq+o2dds8NGw4kh+eoABJuUAAqxl6UoAejxzTfNiJN5P9ybJlAMxL2PHVyKvCLtTv299CZKv7gMBjzRDdns73trG8gAnXoIbqolBxkGaJ3Ocu3MQSBRw/VZub1Eem6IZBymqHaP9jSYX8AfezZsrkJ50RcYgvIBayftA2ZzQzxylar0+g= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL1PR12MB5174.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(366016)(1800799024)(7416014)(376014)(18002099003)(10067099003)(56012099006)(261102130727099003)(261028144727099003)(261021135927099003)(261102123227099003)(261022075727099003)(261021121427099003)(261022105027099003)(261021123027099003)(261026121527099003)(261026140227099003)(261009223027099003)(11063799006)(6133799003)(4133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?4Uv8NPjz5xNznpW7A+xzYc6rNY8J3nfKKP6Fa55BF9LaPOZ6R1qMBc+GMkCf?= =?us-ascii?Q?VVvpO1dVczuBKCUU/T2P76JeB9BD0s8cMuHH9QAlJBOSJSj0NMMclB+p+xpS?= =?us-ascii?Q?dAL78Zhp4M5Uj5K3VKbH698XhfT4XYZNc4dc8zVveFqKbjEz3m6zKE++MnRd?= =?us-ascii?Q?r5zg2rdITLkAW5PhEVtBmFqYkYHWlGnu0p2D8sweanpA93lbVJAo546HYxln?= =?us-ascii?Q?9zO9cLdjrqbm9Y23kSefGodK0e1SiVGhz59M/GB/iGmU3yGdK9TtLFnCc8Xh?= =?us-ascii?Q?9kRUUPP/DbOm6e2UV4CSnlv/5cGtkaD7ATVbD1TkzxUzC4Qvz56rzMZK0cI1?= =?us-ascii?Q?c4MtLfdmhVh+nVJJA8UohCTMdGJUAoRh5vz69MIdZDx4BAAvzcvtdBx5pwru?= =?us-ascii?Q?3tSlIPZ7REPRsfx3qku8+TsyqpyII2HkzYx9QJQ8jM4KUjD2nAF/y/GdsTje?= =?us-ascii?Q?HO0NzT4uZFGE/C2+mDKoRK8HHiT624C/arK8t/cKXbql6oGjPVLIVzmfMLqD?= =?us-ascii?Q?+KfV4Rqif9X9JWvBmx/cmxVHhIczkCfVj/is3Y5SFd0LLFbPgN5KUjMRdEt0?= =?us-ascii?Q?v2sDMZZQ1aO/yvYW1VBZbao1NFcRCLMCOr+QTx0haFVo/wvHFH1hJ80PdFEH?= =?us-ascii?Q?UNXIHbw59eCBaN8gYHUeeuvuRcZfCHqCNMdacc5QjDNeDfW9IV8M9WfQqsRo?= =?us-ascii?Q?h1Ob9u0n1tDeX2lQBGKdo8udRJ43UxDuI2/BvTRWqAKlaxvvVoqR/pDJPX0r?= =?us-ascii?Q?ZUBJVynYjWjGuLz1Z+GAVbHVVFl07GrWbVsa77IgudBpG4zwU3yVy1tw59oC?= =?us-ascii?Q?XyH7xDh7ZHAlfZSSzL29EqNcvaCaQoFepr48P+lqlPDencUFMQM1xyFityyX?= =?us-ascii?Q?tmpYVcyUiNm8jWyZkFk9Cw7UTzWzsH/dSTW01VOAKggfxk09tlr8iD49Zknh?= =?us-ascii?Q?CYVQI4PXnXLODhe7kW0+qVP2RsPKv6hO2rcLNfyAI3O998pXr+W7q8b7V9xf?= =?us-ascii?Q?DnfS5+nLuO0WJbxwiMjob0k/Rp/BzG3rIsPBX8XwnX2ghCZhOex8dFM/HeTy?= =?us-ascii?Q?gkYrzJKqZ44e/LpQp3Gx1LU33ZiT/PgFHtNPw2dJbnwLT0sxer/MrA/KcYax?= =?us-ascii?Q?CBLDsDJNxc1Ap9xgcnh4BqqwKKslGrAbELRAw5dwjasKD8qg3zAmG9BiQRYz?= =?us-ascii?Q?PqroMAmSPR3a80bxlyl260QPi/vxkXBYDK7EmituBVpwoypTDZv13QEegY+G?= =?us-ascii?Q?Ck7b/j3ZxJXWMP9odNcP1I2Lxj+NsfQfKuBMRIwk6sXUFKGtvlyYNSe2syJa?= =?us-ascii?Q?7o90LjLmiPRIP/iZZw6NXL3RYpKv8BP9izzK4Ntc9/4iLwJEmvhv1Z45DjPC?= =?us-ascii?Q?txzlucSOyoWrFIWVtfCebP25H1R7kodDx7dTxVMj6F+wdtH8rnYJmFz6aPnH?= =?us-ascii?Q?9e9Xlc35pIW5cfQvSIG3HudK7/oBvXW6MEuKV4AegPP0yw2aexgY9bIh/Pnp?= =?us-ascii?Q?Ohm/QY5s62hf5WLqBvP+AyzwWVhi0RZKwQDhfxgHoczqODuyp5h9KkIzmzNj?= =?us-ascii?Q?LTIc6HuERpsMb8AvypWzBrmCvcj9rVBHubNg/1bzVB8NbDpkvBkxVlwiFZdQ?= =?us-ascii?Q?iPvsrLDaCT4GcUk5OaF+GzcFcCRDD6VW0B2Sla2TrTSVDWQ935YkeIOj9yif?= =?us-ascii?Q?IXFDjwmYsdfqfD6mFFiIBOfWt+mVcnT+ojTXtScfuUgGxDw5?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 448b83b7-46af-4989-3779-08df50a1def2 X-MS-Exchange-CrossTenant-AuthSource: BL1PR12MB5174.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 18:27:07.2223 (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: 4Khauf0rZQjzmzTkNqzLPA9FYNnElBQRXq/JQAn+ys5Kn8RG/9GVjiwjxg/JCnAcR/bKO6SUSq0iWGN7I2xbuQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH4PR12MB635819 As discussed in the BPF track and the sched_ext microconference at Linux Plumbers 2026 [1][2], shared BPF arenas can provide a generic channel for bidirectional zero-copy communication between BPF programs running on a host and its guests, for example to exchange scheduling hints between host and guest sched_ext schedulers. This series teaches the arena to map pages that it didn't allocate, based on Alexei's prototype [3]. Background ========== An arena can only map pages it allocated itself, so its memory can be shared only with the BPF programs and the user space that map the arena. A host and a guest have no such mapping in common: they need an arena that maps memory supplied by something else, such as the VMM or a paravirt device. Design ====== The arena gains a single primitive, which maps pages supplied from outside at a free arena address. Each call creates one import, kept in an interval tree with its pages, which belong to their supplier, not to the arena: - bpf_arena_free_pages() over any of them releases the whole import: the pages are unmapped and given back to their supplier, and the range goes back to the arena, so the arena doesn't grow as guests come and go, - they are released when the arena is destroyed, - they are not counted in the arena memory usage, - the arena mapping raises SIGBUS on them (SIGSEGV with BPF_F_SEGV_ON_FAULT): user space accesses them through their supplier. There are three ways to supply the pages. Two are sleepable kfuncs for syscall programs, one for each side of a host/guest shared arena, which work with existing VMMs: int bpf_arena_import_memfd(void *map, void __arena *addr, u32 page_cnt, int fd, u64 off); Host side: pins the pages of a memfd, or of any file on tmpfs or hugetlbfs, with memfd_pin_folios() like udmabuf does. The host hands the same file to the VMM as a memory backend, with no change to the VMM. int bpf_arena_import_dax(void *map, void __arena *addr, u32 page_cnt, u64 src); Guest side: the VMM exposes the file as a virtio-pmem or NVDIMM device, which the guest turns into a device-dax device (/dev/daxX.Y). The kfunc pins the device-dax pages mapped at an address of the calling task, and holds a reference on their dev_pagemap until it releases them. It needs CONFIG_DAX=y. Both kfuncs act on the current task, its file descriptors or its address space, so they fail with -EPERM in async callbacks, which may run in another task. The third one is a kernel API, for suppliers that own the pages, such as a paravirt transport: int bpf_arena_map_ext_pages(struct bpf_map *map, u64 addr, struct page **pages, u32 page_cnt, void (*release)(struct page **pages, u32 page_cnt, void *priv), void *priv); int bpf_arena_unmap_ext_pages(struct bpf_map *map, u64 addr, void *priv); The arena calls release() once it no longer maps the pages, whatever the reason. bpf_arena_unmap_ext_pages() revokes them synchronously: when it returns, BPF programs can no longer access the pages and release() has run. release() is called under a mutex of the arena, so it must not take a lock that is held across bpf_arena_unmap_ext_pages(). The only user in this series is bpf_testmod: the API is meant for transports like pvsched, see the discussion on v2 [4][5]. Once one is available, bpf_arena_import_dax() may be deprecated in favor of it. Both sides then see the same pages as arena memory, at an offset known to both of them, so they can agree on a layout in-band, with plain BPF loads and stores, and keep pointers to it in the rest of their arena state. Use case: paravirt scheduling ============================= The git tree below has an additional [DEMO] commit, not meant for upstream, that provides a real, tested use case of this functionality: a pair of sched_ext schedulers, scx_pvhost on the host and scx_pvguest in every guest, which share a few pages per VM through their arenas. The host publishes which vCPUs it has preempted, its idle CPUs and every VM's fair share of the host CPUs; the guests publish their demand and the state of their vCPUs. With that, the guests stop queueing work behind preempted vCPUs and fold onto their share of the host CPUs only while that pays off. On an NVIDIA Vera host (arm64), with 8-vCPU VMs on QEMU or Firecracker, at 2x and 6x overcommit, compared to stock VMs, the paravirt pair is 2.2-3x as fast on hackbench, 1.3-1.9x on a kernel build and serves 1.6-2x the requests of schbench and nginx; tools/sched_ext/scx-pvsched.md in the [DEMO] commit describes the design, the results and how to run it. Known limitations ================= - Imports are released whole: freeing part of an import releases all of it. - Imported device-dax pages keep the device in use: unbinding it blocks until the arena releases them. Revoking them would need a notification from the dax core. - BPF programs have no machine check recovery: on a real NVDIMM, the supplier has to keep bad pages out of the arena. - There is no doorbell: the sched_ext use case polls the shared pages at scheduling events. - Confidential VMs would need the guest to keep the shared pages shared with the host, which the device-dax import doesn't handle. A paravirt transport can do that before it maps the pages with bpf_arena_map_ext_pages(). References ========== [1] https://lpc.events/event/20/contributions/2429/ [2] https://lpc.events/event/20/contributions/2482/ [3] https://lore.kernel.org/r/DM6HVNSP3USV.AJSWS289Z3I9@gmail.com/ [4] https://lore.kernel.org/r/CA+HDTgQ0mx0PgXDps2h2kd8TbJsFWOmJGJmDRGEHZgBZ_qSVwQ@mail.gmail.com/ [5] https://github.com/pvsched/linux Git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arighi/linux.git scx-pvsched Changes in v3: - Make the import kfuncs fail in async callbacks, with bpf_in_async_cb(): from a bpf_task_work callback, a program could import a memfd of another task (BPF CI bot) - Add bpf_arena_map_ext_pages() and bpf_arena_unmap_ext_pages(), to let kernel code import its own pages and revoke them synchronously, and release all the imports through a callback of their supplier (Vineeth Pillai) - Protect the device-dax import from a concurrent unbind with the dax SRCU and dax_alive(), instead of get_online_mems(), which could deadlock with mmap_lock; this requires CONFIG_DAX=y, the kfunc returns -EOPNOTSUPP otherwise (BPF CI bot) - Add a preliminary patch that declares inode_dax() in linux/dax.h, needed to call dax_alive() on the device of a device-dax mapping - Accept tagged addresses in bpf_arena_import_dax() (BPF CI bot) - Document that importing a range of a memfd with holes allocates their pages, and which memory cgroup is charged for them (BPF CI bot) - Link to v2: https://lore.kernel.org/r/20261117103028.4105609-1-arighi@nvidia.com/ Changes in v2: - Drop BPF_F_ARENA_NO_FREE, BPF_F_ARENA_EXPORT and the sized bpffs file, and map pages that the arena didn't allocate instead (Alexei Starovoitov) - Import the host's pages from a memfd with memfd_pin_folios(), the VMM uses the same file as a memory backend (Alexei Starovoitov) - Replace the guest NUMA node with a device-dax import, so the guest's pages never go back to its buddy allocator (Alexei Starovoitov, Josh Don) - Release an import with bpf_arena_free_pages(), instead of keeping the arena at its high watermark (Alexei Starovoitov, Josh Don) - Map the shared pages at an offset known to both sides, instead of discovering it out of band (Josh Don) - Track imports in an interval tree instead of a second range tree and a list, so that a release finds its import without allocating - Link to v1: https://lore.kernel.org/r/20261010224902.1232178-1-arighi@nvidia.com/ Andrea Righi (5): dax: Declare inode_dax() in linux/dax.h bpf: Allow importing memfd pages into an arena bpf: Let kernel code import pages into an arena bpf: Allow importing device-dax pages into an arena selftests/bpf: Test importing pages into an arena drivers/dax/dax-private.h | 1 - include/linux/bpf.h | 21 + include/linux/dax.h | 1 + kernel/bpf/arena.c | 607 +++++++++++++++++++++- tools/testing/selftests/bpf/prog_tests/arena_import.c | 553 ++++++++++++++++++++ tools/testing/selftests/bpf/progs/arena_import.c | 170 ++++++ tools/testing/selftests/bpf/test_kmods/bpf_testmod.c | 90 ++++ .../selftests/bpf/test_kmods/bpf_testmod_kfunc.h | 3 + 8 files changed, 1432 insertions(+), 14 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/arena_import.c create mode 100644 tools/testing/selftests/bpf/progs/arena_import.c