From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011034.outbound.protection.outlook.com [52.101.52.34]) (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 DB98E3A9605; Mon, 17 Aug 2026 20:20:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.34 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786998021; cv=fail; b=hjc4AFrMWNayGVNiiEBBE6wAf0IxGfwaJgdDb8jy+SmMj3L3bJ6dmwGtludPydQ33PTmxbCUAtMpw+o3zciQt4xZyCphf6CZDFaFH8Bb5B3xxzDNv+r5fdErmcs12MQcNBaPLEN3r5o8R5i9WgfA6KELRT96eHUGrM4NZlO5nEw= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786998021; c=relaxed/simple; bh=y2HorSCMpOmDLUSTrC2gYPbn7VkaJUUA//PLI9eiU8I=; h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=cLydq1fyEMbH0YInR9kOUjOD0pvIRaO4KBMFsz2Ky4Mg88p0ZGMjNFt9NSWCdg9eDyxAsHd1DJk91cBuwttlFOUZPR5uEC1VxAAecK4IqJvb2Ku6iOsX7TFS3brCR+l3CMfYqutw68oMiIJeAyQremS4lAlaeWoiDFBaWFgVg3s= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=rEnCCKz9; arc=fail smtp.client-ip=52.101.52.34 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) header.d=Nvidia.com header.i=@Nvidia.com header.b="rEnCCKz9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZgDn7Z7OQU64mx0dxZWOfz6JayuMhjM2u7pXcR5ndxCMqaKblgg9m4AU8ZRoV14e3b4QRbGTlw1oNyhEAOinshYn7gb9wXoMu7Hpq1A3xQIvv/L/cCEKrpGTTF/u8BISDrfY0kKLsthHJfnRxls7ThH4vN2tu9TnlQSHM4XNCtgNt36kF62VJ1TFhLWhel+PACNXFTv84fVFtntGQRwVF4n61a27VELeW7bJX9ToAuKtCYrrzcr0ov8LyZ7vY0ozN+FZjxiIo7TZ46jl4ZjHxYAn5cP93okXb+MfKBBm/ZdkX/TjkAKKZGHlmdFUdjq5EuhBeBDqgYb8xZwXChMZ9Q== 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=zdFnVOAoH1aU1raZRPAIbs1Z0NHTrGAzUSBK4NaZcSk=; b=PwGBxnQh7O7y15nBCljIEkjjZW/D3l6bN4vNAByxmQZrjTlTYXKCsOx0Ca+/7H6EqtVbnAHalP6fEyPQvOBRpVMBN60CM9C0iiWHvQ39OHsWsi264fiTbfXv2rD4t8sqqGf0/al/03Y4DBV5qZcfhUbxVpTA+3mBQ1fNFu3nWvvPE3k42QQhNAYNTyJfxFlwD3VN929Y25xc036u6CoycMQ4U/CujI3xDGlnCHqKEJBrGPME25IhnwltBQmiHJbomUljQGVbFyDnO6kBDX3Fkm2RLjdGpeRltBEytMv0vYQha+44ZWfXKrZdf/UekQdsjq5XoskdBed9ya+hCELRZw== 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=zdFnVOAoH1aU1raZRPAIbs1Z0NHTrGAzUSBK4NaZcSk=; b=rEnCCKz95Zx8TKKfPe2tN2llmzGTUDv0X+eGusbEiE1EK2usxRQ/Bm4AX6KO3AkT6rSkf5ZeELUQwZ6d8VziJ6WGgqNbOJbTN7uj6kdjgD+pAlMTRYH1fdCvy2Lwp7ZEbfwsI8M0bN7wyLTYndQhGAvINSlPV/MYpIwzBv+Fcr5jaxzm7O3ysFRO9Ikkyp9MmeUYQxcRw7HSvARC40GHTlLjxAK3MTMrrTxiuzmHBpPRUQo3FcSAv/W0cx2lfYMdGAIuXaIMocnAKmy+wK8TFp7xc3FJkYmDrC+6UrTog4/yyUTgBV7748F8/1RVOsDW1dhKjr5Rxcd4AtpTWEfU1Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV3PR12MB9356.namprd12.prod.outlook.com (2603:10b6:408:20c::21) by DS7PR12MB8083.namprd12.prod.outlook.com (2603:10b6:8:e4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.315.17; Mon, 17 Aug 2026 20:20:13 +0000 Received: from LV3PR12MB9356.namprd12.prod.outlook.com ([fe80::1c36:31b4:c420:6286]) by LV3PR12MB9356.namprd12.prod.outlook.com ([fe80::1c36:31b4:c420:6286%5]) with mapi id 15.21.0315.016; Mon, 17 Aug 2026 20:20:12 +0000 Date: Mon, 17 Aug 2026 16:20:10 -0400 From: Yury Norov To: Eliot Courtney Cc: Danilo Krummrich , Alice Ryhl , Burak Emir , Yury Norov , Miguel Ojeda , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Trevor Gross , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , Onur =?iso-8859-1?Q?=D6zkan?= , David Airlie , Simona Vetter , Greg Kroah-Hartman , John Hubbard , Alistair Popple , Timur Tabi , Zhi Wang , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org, dri-devel Subject: Re: [PATCH v5 5/5] gpu: nova-core: add ChannelIdPool Message-ID: References: Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: BN9PR03CA0066.namprd03.prod.outlook.com (2603:10b6:408:fc::11) To LV3PR12MB9356.namprd12.prod.outlook.com (2603:10b6:408:20c::21) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV3PR12MB9356:EE_|DS7PR12MB8083:EE_ X-MS-Office365-Filtering-Correlation-Id: f80b7eda-c57a-4da8-b3cb-08defc9cf0e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|1800799024|23010399003|18002099003|22082099003|56012099006|3023799007|11063799006|4143699003|10067099003; X-Microsoft-Antispam-Message-Info: p8WzfAoyduPFtWxK5YiRmTi2Ocy/pPOuE0NsQer7QovwGZCDR0VeCsTJxhqjmzkYbxwAFmQp32PaxUEN86I8c+IjrxXrmtAOSxGL9F8cPxjub5dsmkA58WSaBmfxQLMFONiu0qLFQgrWoqKDBUpJjDL20CnIZaWL0qfF6V1WPjGG22Lcua22RdG6imCfj+6JmVzpyb+8YLlg9yb2uHeashyBawI/UsCFZ/02/DA+nJ9d1A/S0GD74NToWI5vcgQ+G5ZBTEVtcFl32aP4JWeya5BV9IqA5rvAF2pmo2X0kFTxbn087ub+DjkbJ9j+zt9PmXueyh9uN63QEyTbiqbB8lQxvbplCV4I+VadBQAEC5xDesc2YAtduk3kQmmpmuBwIItiSgxqeuIgnU7HbBWtTrgyiaUdXC1NeTVBeTTmLZIdPFR3fqBUNqEL/BoR5/cao56VWIR5xB2SQrNEZR4o3FP9ND6okB2O6sQuP1hHJbu/Eog2kpW5QtIVMqxFlMQstgGFleIHR25ujJ8o02LImLwoVuAwSlv7pZnr/fEE8REXngRaAKFYq1G7JO2NvJqtBu6TppW0IfSiCkLxUtzYuI+T6v+Rq4mPa5eg/8rUEakr7wetEGOm+5dtKty/IkAeSEp3C7E6Q3m2DvSkgIRRQ+vOlHo7Bn50gV6wpk8V7Ns= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV3PR12MB9356.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(366016)(1800799024)(23010399003)(18002099003)(22082099003)(56012099006)(3023799007)(11063799006)(4143699003)(10067099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?G4KsvVkv5NTifSkzyHDOdWvyoFHtIbKMwq9cdWQIklSkcfOGcqz7lT0KE/SP?= =?us-ascii?Q?i6kWYi+N7cfNH4PktbK+dwjsZHqUv8W/4nkkiLGOeP4It7yhv3pBa4rXBG3A?= =?us-ascii?Q?YR7ShlAw5senvaxzbcrV5DVndiw8dAHLV04K0asOfnPK7it2OU82bT37XWqx?= =?us-ascii?Q?8yqNYLhwWOWkxHZUxcIqk5IhjdCkri9/Mlq7mZdGE5AbCJyIKOY7UboKFjvq?= =?us-ascii?Q?7CYL6Cmcz0uQU3SMFGP/Xe4PtIfORQBOznm0+Pu6vR2axmO+ABHk2qfl3BNM?= =?us-ascii?Q?rB7X7mzVV1PHydEgv5smIjV0ldW/cZ9Z8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ii?Q?HKdbastbfFLexCKUejG3RLzdY3trArqFLcdeQkOYDu5+o52pZIndxOAi4NXH?= =?us-ascii?Q?CQDjxE05RfmVT98AFY+uZyTcOWhYwIR+lIudCsNFgzMocp2hITEM9Imos79X?= =?us-ascii?Q?DD7ZeIts0H/FpOl80jjBKe30p3h2lWgay/+Q/DCd2xiW0alnbbzC52SS/haE?= =?us-ascii?Q?JrzranM7PA52uURpuleN60R9IY9sEKpH7U8MCpkH6y4H0pcH1eSwmBfIVWQV?= =?us-ascii?Q?MeaW2AL7+lr+YqaF2y0vjO3K2m0zwDItect2lWmYDSvbAmdPgun19wy1bmCn?= =?us-ascii?Q?TYRmUH8koZxg4+dzvp+sE8tT11pAG0pKPVuCM/WlUrqOVTocK8UxX9JbtZTw?= =?us-ascii?Q?XteaZbtCkzEWKetgQiFRYgJo2xSusGiossfpA89dbqi5QcVguGwz4VLW+juT?= =?us-ascii?Q?4vKqSuMLNLh6Jvck9YT9OHzBQgdvtpbSOJTfaJcaboq3pLhFJ6qG3lYHcTVp?= =?us-ascii?Q?sNHPIvhb7nGOzEgg7NqKFdwRgkjJAgat2e8xzYVIZ1f7RYHB?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f80b7eda-c57a-4da8-b3cb-08defc9cf0e0 X-MS-Exchange-CrossTenant-AuthSource: LV3PR12MB9356.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2026 20:20:12.2473 (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: JRrnMQ4zt/Erw8RfQPCMXolRrC+UoyyEgonfnzAe4zK6i6GCzZuP+hxLw4fOzgmBlb3zEpNqwcttfQSHG+ES0Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB8083 On Mon, Aug 17, 2026 at 04:03:51PM +0900, Eliot Courtney wrote: > On Fri Aug 14, 2026 at 11:53 PM JST, Yury Norov wrote: > > On Fri, Aug 14, 2026 at 05:08:43AM -0400, Yury Norov wrote: > >> On Fri, Aug 14, 2026 at 01:54:24PM +0900, Eliot Courtney wrote: > >> > > 1. Provide a nz! macro to create constant non-zero things. Provide some > >> > > constants for common alignments > >> > > > >> > > Potentially, we could use build_assert! for cases it is provably > >> > > non-zero but not a literal (although tbh not sure this is a good idea - > >> > > at least not do this initially). > >> > > > >> > > So either: nz!: const { NonZero::new(value).unwrap() }, or, nz!: some > >> > > build assert gated construction of NonZero. A general nz! macro could > >> > > also help ergonomics for other use cases too. > >> > > > >> > > That looks like this: > >> > > > >> > > pool.alloc_area(nz!(8), Alignment::AL_8)?; > >> > > >> > Actually found that if we implement SizeConstants for Alignment then we > >> > can get Alignment::SZ_4K etc almost for free. > >> > >> Then maybe pass SZ_4K directly, and allow the alloc_area() to > >> calculate the alignment: > >> > >> pool.alloc_area(nz!(8), SZ_4K)?; > > > > Even worse, you can advertise the function like: allocate a contiguous > > set of channel IDs enough to represent XXX bytes of memory with YYY > > alignment. And that way, you'll be able to do: > > > > pool.alloc_area(SZ_8K, SZ_4K)?; > > > > If my understanding of the function is right, it would be a clear > > improvement, because the user now doesn't think about ID channels pool > > as a set of bits, but an abstraction over the memory access technique, > > which it really is. > > If we pass SZ_4K directly, we are back to using plain integers, which is > not what we should be doing for rust interfaces according to Miguel. Let > me send a new version of this with my Alignment constants + nz! macro > idea, IMO it helps with the verbosity. I meant that if you have 8-bit alignment and granularity, you can create your own enum and pass it as parameter. But it's valid for pre-blackwell channel allocations only, so not applicable in general. > I don't quite understand your point about memory access. Neither me. Scratch that. It was a hallucination, maybe somehow related to the 1st day of flu. :) > The purpose > here is just to be an allocator of IDs, not memory - it's just that we > have some contiguousness and alignment requirements of the IDs > themselves. The values we're passing in just represent numbers of > channels and constraints on those. I think that callers will naturally > want to allocate a particular number of channels, not a specific amount > of memory that corresponds to some number of channels in some way (e.g. > USERD?). On pre-Blackwell, OpenRM makes channel ID area reservations for > vGPU power of two number of channels and and places them so the base > channel ID is aligned to the number of channels. Sorry if I have > misunderstood your point. Maybe we should rename `alloc_area` to > `reserve_ids` or something like that if it would make it clearer? Yes, reserve_ids() sounds better because the parent structure is named ChannelIdPool.