Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1188709rdh; Mon, 25 Sep 2023 06:01:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHMVWBs0CL2T5mtqqzX1kH5zmZulTLuItHwjLBBAKbdlu/SF3/LTdi3MhaffNyAHQxURmXD X-Received: by 2002:a05:6358:e484:b0:143:9827:5f71 with SMTP id by4-20020a056358e48400b0014398275f71mr9267879rwb.8.1695646912119; Mon, 25 Sep 2023 06:01:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695646912; cv=none; d=google.com; s=arc-20160816; b=ebpw0kUV7yLOu7pkc+KSabSCBOIuoUNz5booWLt0oxljE/GlcpvxM0397VJ+0TEb/8 ND4XGKteYJdXP6Ai0wJIWp5WVrDtO0Kg2WtyDxI98qAuvHE5vkd9lIHXmUaAfiBEtoMt 8CCA/pZBsGlIQ3OfIU4mLnvRZjyCVoWPEHI1mDMDWICLGJdrDqz/XIxYXSOY2ivZppwo T+nD+a9brMrB8q+/PJbkRw//NAj0Efz233i2nKUdMcbg+TWKAdlmHsZ1Yz/2HFxq4P34 jMS6Y86s63NsEqHZISqN/P3pzNZ0PJffJxnvGyIxqcfceVTkXaWY/N5YYURLV8tEuLnu rHPA== 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 :date:dkim-signature; bh=Bp7NY2Xx3PzppdVd0zsY5m+Xu/tPLeGNpS34H/HEOi0=; fh=Yw8ZCyBDA/51ohCwLzUDAeBBKICVtJQme2rWgEj357g=; b=vUS1Pgw3bFF68DnP995YaZlf9QhRjkQ4x3byjtJUJe1KWwZIefcbw1A5WviEactNDe KCYJXzGYmpMPrsCxIq+0ctHeUtsFnyG5dyMtaS+rUfOZchwOLnEfYJpgxsE2s7vMr25L CYOKKHfdufVD6r5YOWbw7y48E1pQZcfP90h+L8fwKZVHHuo9/hkKdHuOhezAP9RWbcqx VhqYFTpV2sZDffyopNokEUPeDxGXAcrntf2z+C5DtnM5vxw7/7kHFC6oVIG1705TnD7z /du0KW1PT6KpG41nM22poFyCey5wENEb7BpW48LfzyCS3PgdOc8N1rJIvbR5pa4kLb69 L/gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=EObWAm+D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id v186-20020a6389c3000000b0054fdb18c877si9744457pgd.607.2023.09.25.06.01.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 06:01:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=EObWAm+D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id D32D68083E67; Mon, 25 Sep 2023 02:15:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230061AbjIYJPS (ORCPT + 99 others); Mon, 25 Sep 2023 05:15:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232867AbjIYJPR (ORCPT ); Mon, 25 Sep 2023 05:15:17 -0400 Received: from mail-40134.protonmail.ch (mail-40134.protonmail.ch [185.70.40.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44FABFB; Mon, 25 Sep 2023 02:15:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1695633306; x=1695892506; bh=Bp7NY2Xx3PzppdVd0zsY5m+Xu/tPLeGNpS34H/HEOi0=; 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=EObWAm+DEfTVGivh9jvnACh5I5+ITxrqTq8ojwXQo6utLfMqc+r1a11UNsL/iroqr D+xvoGq/ua7rgCqrUQv90+MYovLlfFa1upYNpLJrsDGnwIkX60O78qR0lfz5xSTCxm aohDDe1Gz6eb9H4amoct52+rhrWadH2+IlK9TKVh9pRNHxAfHaEY2clD6bTS7J4+Po pNOgjLy7b1hR4ZwRnQCXPfyLALnbGCgyKxYiF/vR/1lbnq7nWc91x61u/r5ouEaiSE cOym8xCWh/HbIm1K09c4uhDgG23uZ+GILNKK43Wt1iiMETjI5um6CpVDvWdudpYDgt yvkd6qczDvjmA== Date: Mon, 25 Sep 2023 09:14:50 +0000 To: Alice Ryhl , Wedson Almeida Filho From: Benno Lossin Cc: rust-for-linux@vger.kernel.org, Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , linux-kernel@vger.kernel.org, Wedson Almeida Filho Subject: Re: [PATCH v2 2/2] rust: arc: remove `ArcBorrow` in favour of `WithRef` Message-ID: <969eab7f-ad40-0dfb-18b9-6002fc54e12b@proton.me> In-Reply-To: References: <20230923144938.219517-1-wedsonaf@gmail.com> <20230923144938.219517-3-wedsonaf@gmail.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=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 25 Sep 2023 02:15:19 -0700 (PDT) On 25.09.23 08:29, Alice Ryhl wrote: > On Sat, Sep 23, 2023 at 4:50=E2=80=AFPM Wedson Almeida Filho wrote: >> >> From: Wedson Almeida Filho >> >> With GATs, we don't need a separate type to represent a borrowed object >> with a refcount, we can just use Rust's regular shared borrowing. In >> this case, we use `&WithRef` instead of `ArcBorrow<'_, T>`. >> >> Co-developed-by: Boqun Feng >> Signed-off-by: Boqun Feng >> Signed-off-by: Wedson Almeida Filho >> --- >> rust/kernel/sync.rs | 2 +- >> rust/kernel/sync/arc.rs | 134 ++++++++++++---------------------------- >> 2 files changed, 39 insertions(+), 97 deletions(-) >=20 > I'm concerned about this change, because an `&WithRef` only has > immutable permissions for the allocation. No pointer derived from it > may be used to modify the value in the Arc, however, the drop > implementation of Arc will do exactly that.=20 That is indeed a problem. We could put the value in an `UnsafeCell`, but that would lose us niche optimizations and probably also other optimization= s. > It also means that we > can't convert an Arc with refcount 1 into a UniqueArc. I think you still can, since to do that you would consume the `Arc` by value, thus guaranteeing that no references (and thus no `&WithRef`) exi= st. So I think this would still be fine. --=20 Cheers, Benno