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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 821C0C61DA4 for ; Fri, 3 Feb 2023 08:03:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232783AbjBCID5 (ORCPT ); Fri, 3 Feb 2023 03:03:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232775AbjBCIDQ (ORCPT ); Fri, 3 Feb 2023 03:03:16 -0500 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 222D51B306; Fri, 3 Feb 2023 00:01:41 -0800 (PST) Received: by mail-qt1-x833.google.com with SMTP id v17so4683026qto.3; Fri, 03 Feb 2023 00:01:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=Oc7Xh9yuox+AZ7mX/sAoplAbR6gr2cJ5FgTsBxboy74=; b=MTBn3C/Oox57zcfqxepxI7CXCPyjjZyyTXr8oHzGEGS904EHjRipTSqVV8+e1O69D2 KEQQ42pQQxM8Taqzvb3AO5Xx9dDMliYcsPaChPj5Ym7/a2/qQLr06+JH6FG4/gWk5QDn dLi2+LnwvAT9P3iXEOHQa9uAp9jf4kYCWqWl+Ir7VcpOLIpduQ536L/1c65xEyESjWm6 pYm0IPtGeEnf3kukL6aa2+AWHSWAz9Nb6gHmBORtZ+KuZYol035ymKr3fJsbWegXx6ra OCXydSgGvk/HcJeP07KVSCbrpLwTUd2euILFdwT+LMzKj7QwcKqVMEKhBc5Ro+OhsFje qDdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Oc7Xh9yuox+AZ7mX/sAoplAbR6gr2cJ5FgTsBxboy74=; b=X/uAnn2Y9Knv+aWcZ2N+s4ORiXBKRLGOH+imGsErGo2S5xoq7YpIm6fYaeWOL6mlZz sQ9AS7IoXXmXvXxdroWCS9FYWa4zAou2v8nUsqWtdtcejZ9T2EJtPOwjSHo2KwvGZNcU iITXEWZrtLleQUYsMUyDqkZh7M6H8TMQWePQBaXuk62JF0TzCNviSbzZxeAOYqJHYWW/ B2G7M1fTUjOlHYsoKEtFBz1IG+Xzz7Yle9W3VLaMxZTpaIp4hT7wR5UDEvzXsCtEp9uj sF1LQT42JiyhfhpcvjrFsT/KYQ/1O/ElHV0IPtWe2/S6WaV+kbuXMhUdbSakv8j6Ls8X LJ0Q== X-Gm-Message-State: AO0yUKXpbT6q5SbR9p/IdvKp3lrhH7ZVNT/weG/rsUCJJ/ZyozOE+Ta8 Oj0EHLr829a2r8D3dWaVop4= X-Google-Smtp-Source: AK7set+zCDAm97GhxYZe06v6HPw8d0RUGW9xczfBBGvmut3tTjEedm10W/DpLz+FhrbzLgT1Rryexg== X-Received: by 2002:ac8:4e90:0:b0:3b6:9c63:5ca1 with SMTP id 16-20020ac84e90000000b003b69c635ca1mr18425299qtp.43.1675411300176; Fri, 03 Feb 2023 00:01:40 -0800 (PST) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com. [66.111.4.228]) by smtp.gmail.com with ESMTPSA id y21-20020a05622a005500b003b9bb59543fsm1172432qtw.61.2023.02.03.00.01.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 00:01:39 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailauth.nyi.internal (Postfix) with ESMTP id 1F68927C0054; Fri, 3 Feb 2023 03:01:39 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 03 Feb 2023 03:01:39 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudefledguddufecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeeuohhq uhhnucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrf grthhtvghrnhephedugfduffffteeutddvheeuveelvdfhleelieevtdeguefhgeeuveei udffiedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epsghoqhhunhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqieelvdeghedt ieegqddujeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeepghhmrghilhdrtghomhesfh higihmvgdrnhgrmhgv X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 3 Feb 2023 03:01:38 -0500 (EST) Date: Fri, 3 Feb 2023 00:01:37 -0800 From: Boqun Feng To: Greg KH Cc: Miguel Ojeda , Gary Guo , Peter Zijlstra , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Will Deacon , Mark Rutland , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Vincenzo Palazzo Subject: Re: [RFC 2/5] rust: sync: Arc: Introduces ArcInner::count() Message-ID: References: <20230202142153.352ba479.gary@garyguo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 03, 2023 at 08:38:25AM +0100, Greg KH wrote: [...] > > Needless to say that ArcInner::count() can guarantee not reading 0 > > How? Because you have an implicit reference on it already? If so, then Yes, roughly a reference ("&") in Rust can be treated as a compile-time reference count, so the existence of "&" in fact prevents the underlying data from going away, or in Rust term, being "drop"ped. To get a "&ArcInner", we need a "&Arc", and as long as there is a reference to an "Arc", the object won't be dropped, that's the proof of the underly object still being referenced. Other folks may explain this better and accurate, but that's the basic idea ;-) Regards, Boqun > why does reading from it matter at all, as if you have a reference, you > know it isn't 0, and that's all that you can really care about. You > don't care about any number other than 0 for a reference count, as by > definition, that's what a reference count does :) > [...] > thanks, > > greg k-h