Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp864894lqs; Fri, 14 Jun 2024 07:53:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXCwN7+9SsGpR4GbANkBNicHPpA71C++RmSunSdONu7O//NEwuXX92e96JfwfLXH91TpYSO/ByrwKr+8UR6HagvEUgiOxm3dlZPoZbxsA== X-Google-Smtp-Source: AGHT+IHDGf8uK0ix0Ngi4RJv3ja+9lA2NvEtIh3suIC831VWRVQnpTXza4z7JbpjIW1rRwevPFHn X-Received: by 2002:a17:906:48d2:b0:a6f:489b:ff50 with SMTP id a640c23a62f3a-a6f60dc1ed1mr203122466b.52.1718376803618; Fri, 14 Jun 2024 07:53:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718376803; cv=pass; d=google.com; s=arc-20160816; b=aF71d/uUgVipbAm0GRTqT+ScD3H+A1xfppV6rJcK2irABsYGfIF3h6ssg+GoZqvM2C jKlZ5Z6Una74IKcNNiOBwPHYmnjdtm5USJCPQb2hBwev5PARWOxc8J3eM5fueCisIBdc TeOtPMPl28dmSZX3RxJb8ILrxIBJBYDoOmfmL1UQ+0ZRl7RsxC9cv/1H6LXM5ymq4d80 u5VoFcrWwube4fFvNglyRW/m8OU85nl3sfMz+lXZP3JZ5B8SRx5aEtxALzfEsTGrfYF5 f3ljdx6imLEn4lVgTe8P7MQfgrZeXXx8WWKsbWj3uyPcDvQ83bgohsCafnM9YdefBCI3 1WLw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=D9R7E/DpQNgNsvkfegKfRFjQEUms/ZvV0CqLhYXEFAA=; fh=/K0np37AfufgAU9TmM3HvAcwwi2FIaDdk3Kf+2I/iWE=; b=aQe08ziKorzqb4qX8Z0ZDUvJT0029mrnTPyp3dQ7C3VpERAMfmsTyIMf2bm6J03ahI 5smGHuwDmmczY5YNejmXC49jljmWMVq/wCYDJ5TPYw3iFr0r5bbXPkPp7M1Jgbh4FMrl HXkWeGeNj0Ici5wtR2PJ5jbrQnt3L9Rjk9hrBuMdX+Mv+8soH3kbKOgIgYRhTStBZPib ZNkPf4KNJ332Av+Zht2UaESETvcdubZ06fakPWbVJ9ZiN/6D/25lyKO/Q+nzLu5YW688 1numiGyhPWMlEbYGznW/jGOshkG9/YyzYq5GbRif9sxMc0tZVZgHINyfRHM6U/7t+DQy IftA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=bKHqjXQG; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-214699-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214699-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f56dd66f2si178146466b.367.2024.06.14.07.53.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 07:53:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214699-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=bKHqjXQG; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-214699-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214699-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 08DA41F256E1 for ; Fri, 14 Jun 2024 09:57:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DAA6A198850; Fri, 14 Jun 2024 09:51:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="bKHqjXQG" Received: from casper.infradead.org (casper.infradead.org [90.155.50.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 9F66B1946CA; Fri, 14 Jun 2024 09:51:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718358699; cv=none; b=P/VqgciYAcMTdqZanNfyk6wFv4pPLFfk403Grd+FVBJLCLQm3M/zJQnVKJ7VB/0JkcDJF8owAZuTP0riEXBpJatYsEBbWWsFSfhbddL+UARl9ctOQXFXrm3u8KzpE2tuuWgaVvU8Q/JoH+jJW4nFON2HUTdQtJPefZgxF0Opcl8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718358699; c=relaxed/simple; bh=YY13vYUMWiH23OOj6eMMyehLr25oWbUwaRTSmzzu/jM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ekuB2KHBAT5s9MgIw8n8+R/lTopXKm1EZyt/ANvdtsYgAKv+AW4TezOWeiMUQfpZnQ6/XBiu298/roJpe3DOHbJ8jbizFGEZClJIgQYknnlnc/uyMvnfCMjDQFwJrSnPcibG3IZJ6MZmtgtGU3KrOSNg15gJvpNrgAYrG/2xAiY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=bKHqjXQG; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=D9R7E/DpQNgNsvkfegKfRFjQEUms/ZvV0CqLhYXEFAA=; b=bKHqjXQGGIli99vP1x6nMU+0Wv brwBnfym82dpij06ITc7lhF4/DrVQ57Rc9tY++BYcFExsfbjR0XKprP2XHneZN/UP/9xwBhuyMBiI wlhFvx/kqIHBrq3o7fR9RdOOdsZlHMzYQYnRJ3HqOI6pHMMTMiT5FUAJ5QPUUpn+gWyZPCrhkYiSf FeGGy4wnXf1PgUVqVAji84k1epbdnE9UJlWLnyO8KMpSqvA4Bw/zgpJmJ5AzyWVkmbRsjQhll5Dul NgxZPYtR27wlrT+/wqmquormdS9nbzjQp1UOplrndUGRb45Nl1sOtfuBrAYzEX/zLdOFxHLC6Lgwn ndhwOYFA==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1sI3af-0000000GqAB-0CFR; Fri, 14 Jun 2024 09:51:25 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id A8C26300886; Fri, 14 Jun 2024 11:51:24 +0200 (CEST) Date: Fri, 14 Jun 2024 11:51:24 +0200 From: Peter Zijlstra To: Boqun Feng Cc: Gary Guo , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, llvm@lists.linux.dev, Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Alan Stern , Andrea Parri , Will Deacon , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , "Paul E. McKenney" , Akira Yokosawa , Daniel Lustig , Joel Fernandes , Nathan Chancellor , Nick Desaulniers , kent.overstreet@gmail.com, Greg Kroah-Hartman , elver@google.com, Mark Rutland , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Catalin Marinas , torvalds@linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-fsdevel@vger.kernel.org, Trevor Gross , dakr@redhat.com Subject: Re: [RFC 2/2] rust: sync: Add atomic support Message-ID: <20240614095124.GN8774@noisy.programming.kicks-ass.net> References: <20240612223025.1158537-1-boqun.feng@gmail.com> <20240612223025.1158537-3-boqun.feng@gmail.com> <20240613144432.77711a3a@eugeo> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Jun 13, 2024 at 09:30:26AM -0700, Boqun Feng wrote: > We can always add a layer on top of what we have here to provide the > generic `Atomic`. However, I personally don't think generic > `Atomic` is a good idea, for a few reasons: > > * I'm not sure it will bring benefits to users, the current atomic > users in kernel are pretty specific on the size of atomic they > use, so they want to directly use AtomicI32 or AtomicI64 in > their type definitions rather than use a `Atomic` where their > users can provide type later. > > * I can also see the future where we have different APIs on > different types of atomics, for example, we could have a: > > impl AtomicI64 { > pub fn split(&self) -> (&AtomicI32, &AtomicI32) > } > > which doesn't exist for AtomicI32. Note this is not a UB because > we write our atomic implementation in asm, so it's perfectly > fine for mix-sized atomics. > > So let's start with some basic and simple until we really have a need > for generic `Atomic`. Thoughts? Not on the generic thing, but on the lack of long. atomic_long_t is often used when we have pointers with extra bits on. Then you want a number type in order to be able to manipulate the low bits.