From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1F322C27C75 for ; Fri, 14 Jun 2024 09:51:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=D9R7E/DpQNgNsvkfegKfRFjQEUms/ZvV0CqLhYXEFAA=; b=ISmHlC93eA3SFFZMEeax/gAMB/ gUPfpiTh5NDQ7ytBzSbgT048pU0JZ3Z9LmNt9HzNH2ICTN6RCvMGIDAUBt9i24St6mq3T2/CQA9Gr jP6MwZ+6/h4ani5EfiHTvT24JCUL8JyLKrIPRUSPthETsGTedqr/a6WOP5744+nBk+YX2XuWIC6r0 72xXFOqWjLy8896Jc4OEtKc3U5GaTq7aFo+CEGzULoG3FS8o6BNrHsNzzxxWvFIKulpgsPvihnSwu Rt4fRN06aoSwiUkfaP6HdgRn/+peRf28VkfMH/A0Zu1sF5acsmHWMgrntYcNJmPPvKhnVFu6lEPLF RYwmUlig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sI3am-00000002HpJ-34Mb; Fri, 14 Jun 2024 09:51:32 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sI3al-00000002Hog-0XW3 for linux-arm-kernel@bombadil.infradead.org; Fri, 14 Jun 2024 09:51:31 +0000 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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.