From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) (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 A42F213A88A for ; Wed, 26 Feb 2025 20:25:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740601552; cv=none; b=QiVRz5zCyCyJAXiUVOKaWYuGvvYTc/jMa+VKtUuqN03g7zpGJIfjTq6US7TCt6I7F7pPVVViXtaj71xUzxSTmWsyGPY4fsUXxPEsH399dMJEvJgiYfCu03Oh6raYhSc2Xqjwe4PGVPF4R2hvqu4dETBiRs99Xk0/TyGpt7PyHOY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740601552; c=relaxed/simple; bh=Q8sYku9aMCtWhflJLwH91vUGtFPSQw2rleG8nUX/WAg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=b4gJP8Pg/cy13HT91XLt2WoDPqxPbkZ9yyAmBwbCKQAs2vghy36S8qwsP9rFoZ8y/uvvATOJRfPJXNG0nVmYny5u/2VPfclZ8XHVgtZOGSBEAurnAIDdbwl5pS0P4WLFNWf1wORYIVhhWsc/Vh1w4lyHYx/Jefr8AEWd9Fl6nNM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=UPw11DU5; arc=none smtp.client-ip=95.215.58.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="UPw11DU5" Date: Wed, 26 Feb 2025 15:25:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1740601538; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lQTz2Z60ErneXO5HjXDw3PfvKwLnnAXF84o/4WSH4M8=; b=UPw11DU5IPn/iHj10Ngjhcml/9OUHZnnKj9E2cJ4h84crN3jw+5ziDj18Y767dYbhqdkmm uGz6qTm72fDQtIetBj4i1vcsAUtKMFS4TPvVQ6CvIw+TcalQpLwEtnXJ9BmOVUSoQOdmVm 4bfI+ozZUvgBete7FVNLQCQjAURgEFE= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Linus Torvalds Cc: Ralf Jung , 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 Subject: Re: C aggregate passing (Rust kernel policy) Message-ID: References: <20250222141521.1fe24871@eugeo> <6pwjvkejyw2wjxobu6ffeyolkk2fppuuvyrzqpigchqzhclnhm@v5zhfpmirk2c> <5d7363b0-785c-4101-8047-27cb7afb0364@ralfj.de> Precedence: bulk X-Mailing-List: ksummit@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT On Wed, Feb 26, 2025 at 09:59:41AM -0800, Linus Torvalds wrote: > And just as an example: threading fundamentally introduces a notion of > "aliasing" because different *threads* can access the same location > concurrently. And that actually has real effects that a good language > absolutely needs to deal with, even when there is absolutely *no* > memory ordering or locking in the source code. > > For example, it means that you cannot ever widen stores unless you > know that the data you are touching is thread-local. Because the bytes > *next* to you may not be things that you control. In Rust, W^X references mean you know that if you're writing to an object you've got exclusive access - the exception being across an UnsafeCell boundary, that's where you can't widen stores. Which means all those old problems with bitfields go away, and the compiler people finally know what they can safely do - and we have to properly annotate access from multiple threads. E.g. if you're doing a ringbuffer with head and tail pointers shared between multiple threads, you no longer do that with bare integers, you use atomics (even if you're not actually using any atomic operations on them).