From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from r-passerv.ralfj.de (r-passerv.ralfj.de [109.230.236.95]) (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 DEC472CCC0 for ; Fri, 28 Feb 2025 07:53:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=109.230.236.95 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740729195; cv=none; b=W1PPEyGC+/cagUrWeJgfQoJdcwiGT1oWDn1HH/wVtMGYdKn+w81Nc/l+r6Y3kRSM8IKd4245MVvPGYcKkDWI0hqnVVdiW58uVKHG4+PJ33chwdB7dQ7sMfYhNClmXdYr5fAruUnj434rNOAhTxgswpzxWTZPnvl/n2nA1+u+G9M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740729195; c=relaxed/simple; bh=PUtZpIADiI6Ujj2mPs39lwBthjJFOnSo983vSigK3gw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Q2FLzUTTpcuY/b8hyTgTBL15F82kpM2u+au/MlIyqgehHcIkebmSckWYkPpU76sCqAaIRTPROOrKEaKcPmUf8YXBF7AJdmbiqC6NzD+KCDk5cGgr/64EjqZpypKPGBpUaD4vRDOsjwXwzhxzgqtNrhS8TPXmytzqW8prz1pJMOU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ralfj.de; spf=pass smtp.mailfrom=ralfj.de; dkim=pass (1024-bit key) header.d=ralfj.de header.i=@ralfj.de header.b=TmzHf/je; arc=none smtp.client-ip=109.230.236.95 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ralfj.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ralfj.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ralfj.de header.i=@ralfj.de header.b="TmzHf/je" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=ralfj.de; s=mail; t=1740729192; bh=PUtZpIADiI6Ujj2mPs39lwBthjJFOnSo983vSigK3gw=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=TmzHf/jeSbNeL86dRLzSU79EbpCJtZwt7IMkXWI0zRBF0NyjDo++w0SppZyOE35J9 zaV7Gxe/vLTRc0oillVnzeoyov0DwEpi4x4A1y6aHstGVRFrwcar9frkLfAFCvlp9N 25/5TrRB1bPA56OzzQ0mXUpHfaIRxnw5czd/cc4k= Received: from [IPV6:2001:8e0:207e:3500:4ab6:48fe:df57:b084] (2001-8e0-207e-3500-4ab6-48fe-df57-b084.ewm.ftth.ip6.as8758.net [IPv6:2001:8e0:207e:3500:4ab6:48fe:df57:b084]) by r-passerv.ralfj.de (Postfix) with ESMTPSA id 0C2712052A86; Fri, 28 Feb 2025 08:53:12 +0100 (CET) Message-ID: <2949f6dc-51fe-4a28-b44d-5a38796303e8@ralfj.de> Date: Fri, 28 Feb 2025 08:53:11 +0100 Precedence: bulk X-Mailing-List: ksummit@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: C aggregate passing (Rust kernel policy) To: Linus Torvalds Cc: Kent Overstreet , Martin Uecker , "Paul E. McKenney" , Alice Ryhl , Ventura Jack , Gary Guo , airlied@gmail.com, boqun.feng@gmail.com, david.laight.linux@gmail.com, ej@inai.de, gregkh@linuxfoundation.org, hch@infradead.org, hpa@zytor.com, ksummit@lists.linux.dev, linux-kernel@vger.kernel.org, miguel.ojeda.sandonis@gmail.com, rust-for-linux@vger.kernel.org References: <6pwjvkejyw2wjxobu6ffeyolkk2fppuuvyrzqpigchqzhclnhm@v5zhfpmirk2c> <5d7363b0-785c-4101-8047-27cb7afb0364@ralfj.de> <0f3bc0e8-5111-4e2f-83b5-36b3aec0cbbd@ralfj.de> Content-Language: en-US, de-DE From: Ralf Jung In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, On 27.02.25 20:15, Linus Torvalds wrote: > On Thu, 27 Feb 2025 at 10:33, Ralf Jung wrote: >> >> The way you do global flags in Rust is like this: > > Note that I was really talking mainly about the unsafe cases, an din > particular when interfacing with C code. When Rust code and C code share memory that is concurrently accessed, all accesses to that from the Rust side must be explicitly marked as atomic. A pointer to such a memory should look like `&AtomicBool` in Rust, not `*mut bool`. To my knowledge, the kernel already has appropriate APIs for that. That will then ensure things behave like the AtomicBool example. Kind regards, Ralf > > Also, honestly: > >> FLAG.store(true, Ordering::SeqCst); // or release/acquire/relaxed > > I suspect in reality it would be hidden as accessor functions, or > people just continue to write things in C. > > Yes, I know all about the C++ memory ordering. It's not only a > standards mess, it's all very illegible code too. > > Linus