From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F05D21D3E4 for ; Thu, 7 May 2026 07:18:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778138329; cv=none; b=A9Uj4r7Hl87p1cy+TMffxXvKCdvuDHwInaPmoTfgm679WPXTN4D1Tr/lPHsMYSI2L2k2n2ld3T/1f4cH/mlm7DR2Y0yqyRFDoVFExQwTTP5VD0MDdFxSPPwewm39hv4MkifAJFvfm2PmhNgNVfAMUW3zkzYvRjQePG3kEyJdrCc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778138329; c=relaxed/simple; bh=1ArEdGwJd4akLgQ+SZ6Un1i7sYoRraUekLjZXcwXaWE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=UjWYA89fDsmXr4DZqm4KqPMfc+Hsug/UErU+aX//ZEHjQEkaCvwO0ukBRj4mh28y5PYZT88wH0nnWrpVMC7mN7t2OYSmtQKHpCfmJZmOq7fBHm/qfoAD2tEZxWl7CxNhtf3tmqUWLgA2mRplA8x3wblYUV75daPrnN65NPrlF4I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=jc36E/pG; arc=none smtp.client-ip=209.85.221.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="jc36E/pG" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-44b2b38648eso381271f8f.3 for ; Thu, 07 May 2026 00:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778138327; x=1778743127; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=STH36cS/F87DhIyaZ+8OVzfArrGCDV+Ojd5JS20sYwA=; b=jc36E/pGmC39UkJUJNndAyekhU6asksxweNoIOt6W9GwjHdiKUZKVEODySSxDoRSXj EemefrI5O/A+X42a78LLcrFbrXCO7sUOubUlk+dKts2hPN/sfL0/gT+VF6ACn3lyvn2E YrNbAnNyYgzjmGx47LGPazloL7S36M0a9Qe8Q/Bo5PAs0PIvwppFUDXOBWA4YNLamr2h lDs5DJtYBau7z6hGXwub8UR/VJBa0KwR2s6zWSmOlGN1ZsyAFlPJa/yAmx8M1mV2cBM0 CN1hizGVuKBLQ0c6j4x9AMFP/iCKMCxdflWCNHhYNLFZ55EE0qT7JVMDmu2u/zsQ/+8G LpxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778138327; x=1778743127; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=STH36cS/F87DhIyaZ+8OVzfArrGCDV+Ojd5JS20sYwA=; b=S6UU7d3X926/Fo3Ek8EoJe1Q0RJ0/u2EIqTIOkfPpasIosaQes7DTMhsg7sPdXZzfr GL72fBeP8cyqfyONA+R0BJtolAPn6GKD4EKesYF7Y84XtphigOzGONQeuE3W7yQrJ9WL A2+K9Ag6z0aK51dZc+KgYfLquDVNlC1arYo1fXTofHdSBa9+wpMUIhCaOj1rCpCGAte9 EoQWl00sW8X+4jBUuNZ1jYx/rJ2UiIcDeqWbEksT0+fWv1rM2lv8MIgJMt/4b9EWoD55 Qn4TIMqkflLHDRmGDZl9yK6Vl4G+R4vBkPPFbm1A9ZGLoL6SeJQnbvr4UgIXMNXhN617 PKTg== X-Gm-Message-State: AOJu0YyZarjJV8Jf6KITIJgLKQQ7DfLfXcJIJSActEHprRv7CpONE89c U9dize1VaNSBnrpXVg6T28/sUIoUHFJUZDO2SobfdJPFbU/hyALOFkcNIA/rxZ8wlCRJ+8R6cHK MmSFcmN0bTuFyOinbug== X-Received: from wrqr6.prod.google.com ([2002:a5d:4986:0:b0:43c:f906:ae85]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:4381:b0:441:247a:e98e with SMTP id ffacd0b85a97d-4515ce1c738mr11025046f8f.24.1778138326535; Thu, 07 May 2026 00:18:46 -0700 (PDT) Date: Thu, 7 May 2026 07:18:45 +0000 In-Reply-To: <20260506135122.GA1432412@joelbox2> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260506135122.GA1432412@joelbox2> Message-ID: Subject: Re: [PATCH v2] rust: maple_tree: implement Send and Sync for MapleTree From: Alice Ryhl To: Joel Fernandes Cc: linux-kernel@vger.kernel.org, Miguel Ojeda , Boqun Feng , Gary Guo , Bjorn Roy Baron , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich , Dave Airlie , Daniel Almeida , dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org, nova-gpu@lists.linux.dev, Nikola Djukic , David Airlie , Boqun Feng , John Hubbard , Alistair Popple , Timur Tabi , Edwin Peer , Alexandre Courbot , Andrea Righi , Andy Ritger , Zhi Wang , Balbir Singh , Philipp Stanner , alexeyi@nvidia.com, Eliot Courtney , joel@joelfernandes.org, linux-doc@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Wed, May 06, 2026 at 09:51:22AM -0400, Joel Fernandes wrote: > The C maple_tree struct contains a *mut c_void, which prevents Rust from > auto-deriving Send/Sync. Following is an example error message when using > MapleTree in nova-core's Vmm. > > This propagates up through MapleTreeAlloc to Vmm, BarUser, Gpu, and NovaCore, > causing NovaCore to fail the Send bound required by pci::Driver: > > error[E0277]: `*mut c_void` cannot be sent between threads safely > --> drivers/gpu/nova-core/driver.rs:77:22 > | > 77 | impl pci::Driver for NovaCore { > | ^^^^^^^^ `*mut c_void` cannot be sent between threads safely > | > = help: within `MapleTreeAlloc<()>`, the trait `Send` is not implemented for `*mut c_void` > note: required because it appears within the type `kernel::bindings::maple_tree` > note: required because it appears within the type `Opaque` > note: required because it appears within the type `MapleTree<()>` > note: required because it appears within the type `MapleTreeAlloc<()>` > = note: required for `Box, Kmalloc>` to implement `Send` > note: required because it appears within the type `core::pin::Pin, Kmalloc>>` > note: required because it appears within the type `Vmm` > note: required because it appears within the type `BarUser` > note: required because it appears within the type `Gpu` > note: required because it appears within the type `NovaCore` > note: required by a bound in `kernel::pci::Driver` > --> rust/kernel/pci.rs:294:19 > > Implement Send and Sync for MapleTree. The tree contains no thread-local > state, and all shared access goes through the internal ma_lock spinlock. > > Signed-off-by: Joel Fernandes Reviewed-by: Alice Ryhl