Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4645181rwd; Tue, 23 May 2023 10:19:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ52AS8ef2vKysMKGLtx2Xq857kmMFu0pr3zfAQDvmOrDKXp8rTzDluKzohcY3514ao39nNB X-Received: by 2002:a17:90a:6e03:b0:252:b345:7953 with SMTP id b3-20020a17090a6e0300b00252b3457953mr17974859pjk.24.1684862360800; Tue, 23 May 2023 10:19:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684862360; cv=none; d=google.com; s=arc-20160816; b=J93wVTm7rTP5spwLEoyqRUkKNYP96nA7XIOk8RNRj50zp2mhKLtMnTbcQR35h2LQ19 z5KRDZyDvofpkfaVylXOKbhKZ7ThMsABZRLYTI1MHAL702iJDrP1DVyttGWq1Bapx5LP qctaJcF7j6cjJtPPGhQvJ1rB+HtzqyEnJtz/O3j53aJAOVEnIQIJFnGGHX1sg2FA+jYR FJrqoLyToESg1QbOgWTGwL4Ikigo88DltDC+sVLIJ07sL6NOBZY42n+JL6Olb2oGRC4L hWJLZCEKk+1FxZZ5I0FZO/NJDow2nGit8+KPGfGEnXYlSA6AkHSmp7EkU1o07s6CfYLd cLGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:feedback-id:dkim-signature:dkim-signature; bh=xtAMM6mnNcy2IBjIoSVCNnLL8ij8AZ6nMF5VcBqw3e8=; b=KqylyCWGRIBeN0nsuEzx3i1Ao6Hzdj2KmDi5bRUdGPdi6GFmJaGHOHCUmVr08Kmp9Z 47I3lrhy4esRQ/dSspz22el+wPv5Ib2xubo81qGrmClRKzthJ4Z3fZhW7VODYNf33+UW mplm4+deQ5mXtZ/ZKmWfnKbJXJykpX3hHTVlCiGS0yobgQYZ7KoaFxBMHY8q1QAjREIr kj/7IA96pWLa6G/xfZDLvuute1v6fVhYSlq9jm/91/t4zsyklto6UrYfjeFM3mwNNS2b s7N75G1Ro2tIzZ2P6IKVzKcCiLeM5iR4vdKfhSKh8xyqYHHXeK++g8AL1cVugRkERH6s qv7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ryhl.io header.s=fm1 header.b=uvsiHWq7; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=zKtHNt9P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ryhl.io Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b22-20020a637156000000b0053ef0f20fe3si1495603pgn.600.2023.05.23.10.19.06; Tue, 23 May 2023 10:19:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ryhl.io header.s=fm1 header.b=uvsiHWq7; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=zKtHNt9P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ryhl.io Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236997AbjEWRIk (ORCPT + 99 others); Tue, 23 May 2023 13:08:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237420AbjEWRIi (ORCPT ); Tue, 23 May 2023 13:08:38 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFF371BB; Tue, 23 May 2023 10:08:22 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 209F85C0040; Tue, 23 May 2023 13:08:19 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 23 May 2023 13:08:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ryhl.io; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm1; t= 1684861699; x=1684948099; bh=xtAMM6mnNcy2IBjIoSVCNnLL8ij8AZ6nMF5 VcBqw3e8=; b=uvsiHWq7vuESpqxiY6QGQReZNHAux5qoRlBTdc0sIQuKEt/dfM+ qFIffGmdbfdbVc/DguHpoT11wkfYzKdKeBpcXB4lFeCLPleS6OSrpCG/HaaJJWP3 xPDGiVPEcXt+j8en8jgs9QP8DHDuKcAvIl6S2sugFR8eiwIoUNnnNDuFLCesjzcb CxzhdZ4RME74Ydr0LyS5ZgJV61IUABOViTs0QHX++4qmVzxh5/hfizvcxhOGd0Rt T187x8csHllvQ0yuLiCsfrAZOKjd528POosoSZw6Gqt2KH6Z62jfN9TEZwh0ElYB B0RCP9Br1+aaEgISoo5mSdqOdpiNXa9uwbQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1684861699; x=1684948099; bh=xtAMM6mnNcy2IBjIoSVCNnLL8ij8AZ6nMF5 VcBqw3e8=; b=zKtHNt9PheMKA5jrjQLobzU6GeQJGxUJCnQMplNpnOx631mjUGx H0bwM8X+/iV7nuQYsNOpyKIJ5FmyZOnvODFzPyVAS/RJI/tcM9sH/f3YGuQvHSyx QN9Yc1s2l5UvjWwhRivbNSb90fymwLo3HDDKpheujpoadWYp7vwTOlrfuECgUzbp bTN1QxR+pouFgkW/noMce95izbX071EpKP0WEAZ0Ako+AVoEsGwA0MxbeiOV19Yt HzO59ehtwUIAwE1eQNltemKpzBSXlAvB5nEUXXrbk3SVn4DsN8oTZfQr0tfcxv2W 83huFfLDqQ9ZjUzZ+B0xbpy6/RDjI+tXegQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeejfedguddtiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfuvfevfhfhjggtgfesthejredttdefjeenucfhrhhomheptehl ihgtvgcutfihhhhluceorghlihgtvgesrhihhhhlrdhioheqnecuggftrfgrthhtvghrnh epheduuddvteekvdektdduledugfffhfdugeejgeeuvdevtdetveejheehiefffeegnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlihgtvg esrhihhhhlrdhioh X-ME-Proxy: Feedback-ID: i56684263:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 23 May 2023 13:08:15 -0400 (EDT) Message-ID: <166384c2-7788-a295-fbe3-31fb350aac39@ryhl.io> Date: Tue, 23 May 2023 19:08:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v2 2/4] rust: sync: reword the `Arc` safety comment for `Sync` Content-Language: en-US To: Gary Guo Cc: Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor , Boqun Feng , =?UTF-8?Q?Bj=c3=b6rn_Roy_Baron?= , Benno Lossin , Ingo Molnar , Peter Zijlstra , Will Deacon , Mark Rutland , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Andreas Hindborg , Alice Ryhl References: <20230523144418.1250547-1-aliceryhl@google.com> <20230523144418.1250547-3-aliceryhl@google.com> <20230523165027.71600b4b.gary@garyguo.net> From: Alice Ryhl In-Reply-To: <20230523165027.71600b4b.gary@garyguo.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/23/23 17:50, Gary Guo wrote: >> -// SAFETY: It is safe to send `&Arc` to another thread when the underlying `T` is `Sync` for the >> -// same reason as above. `T` needs to be `Send` as well because a thread can clone an `&Arc` >> -// into an `Arc`, which may lead to `T` being accessed by the same reasoning as above. >> +// SAFETY: It is safe to send `&Arc` to another thread when the underlying `T` is `Sync` >> +// because it effectively means sharing `&T` (which is safe because `T` is `Sync`); additionally, >> +// it needs `T` to be `Send` because any thread that has a `&Arc` may clone it and get an >> +// `Arc` on that thread, so the thread may ultimately access `T` using a mutable reference, for >> +// example, when the reference count reaches zero and `T` is dropped. > > "for example" here implies that there are other case to get a mutable > reference? I don't think that's true for our `Arc` since we don't > provide a `get_mut` method. Ah, yes, that's true. Good point.