Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1000011rwd; Thu, 25 May 2023 06:57:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7XoeBqY4nuDK6D1rndnSX/QVRYI8rUlmG59TFrTUxLX08jKKvJnGk2xlLlzaZdOECwKSEF X-Received: by 2002:a17:90b:3b46:b0:253:9766:749e with SMTP id ot6-20020a17090b3b4600b002539766749emr1834590pjb.16.1685023079185; Thu, 25 May 2023 06:57:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685023079; cv=none; d=google.com; s=arc-20160816; b=H5nmvZZC0+1ufZ28likn2lT6l5Cc31VIWGIDLrF0VxanDhayR61Sa8/etu2xNtwnCl Kan3F9p/IMCsQBSpnIV2DQlIYWG2MmzLGS1OkRvp363nzgu9KtYIEQ62JsJAJ7PUNmM5 99bNgkxpj3umyavvT4tgV2Ujx+fFWYJd12aY3NIKwFugcCa7E4s5xi/uto/A8jQNgKHf f1xOufdOFC/QmLf2axC4MNnk/86KhRbMl9xwRQPGnZKOo2P+dO5r8S9BESbM8+2hmIrA +QlQLVpS4i3zHRNHkw1WbHhQ79AdJOFo/TcS2bQ/x9Qag064Fi+YwmmJJvOU2wbOg2y6 vaYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :feedback-id:references:in-reply-to:message-id:subject:cc:from:to :dkim-signature:date; bh=suh2qWobHv/e71oBswi/1P7jWTrjhoTP+ewfudh/9Oc=; b=o5tf8Z2q0y0OjX5XWbW3Po9C0HK0cHMK3EMu9aDPCiyPZeDutUxNLxhrT/X/UuFw0v 0tvrJF3YrnKjWdRMLPqDo+9a9AFS4wC4Ir3rCveSDRXmrPGgGWYkZIw8SOoHq7zbkgIS Pn+jqDk9Kd2pH0kK4V6e+VdL87ExxTXvVsfbbNZhygx0pbFNt+5L5Qlvoj7c76V/gJHI eHMk2sTHGBRNBDZ78u44SsywH6KELe4WD5uQKqX/8jZ00AWJjyviq3lQQvjBJQokDMyd ypL/dS8ZsQ5n0p+/LJeAaZyn7wH6akCi6gFIqE7cxdC2PrDHYaETicPeRKDXH3C54Nqx 1aZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@proton.me header.s=wq3otvmqe5fvvgofqofhhhriqi.protonmail header.b=ZCLeyRdd; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bt17-20020a17090af01100b00250888e039csi1635448pjb.62.2023.05.25.06.57.42; Thu, 25 May 2023 06:57:59 -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=@proton.me header.s=wq3otvmqe5fvvgofqofhhhriqi.protonmail header.b=ZCLeyRdd; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241346AbjEYNno (ORCPT + 99 others); Thu, 25 May 2023 09:43:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233263AbjEYNnm (ORCPT ); Thu, 25 May 2023 09:43:42 -0400 Received: from mail-40131.protonmail.ch (mail-40131.protonmail.ch [185.70.40.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7826C1A1 for ; Thu, 25 May 2023 06:43:38 -0700 (PDT) Date: Thu, 25 May 2023 13:43:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=wq3otvmqe5fvvgofqofhhhriqi.protonmail; t=1685022216; x=1685281416; bh=suh2qWobHv/e71oBswi/1P7jWTrjhoTP+ewfudh/9Oc=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=ZCLeyRdd2VTwzqWNtR9NipZcNJ2/P7pHt5uV0Fk06vLq6AV1HT0kUoFWQgljGmnvR fT0wBApE4KBEF9LXRzEScZXKZVvWyRZuD0/UZTD0ozCudmvdwTN0GQLEQoVse0gySO 4iIKmIgsce5/Ag4igpncAH8Sx/dWMv+JI08hVHh57vPNx9Y31/le8zAoad4Bi4Medw CJjrANb64yiAveXxS/1VLHuOuAopV2V+X9hw7kyB1IlUWLClJbpKbNGv64rd5HEftG XhMFkIBHrKrO1TE+goj/nnXYjO9ku8M0ctVSaVi49TxAQ507WjpUY9qBjSWong5uIO zbPYdlX0qPmNA== To: Alice Ryhl From: Benno Lossin Cc: Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , 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 Subject: Re: [PATCH v2 2/4] rust: sync: reword the `Arc` safety comment for `Sync` Message-ID: In-Reply-To: <20230523144418.1250547-3-aliceryhl@google.com> References: <20230523144418.1250547-1-aliceryhl@google.com> <20230523144418.1250547-3-aliceryhl@google.com> Feedback-ID: 71780778:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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 16:44, Alice Ryhl wrote: > The safety comment on `impl Sync for Arc` references the Send safety > comment. This commit avoids that in case the two comments drift apart in > the future. >=20 > Suggested-by: Andreas Hindborg > Signed-off-by: Alice Ryhl > Reviewed-by: Andreas Hindborg > Reviewed-by: Boqun Feng Reviewed-by: Benno Lossin > --- > rust/kernel/sync/arc.rs | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) >=20 > diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs > index 87a4c9ed712b..4d10f9868d9e 100644 > --- a/rust/kernel/sync/arc.rs > +++ b/rust/kernel/sync/arc.rs > @@ -150,9 +150,11 @@ impl, U: ?Sized> core::ops::Di= spatchFromDyn> for Ar > // mutable reference, for example, when the reference count reaches zer= o and `T` is dropped. > unsafe impl Send for Arc {} >=20 > -// SAFETY: It is safe to send `&Arc` to another thread when the under= lying `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 re= asoning as above. > +// SAFETY: It is safe to send `&Arc` to another thread when the under= lying `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` usin= g a mutable reference, for > +// example, when the reference count reaches zero and `T` is dropped. > unsafe impl Sync for Arc {} >=20 > impl Arc { > -- > 2.40.1.698.g37aff9b760-goog >=20 --=20 Cheers, Benno