Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4479893rwd; Tue, 23 May 2023 08:14:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5DBzj/9XWMPkP9Uiw3csWtQ+x+0gAD9UNaL0YB5aaUggoBE7JPp27OFc9MzSHfWm8Q8U6E X-Received: by 2002:a05:6a00:1ad4:b0:64d:1d84:aeb4 with SMTP id f20-20020a056a001ad400b0064d1d84aeb4mr18531159pfv.24.1684854841165; Tue, 23 May 2023 08:14:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684854841; cv=none; d=google.com; s=arc-20160816; b=efF5WiV1Thn5X/75OvBeq2v4cbjW/kTqased/7fAfoSZfDpDpHw4BaLYTeEwM9t82k 3r9dY1mm2Si3o6KtHGMX2w1l3g3d3tV6TgLQQ+KQHNtwA/JMzBk+5RaMbs1ZtUVXVpPU Zt0EXp+RB2TgGKefsH2mTpS2P+1NB9XiUr+tv5wIJEabPftXBA18+Jqr+ML1rrZ6Hl5N lAVWfljXkBA9MUH3nKzBizmF0oWmGZi9RRlZuE4eKG7Y3EavfmA9HVJ3YrcgcFWF7hax sHBUCqDqXzRZ26oUgfxmwr9wzXNA9OTUQX4P1tzXjQshuw65dRYtRYp6OltzP51WPRck ETKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=qdVRg6LoNElWahe9YlmLHc0fO9VPVtOwab5a4NPQ+t0=; b=xUgHVD/NNmGDOmKZkbmbJU0j9JfXwGzHeFf+WsR+L01xP6x79jEawoPtBi7+3NpFS8 1tw0L4QlJLcCKqFdUwkUWvGBBxRK3hZ1KK5uPQYfgFjfRhQkF1CInmoRu+a0/MGA/uBS 2NS4pZPmMry7xA9cD8MErtlc5M1kQHuSderWExPC5LtoPlHo9h9J98BsfcuqclMr9vgg 0RqyGF69NKMJnBCK2zsA+LuL9S7eHX2rX9vwtaK3WnZMETfvgNZLwf4HwN8trzJqgaJf 1CFNufAZ5qVxA5GyTv2rpjbwAPfoLpQX55iOOKdb0eqy1WMqCgOtl6uDtsgdGk3uYX63 F/Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=L+ydM2ZM; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e30-20020aa798de000000b0064d72691d73si1653315pfm.316.2023.05.23.08.13.46; Tue, 23 May 2023 08:14:01 -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=@google.com header.s=20221208 header.b=L+ydM2ZM; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237363AbjEWOpK (ORCPT + 99 others); Tue, 23 May 2023 10:45:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234406AbjEWOpI (ORCPT ); Tue, 23 May 2023 10:45:08 -0400 Received: from mail-ej1-x64a.google.com (mail-ej1-x64a.google.com [IPv6:2a00:1450:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9E49C6 for ; Tue, 23 May 2023 07:45:06 -0700 (PDT) Received: by mail-ej1-x64a.google.com with SMTP id a640c23a62f3a-94a356c74e0so745525866b.2 for ; Tue, 23 May 2023 07:45:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684853105; x=1687445105; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=qdVRg6LoNElWahe9YlmLHc0fO9VPVtOwab5a4NPQ+t0=; b=L+ydM2ZMhTGwNMwmjmnRmRfMJfy783Y8dALDZDlyzR0avEpxlOnKtSq5GYMkYzb317 vtIYmC0LT38gm6XodkzGrp11N2LZSJzXE2oX4+W0z/RRuSLisAL86VqLi7RA5QO8f8GZ MxaI60HRLpFzgsFuRKnLFYwHloYozwkZC6aKvzAr95gWRC27FvpWdG3aAxjmKIqnSmbw p1oYFQpe3C9rz5RILbQYi1dfGzQIBcN6VOtGm7F2Kkm2Uaml0QsfDRilvm4+zqsDKcZW G511w179klPw2ryx75gy6gXzIM9R+enCxH/3gS0BhdyC4bXWrH8OjIEVk2y5yvwAQAE+ 6usg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684853105; x=1687445105; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qdVRg6LoNElWahe9YlmLHc0fO9VPVtOwab5a4NPQ+t0=; b=dQZ63bLZswOTOoZOYggd1PitKu78pPpWfqj/97g/P8vAt4e5C2t1hwYuySckw35pO+ 8a4FJzsfyh5z7MqozpdJ2LBzMGoi86noA8wlBmHfWQr4DJLo/c2GV2b/z71FxIRucsDj H3pohODzU6yS4VWgnRIdNqRwsctUQoCwCSZqp+WYfg6bOmU4JFDh6WiqRLdQnI/VpMrU fGEy91G6DxHIYxUb+YADz0CUdcd172a82daqaP9wf0fRdhSJho1pLH4F/ZogfuXcQEyt dIzipXO53b/jCY7WxwOt7stxbxrR93jZBWQHtCHL53763Vc1HZZVI+tl2V/VCRZXhVBE uOyQ== X-Gm-Message-State: AC+VfDy5X6mUAL1YnUhM4bmmxiGSjWXHqsW9PFdw7/z+oXLNqdncmNf8 1oMLxRaPoK4FOphUwBpg0bLTwk588vcFfRs= X-Received: from aliceryhl.c.googlers.com ([fda3:e722:ac3:cc00:31:98fb:c0a8:6c8]) (user=aliceryhl job=sendgmr) by 2002:a17:906:8453:b0:965:ecf8:4af5 with SMTP id e19-20020a170906845300b00965ecf84af5mr5174037ejy.12.1684853105342; Tue, 23 May 2023 07:45:05 -0700 (PDT) Date: Tue, 23 May 2023 14:44:15 +0000 In-Reply-To: <20230523144418.1250547-1-aliceryhl@google.com> Mime-Version: 1.0 References: <20230523144418.1250547-1-aliceryhl@google.com> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog Message-ID: <20230523144418.1250547-2-aliceryhl@google.com> Subject: [PATCH v2 1/4] rust: sync: reword the `Arc` safety comment for `Send` From: Alice Ryhl To: Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor Cc: Boqun Feng , Gary Guo , "=?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?=" , Benno Lossin , Alice Ryhl , 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL 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 The safety comment on `impl Send for Arc` talks about "directly" accessing the value, when it really means "accessing the value with a mutable reference". This commit clarifies that. Suggested-by: Boqun Feng Signed-off-by: Alice Ryhl Reviewed-by: Andreas Hindborg Reviewed-by: Boqun Feng --- rust/kernel/sync/arc.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs index e6d206242465..87a4c9ed712b 100644 --- a/rust/kernel/sync/arc.rs +++ b/rust/kernel/sync/arc.rs @@ -146,8 +146,8 @@ impl, U: ?Sized> core::ops::DispatchFromDyn> for Ar // 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 an `Arc` may ultimately access `T` directly, for -// example, when the reference count reaches zero and `T` is dropped. +// `T` to be `Send` because any thread that has an `Arc` may ultimately access `T` using a +// mutable reference, for example, when the reference count reaches zero and `T` is dropped. unsafe impl Send for Arc {} // SAFETY: It is safe to send `&Arc` to another thread when the underlying `T` is `Sync` for the -- 2.40.1.698.g37aff9b760-goog