Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4619226rwd; Tue, 23 May 2023 10:01:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6OmJX3ghoHZBYxyhAgM+dlgAn1qbLxWOy33acpLoaXCFaQRvo1X0oS9MfL1HzQHSsp5XtM X-Received: by 2002:a17:902:efd5:b0:1ae:4a0b:5957 with SMTP id ja21-20020a170902efd500b001ae4a0b5957mr13925191plb.54.1684861267892; Tue, 23 May 2023 10:01:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684861267; cv=none; d=google.com; s=arc-20160816; b=yWhj6B978zJnBakgGhpDvC/prEp2RSNiEpfN+jKOWQgbXOI9OoCfa3yjuzRje+5pJC Ikp7giUCcLicbNOegMFMs+f23eqi8w9vFxHO/eEGdcCs7j5Nz+LYtjRIwr6tLBehkYyk uAhJN2nVJbq5O9MaYQ01owLCLqCz7uWQ0MZap8yCLh7cJGlszNyqVeTVHSU08e+zlQSF WfUtMUNzjjD08CwDfdZAAWsV/GdRIbjrlFxYFKEJoLeDqr0ZByU94BOLK7nBKndf4nMy Tgq0aM6NGo236MQgXg/3o4jyFLYtc09Cl0KOe4jind7AVPJ+NmOQOac7xf3c2LpIJ4vD SyXQ== 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:dkim-signature; bh=RLkW4IB8Lte2u6vuIxUUWaT7tLfO+b0+5hxrFkp7bhc=; b=nu74tpFHQuhfQ0P/htwC1Riz5JbP5H+CNitBLi9rUHPcYwsHAne/oSbMI258qAcam6 RDbemWo0zJ2uXChlcBwvn3hqyRs0gWmOy+5PtrEgf7qdNZKfj6R5Z+KQCKunr0C7GpfB WAsvQl6pZy9y+8vHGlEDMbtUZ4PgOt2X8Hvh70/6GHRLbKUPDeQ2pkdeJncG6CgOfCZe WgIAUv4R817pSeea51fD+jvqOEsSSmkYvCaNvDVjEAUXeYKwX1FTVmxybFUa1lF1vPOu uXqHAuqJrNO9tJzDPm+t+1OIEFSB02bDV45CZFUxOQbqxaqKr7eeehnYP9JpyWOTSCrz X11w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=kUCgughp; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n12-20020a170903110c00b001ae8c269c76si6742156plh.638.2023.05.23.10.00.52; Tue, 23 May 2023 10:01:07 -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=@gmail.com header.s=20221208 header.b=kUCgughp; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229785AbjEWQmJ (ORCPT + 99 others); Tue, 23 May 2023 12:42:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229775AbjEWQmG (ORCPT ); Tue, 23 May 2023 12:42:06 -0400 Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F8D8DD; Tue, 23 May 2023 09:42:05 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-6af93a6166fso394019a34.3; Tue, 23 May 2023 09:42:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684860125; x=1687452125; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=RLkW4IB8Lte2u6vuIxUUWaT7tLfO+b0+5hxrFkp7bhc=; b=kUCgughpIJFzbxEq3AE8VPjotAe+3xTZO3xkUj0MrzsLSYwWZZPW9zcZrWxccfneBL dftkAjIooDR8R+BPmyfjy/ASOUghqozY2399/dpOglToYplavPxrkWg1RXRL+LBkfv4A URvpdv5cOxzh9MWWrbW0BIeGsIPKwXub2O73h8oMdM9BNWJNupCq2BPljuLmf+UAskhT 0Z0Z1Oho8EA4zX2eKGym2lPeIm9NXdkqRQ6VqvI5aOwGeuqaEk1EeZmnVEMd6HA82KA3 thoGkiVOC9+y2G8/Qfg6JynTBEYSbFqwsMKQyOCNK/ew5EM9d00V19Lm7X3OQHBZcENN qPCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684860125; x=1687452125; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RLkW4IB8Lte2u6vuIxUUWaT7tLfO+b0+5hxrFkp7bhc=; b=ViJ1wzfNWO3eSckWE15YwcYEAJVRixcjtkzbtaDdrevkEiu0aYZszLG7zGJJ9rsFAv j9nKbTks0YRUvqfVYxlk7KGl6veuce2VFsiwPkJGUo86J7ZSFroJUglDJOSYEgiV5QrC 3gC4zxoD+nKyc6ue+W/9BHHvEGtSiWtH+UA44CRWmoHFfrMOCqlzKltPDV9ybs6AzKCm iL8/VXJZHprSoFoRv3LZK6TieanRq55aB66KC8yoCR+VMhT9PPluCkj8evFVDeWeXDAq wPoAg4SHLcVeTSYoHenj4UyguqMKSu53n4zVVgJJT9M97mppGxJaGqu83ASGqDuBeWPY NKPQ== X-Gm-Message-State: AC+VfDxTBOvGnnM5/ClP0gfI8/kd8M9Paxg1wGLRCM2aTVVNl3nYJADT Rzja+AzT2MKM9Hu5QQujrFM= X-Received: by 2002:a9d:6b8c:0:b0:6a4:19b2:d813 with SMTP id b12-20020a9d6b8c000000b006a419b2d813mr7614811otq.30.1684860124925; Tue, 23 May 2023 09:42:04 -0700 (PDT) Received: from [192.168.54.90] (static.220.238.itcsa.net. [190.15.220.238]) by smtp.gmail.com with ESMTPSA id j9-20020a9d7389000000b006a3bd777dfdsm3576008otk.12.2023.05.23.09.42.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 May 2023 09:42:04 -0700 (PDT) Message-ID: Date: Tue, 23 May 2023 13:29:07 -0300 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: Alice Ryhl , Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor Cc: Boqun Feng , Gary Guo , =?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 References: <20230523144418.1250547-1-aliceryhl@google.com> <20230523144418.1250547-3-aliceryhl@google.com> From: Martin Rodriguez Reboredo In-Reply-To: <20230523144418.1250547-3-aliceryhl@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 11: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. > > Suggested-by: Andreas Hindborg > Signed-off-by: Alice Ryhl > Reviewed-by: Andreas Hindborg > Reviewed-by: Boqun Feng > --- > [...] > > -// 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. > unsafe impl Sync for Arc {} > > impl Arc { Reviewed-by: Martin Rodriguez Reboredo