From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from BN1PR04CU002.outbound.protection.outlook.com (mail-eastus2azon11010053.outbound.protection.outlook.com [52.101.56.53]) (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 D98E3258ED5; Mon, 1 Dec 2025 22:18:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.56.53 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764627499; cv=fail; b=n57TWUitXrB7QcM6wSA3ci0/mH2Vx4qegc1CP8yXVCovY5X+6jCh76F+wwdcs1OPy2g4tzRXmZyJaxNc8gtW6PSiX6FGOMsEC6VyIsZFB0uq6Hy21a9bZNlAcEKRR20jr+c16EA8dtbNmyNEX9lhfqZ3arP0othCuxwOUal03do= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764627499; c=relaxed/simple; bh=PcD067aG2TaWagbZxwm08tA0arUYtaTpfU0aohhZh3o=; h=Message-ID:Date:Subject:To:Cc:References:From:In-Reply-To: Content-Type:MIME-Version; b=XbNCrOzvvEbNAHqfmbRENSMNSaFIleMJBGyecZz4eqwReLaZMwsex4gGTifTdJ9XxJer2ZUHhn+Gf57Ymn5/uI79aLXz3KB7pGnkEohGwsj6V2tFSOd8ZPCX1O4njZPvR2FoHZSebrETj9/di3l5Ks1E1BuKc9qK32pJOw38xn0= 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=N5Qez3dj; arc=fail smtp.client-ip=52.101.56.53 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="N5Qez3dj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ln9ZsY4Mhdt2ATvtPIaYXuZCC5iHoanV/+MPOVp4a7sDDFi66wg0TnQB/hLtsso9jq/k8s0fSHIWJ2o44tJRUerk3XrneWLMKmTjCkoe6uIcEZiIkGo2G0a/wzuf5tdy8mHbrfIJS0bgQQb+SZDYJ/qltXBCaNSV9oisgY23vph+xMXkdxpm8jYyPBRsidOrwCrDfDXGMygRsBNJ3g7NdMyMTv2B3IZj1cCVsPPyjuLSO1dqFCpWjXiZmlGEuCZIXUJ0E3ZYhlELqQzhNPMDo3mPVlXo7z5M+0Zeg3e8JYDfbrcJFeC/Ryiqq5/j1AtXN2fAW9b/5OqztMWgOTkVmQ== 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=Std4ocSXHZey70lhGGnLhAalQkQkjT8zQdAmK455xHs=; b=wnRz1kETDqcgZ/91SnoXtHQiNLcRWkhYBCTUgNJ+CCRFIPyHBaDByWDXTeWBXSoZoMLHT2Y3Htmz7qR8fDLojk24ojic7VDo6ko11WyG6HyAUKM753PKb5Zg/GMra00tLllIMtAsH3pWXim0850uEgmTD76PcvalG7psq5K9sDuViUh1mSNECD8mdjq7IR8YBJQWaX5AuJMs6FCgPPQsk12RQitkte1ZaIOnJ3PZrwbjUQJ4598ztG36zEgF3IUsLGJ78R/4n6TsfDdh1LanuFhOFvK26OUe/wT1Y1yR6jg2gQ8/f98sO+1HEe18HleqQXn3rDEnIELMucwyqW6dxQ== 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=Std4ocSXHZey70lhGGnLhAalQkQkjT8zQdAmK455xHs=; b=N5Qez3dj0rVOu2sV2lWWi/+izeGAzzs/obyfJQAl4ZQieEb6gykL36RNq4tneF+XNZWLFipgabDW2cpNjNJOcBhy5uRIg1yoSnQcaf+WM03wZUN68UuIGUkULlCHR//eDFIfLfu4TbE++p7UFv8Q0Pdu0T8NTn0B9P1tpx4spQk4Ga4zUkOJodx2LtEJqRbRzG1A9U4JLsLAJDSjPSLJOQAWuJF4skLY1wG1xHkbqly0zgS+34qbxnnbc20x2tMGvG2V4oh8OjtWhQGhud1BBGzrGTeGdYKD/cBuyJKrTZXkkbU1Ljo1NXd2lUfINYZqzc2/F6C2Mx+6J4lNTcOryA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) by IA0PPFFEC453979.namprd12.prod.outlook.com (2603:10b6:20f:fc04::beb) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9366.17; Mon, 1 Dec 2025 22:18:13 +0000 Received: from DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8]) by DM3PR12MB9416.namprd12.prod.outlook.com ([fe80::8cdd:504c:7d2a:59c8%7]) with mapi id 15.20.9366.012; Mon, 1 Dec 2025 22:18:13 +0000 Message-ID: <497c91a2-ca6c-4e05-bc5e-7c3818302c7e@nvidia.com> Date: Mon, 1 Dec 2025 14:17:17 -0800 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] rust: clist: Add support to interface with C linked lists To: Joel Fernandes , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, Danilo Krummrich , Dave Airlie Cc: Alexandre Courbot , Alistair Popple , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , bjorn3_gh@protonmail.com, Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Timur Tabi , Joel Fernandes , Lyude Paul , Daniel Almeida , Andrea Righi , Philipp Stanner References: <20251129213056.4021375-1-joelagnelf@nvidia.com> <2653abf6-5cd4-4385-b7c2-f377a9503160@nvidia.com> <7a88da9f-c67b-4a68-b8d6-a66f9096bab4@nvidia.com> Content-Language: en-US From: John Hubbard In-Reply-To: <7a88da9f-c67b-4a68-b8d6-a66f9096bab4@nvidia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: BY5PR17CA0007.namprd17.prod.outlook.com (2603:10b6:a03:1b8::20) To DM3PR12MB9416.namprd12.prod.outlook.com (2603:10b6:0:4b::8) Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3PR12MB9416:EE_|IA0PPFFEC453979:EE_ X-MS-Office365-Filtering-Correlation-Id: 72b6ee88-8a19-4a39-f92e-08de31278462 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: =?utf-8?B?bXVzeDYrTmZmQkVZQUJmTGk2SlRjMndwK053MTgvM3QxM0dmS0NHWHVPbUFw?= =?utf-8?B?MmJQQ3dndXhrYUFCTldCWVpSNnRwQXN3MUplS1FjMnJsc2hlNUt0YVZEYlg3?= =?utf-8?B?MlBHKzByRlBKcEVPc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DRyNlBScWx5eFpFTCsw?= =?utf-8?Q?cXB1Y0/qrp0jAWP3wiinGHPxgXAiwTOl?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM3PR12MB9416.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?c0ZrUlRmWjRpTmRWaVAxVTdML2p1YnNnODl6RUZEZHlXUSs5M1NDUnI4RXg2?= =?utf-8?B?T2QwdnVicFY2OGRzYnRrYWRzY1hlWTVEUU52ekg4SVFjMjYwWGJiekNXRCs4?= =?utf-8?B?SlFWcEVacDIyZXhZWmw0Ulh6ZGYzcGhsNHZaSmxyd29xVXdrc240bW1Namc1?= =?utf-8?B?aVZKSnp3YlErMHgzd2FlQVI1QjZWcDBrbkxuUGovd0VyN1N4a2M1SThZQUs5?= =?utf-8?B?dFNyejl0aEN1NjNJcStYbnNabGVYUUtwYUFudVR5RmZJOVJxYUJwMi96b3Bn?= =?utf-8?B?K2dzeW1OalpralhzZHlVMEpGMUQrUnVuaE9JRWdKK250Y1BWQlRNL1ZSeVRL?= =?utf-8?B?Nll0TEhkbW9EaDMyTnJOT1ZUTmpXRTVEaW9nT3BCWEs5Zk1RWUYrV0VJSUZ5?= =?utf-8?B?ZjNQOW9XaVh2dmNOQ1JKSDlDU1NYQlc3K2VwQzRZeFc2THFWLzJKWVZzMjdL?= =?utf-8?B?cDBUVlRaaTVNTlk5S3ZWRE5LUDllYnFhbFVFNnlzVXh6VTNMZnRLL1d3eWZy?= =?utf-8?B?TjdPaVJiV1lBajg0NDlWUmtDVzVtWWhoU2pJUW9GaEM2UXdKYU5vZUxYY0dV?= =?utf-8?B?elpQQ09JMjlQdWQ2dUx3U3ZvaDIrZVorN21zZ2cwRFI1WUlpK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ENjS3RIRjdW?= =?utf-8?B?YnNQRmQvM1Q5QzFSelZCa1NERWt1SWNvM1FQd0Ivc1pSa3JIaVdWTnRjK3pV?= =?utf-8?B?NjZPV2liZWV5dGhqWnBhZFNabHlKTU9aREoyNStEZkg5TnJJTWpqTUNQRGxD?= =?utf-8?B?b21IcmlHS08wNjlRdk9qYUl2MlBQejg5c2FaSXJma09sSXVBNHNab1RtOGtr?= =?utf-8?B?OWEwWVNHdDdXTHR6UklsYXR3WVdvY1RXQm9kN0pTRjZGbnFoaVowNXNML20v?= =?utf-8?B?N2VKYWpVWmRDcGJGbFlweDRDcytGUlQrTjg1T2NXSndlNzNNWEpvanhMRk4r?= =?utf-8?B?bXVZQWRNU1c4RTFoV0hvYnNJdmd5b2owUm9rUC9FMmpseDRnNXJjUTFzcnVV?= =?utf-8?B?K0IwemkrSEYrNStkNUY1aytoL3gxTDZmQUR5TVhxYkFVUkFVQkdHNXVHejZM?= =?utf-8?B?ck9sSFprOVVjMjRaRjdqaXRuT0FHa1R2REptS2dvY0JFNXVJRlIzajl4cWVO?= =?utf-8?B?YUluY09JSTJLTTBiRlh0UkdOMC9Lb3lXaEpZSXh1MDdxTHdlb2UvSkUxa0di?= =?utf-8?Q?KRTbh5ujC2FobF1SfAoBAIYul?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72b6ee88-8a19-4a39-f92e-08de31278462 X-MS-Exchange-CrossTenant-AuthSource: DM3PR12MB9416.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2025 22:18:12.9787 (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: BS041oAn6/d9bmE8BX2WNLzZ6IDlHLJJUCu8N+fEu2rqqwHFzqQRLbV7WsNsQN8/Nn9uNE5abMQenwhnkdW6fw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PPFFEC453979 On 12/1/25 12:32 PM, Joel Fernandes wrote: > On 11/30/2025 7:34 PM, John Hubbard wrote: >> On 11/29/25 1:30 PM, Joel Fernandes wrote: ... >> This is sufficiently tricky that I think it needs some code to exercise it. >> >> Lately I'm not sure what to recommend, there are several choices, each with >> trade-offs: kunit, samples/rust, or even new DRM Rust code. Maybe the last >> one is especially nice, because it doesn't really have many downsides. >> >> Rather than wait for any of that, I wrote a quick samples/rust/rust_clist.rs >> and used it to sanity check my review findings, which are below. > > In v1, I had a samples/rust/ patch, but everyone's opinion almost unanimously > was this does not belong in a sample, but rather in doctests. What in the sample > is not supported by the current doctest? If something is missing, I think I can > add it in. Plus yes, DRM_BUDDY is going to be a consumer shortly. Well, I won't contest the choice of doctests, since wiser heads than mine have already worked through the tradeoffs. But for API developers, the problem with doctests is that no one has ever actually *run* the code. It's just a build test. And so critical bugs, such as the kernel crash/hang below, are missed. I would humbly suggest that you build and *run* your own samples code, for new code that has no users yet. Because if you are skipping steps like this (posting the code before there is an actual caller), then the documentation of how to use it is not "just documentation" anymore--it really needs to run correctly. And actually, after writing the above...I still think it would be better to post this with its first caller (DRM_BUDDY, or BUDDY_DRM_ALUMNI, or however it ends up), so that we can see how it looks and behaves in practice. What's the rush? ... >> The fix requires two-step initialization, like this, for example: > > It has nothing to do with 2-step initialization. The issue is only related to > the HEAD (and not the items) right? The issue is `assume_init()` should not be > used on self-referential structures, the fix just one line: > > -//! # unsafe { init_list_head(head.as_mut_ptr()) }; > -//! # let mut head = unsafe { head.assume_init() }; > > +//! # let head = head.as_mut_ptr(); > +//! # unsafe { init_list_head(head) }; > > Does that fix the issue in your private sample test too? > > Or did I miss what you're suggesting? > Yes, you are correct: the main point is to avoid moving a struct that contains self-referential fields. So your version is a more accurate and better fix. ... >>> +pub struct Clist<'a, T> { >>> + head: &'a ClistHead, >>> + offset: usize, >>> + _phantom: PhantomData<&'a T>, >>> +} >> >> This discards build-time (const generic) information, and demotes it to >> runtime (.offset), without any real benefit. I believe it's better to keep >> it as a const generic, like this: >> >> pub struct Clist<'a, T, const OFFSET: usize> { >> head: &'a ClistHead, >> _phantom: PhantomData<&'a T>, >> } >> >>> + >>> +impl<'a, T> Clist<'a, T> { >> >> And here, the above becomes: >> >> impl<'a, T, const OFFSET: usize> Clist<'a, T, OFFSET> { >> >> ...etc. > > It is not ignored, the const-generic part only applies to the constructor method > in my patch. I didn't want to add another argument to the diamond brackets, the > type name looks really ugly then. > The macro hides it, though. Users never have to write the full type. Increasing const-ness is worth something. The messy syntax is unfortunate, but I don't really know what to say there. > The only advantage I think of doing this (inspite of the obvious aesthetic > disadvantage) is that a mutable `Clist` cannot have its offset modified. Let me > see if I can get Alice's suggestion to make it a const in the struct work to > solve that. Yes. I have it working locally, so I'm confident that you will prevail. :) thanks, -- John Hubbard