From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (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 A13EA610D for ; Sun, 16 Jun 2024 14:36:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718548563; cv=none; b=GmD728ol3hGYySwRK243b3hMINTySAWnTwBhUlIfaltSYQa9P/Oz5+oNufMXd2GlUSuzsig51q0d9fe0MScNQOl3nlI8Lvhj1aVrKtsVDLMjFBrU0PRDZVZ1yVtNcdCaC1K9sc7KyNjkFIlTU5j04vYc/BAymQQxKNDeW1mxJsI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718548563; c=relaxed/simple; bh=7e9CZmd124XeWsjsaTuz81EPjeNmZoFf85hV+ZcTGZ0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Sc7S54DLphzUFN5ZPxZMBvhiPn5TWo91qDrvMnm7MihR/ZjiJDw2mkmxAl1tIVrA7ys7yD5i+Mz+osmf6tdWI0i3QxiJpTBQ4tz/atszSwSqmZtncfaSaRisHnvBPWb7n2B4sPIqXbYgJkoJqHFFPs884BIyajdLWdTZHkPjl7k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kafxC3OZ; arc=none smtp.client-ip=209.85.222.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kafxC3OZ" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-797f1287aa3so270503885a.2 for ; Sun, 16 Jun 2024 07:36:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718548560; x=1719153360; darn=lists.linux.dev; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:from:to:cc:subject:date :message-id:reply-to; bh=i9qsPYBwH3Sp7/6c6yDAa2y8gJfd287HNf312thuud8=; b=kafxC3OZl+Lvrf+RtuXwljU2D1YkrJ1K2ENSDDr++pwRS8qAGwxFIQhngxbd4hOWNU pcuLeBxenNFdfglCdSVQ1uz8vlI+TFcf76Dd9LHqRbNEZ2cnDYgOVssh74CVir6nya8k 72JRgHZAsL0bMfvA/VncbNEiE1xF8aCGqbCURE/kOCuIHIcB5nup+UIOm3RNXLrfJOCx ckLVQFabbwIi+j/XOLv2iKwjw5tgBBE17Wby4dU06DNPTEY0ecK4Rd4Gola90qoYYqmu xnbCIN94oV4N5Q6YdKXvPpU2Vlau942PVi7YYt0G61Um0WNHLtXsrRzYO6NAbkqRCTjr UHzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718548560; x=1719153360; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i9qsPYBwH3Sp7/6c6yDAa2y8gJfd287HNf312thuud8=; b=VbjVB1e1xKVgMCQkNEeAE3rNSv65rXsVRHgxLONg7c7By4HhCroDilIOlkNk4/Ijv4 UbZksxONoSimN5DW73DyObz9Ir/AbV0n7KDt0ntjtgYSJ5p8aSmza7+4qF72er7GuZxN G6m1PmvAFxFJJUH1G0us0dET91Jb/RrIhAMEykqG0+M5gqS4NnCuHhuADJmoeqxhwRVY DMiV7qgHFRlgs2Gro7zVpH11R+Cvil0ZATYbu8AfHtaMxkb6cML/AHX6sBa56GITs4fC tSmMI5UEJ6w+d+4JIFuXk3f5pm+5Yu0yA3L0o4KhdyffUScVMVaZ71919ucNRxkxdVcK h1LQ== X-Forwarded-Encrypted: i=1; AJvYcCVJF3SbaVjylGOWIzazEft3d0cYI98788SRVc0fT0nS9xLSvNzAs/hD/ODiOtgxtdNMAkY5dryNxydszKdgUIU5ZQrsVQ== X-Gm-Message-State: AOJu0YwBJIrWXKHzczmykU5FLZ9qU7/baCv4JqFZHWczAq78b77f47dG z6Eg5lZzJcOxx9xwdtAj3verh2GJuEXr1eQlcFdu2vut/rUL3pam X-Google-Smtp-Source: AGHT+IE4znSN0CJN5q1n8JV3DeDpQHBV3vnA5qh9mxdOQC/KkdziwRzH+gkuO6qgwfyCqvW4Z/5i6A== X-Received: by 2002:a05:620a:4510:b0:792:c32f:caf0 with SMTP id af79cd13be357-798d26b521amr864146585a.70.1718548560454; Sun, 16 Jun 2024 07:36:00 -0700 (PDT) Received: from fauth1-smtp.messagingengine.com (fauth1-smtp.messagingengine.com. [103.168.172.200]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-441f2ff9418sm37282091cf.86.2024.06.16.07.35.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jun 2024 07:36:00 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfauth.nyi.internal (Postfix) with ESMTP id F0D271200043; Sun, 16 Jun 2024 10:35:58 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sun, 16 Jun 2024 10:35:59 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfedvfedgjeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhu nhcuhfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrg htthgvrhhnpeehudfgudffffetuedtvdehueevledvhfelleeivedtgeeuhfegueeviedu ffeivdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe gsohhquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdei gedqudejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfih igmhgvrdhnrghmvg X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 16 Jun 2024 10:35:58 -0400 (EDT) Date: Sun, 16 Jun 2024 07:35:57 -0700 From: Boqun Feng To: Kent Overstreet Cc: Benno Lossin , Miguel Ojeda , 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 , Andreas Hindborg , Alice Ryhl , Alan Stern , Andrea Parri , Will Deacon , Peter Zijlstra , 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: References: <5lwylk6fhlvqfgxmt7xdoxdrhtvmplo5kazpdbt3kxpnlltxit@v5xbpiv3dnqq> Precedence: bulk X-Mailing-List: llvm@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: On Sun, Jun 16, 2024 at 07:16:30AM -0700, Boqun Feng wrote: > On Sun, Jun 16, 2024 at 05:51:07AM -0400, Kent Overstreet wrote: > > On Sat, Jun 15, 2024 at 03:12:33PM -0700, Boqun Feng wrote: > > > What's the issue of having AtomicI32 and AtomicI64 first then? We don't > > > need to do 1 or 2 until the real users show up. > > > > > > And I'd like also to point out that there are a few more trait bound > > > designs needed for Atomic, for example, Atomic and Atomic > > > have different sets of API (no inc_unless_negative() for u32). > > > > > > Don't make me wrong, I have no doubt we can handle this in the type > > > system, but given the design work need, won't it make sense that we take > > > baby steps on this? We can first introduce AtomicI32 and AtomicI64 which > > > already have real users, and then if there are some values of generic > > > atomics, we introduce them and have proper discussion on design. > > > > > > To me, it's perfectly fine that Atomic{I32,I64} co-exist with Atomic. > > > What's the downside? A bit specific example would help me understand > > > the real concern here. > > > > Err, what? > > > > Of course we want generic atomics, and we need that for properly > > supporting cmpxchg. > > > > Nope. Note this series only introduces the atomic types (atomic_ C > APIs), but cmpxchg C APIs (no atomic_ prefix) are probably presented via > a different API, where we need to make it easier to interact with normal > types, and we may use generic there. > Or it could be a generic function instead of generic type like: pub unsafe fn cmpxchg(ptr: * mut T, old: T, new T) -> T the "unsafe" part is due to `ptr` may not be a valid pointer or this may make normal accesses data race. Regards, Boqun > > Bogun, you've got all the rust guys pushing for doing this with > > generics, I'm not sure why you're being stubborn here? > > Hmm? Have you seen the email I replied to John, a broader Rust community > seems doesn't appreciate the idea of generic atomics. > > Regards, > Boqun