Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1187267rdh; Mon, 25 Sep 2023 06:00:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEqgAmu9RWPCOfvFHlTcKj02FLOSZfdE+tg+8H2v/t0O3XDOKOhTkbWjva/H4YMz11IJFc X-Received: by 2002:a05:6a00:2e8b:b0:68f:c9df:2ccb with SMTP id fd11-20020a056a002e8b00b0068fc9df2ccbmr5889375pfb.1.1695646819557; Mon, 25 Sep 2023 06:00:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695646819; cv=none; d=google.com; s=arc-20160816; b=lTOd5EfcP4eDhLfCUS8C+HvAv3ONsxClLdh7wFtDfaz7FxsiZ3WgOmsBAiT0HMY2eo 5WTLJlmhGp6qF82lfBTLyMQAdI66Yzv92zIJ2Hykzqyu+kXghatAYV5bPcQe+CP3UsR2 qslP7/fSXu7LlaT6sAQiyBCKSLqZUVzZBVYu3i2/0nETpc5VMECAnzb1zFIIIYLxQDa8 LAZo14W56qlN1crZhee+4eeNdnJFkIhBkqgn/ASqXMMobWz6Wqv0R40zrK//qY+Aimwm 3yflBr0ccajIUFUXkKFg3CLXGmz6orTcaSraUFLjZPFE2o4DBYB2iIedTdKZZV3Rzqm9 +jPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=HDgdET5rtDgfpk7MPhmyy8y/ZmiNwOCWphKHbytaUxo=; fh=t/sjeKs3jDUVnpgQ/tAkLOUZ0fhoGCVITqIFPNqX3gA=; b=FEz3Z8EB+n0UTPL7cvEksW9rO1aO5VaHaRjrfPAuJ6VNEY2ilziLYsPpHuPvlEaEEK oOnPdqG6uVOrbmwMvCiAXEJY96w4VeEVy2Pk5fQIXEnrR1bqHBnhkxxClkGj7LebfaUq NFqwf8KEW1QzfZ2YNNAeNxZmw8CwNMTXIVbtejnCWUcfxQGK0oS51dDS8qbhfpUJ891I UKiCXGQupkoww/IOtiGIVCZqoPTa/GMag0fTpvap7L+MFuMnQgStkzPH+Ra4ZpW/yZtq tzTpbrtXaijs/Igkj17Zteq0QStDlBg1xG0ul2i9r6CFxWT5g2K0t6rPV1tWrWSLlNp4 Rh9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YTSOu2AT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id cj15-20020a056a00298f00b0068a3a2984ccsi9916737pfb.236.2023.09.25.06.00.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 06:00:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YTSOu2AT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 2B9CD8062903; Sun, 24 Sep 2023 23:29:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232053AbjIYG3d (ORCPT + 99 others); Mon, 25 Sep 2023 02:29:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231228AbjIYG3c (ORCPT ); Mon, 25 Sep 2023 02:29:32 -0400 Received: from mail-vs1-xe30.google.com (mail-vs1-xe30.google.com [IPv6:2607:f8b0:4864:20::e30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB32EA2 for ; Sun, 24 Sep 2023 23:29:25 -0700 (PDT) Received: by mail-vs1-xe30.google.com with SMTP id ada2fe7eead31-4528cba7892so2503949137.0 for ; Sun, 24 Sep 2023 23:29:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695623365; x=1696228165; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=HDgdET5rtDgfpk7MPhmyy8y/ZmiNwOCWphKHbytaUxo=; b=YTSOu2ATNujHMfgzMWSmDmbfnRBQ1sRkuiTD3sxjJAAjfzRpD/DAOAYS5ueWPkCnic QV2aXh0PyLcy+SM2pBthdMR/T12RJipGvq2B216WCDgaMaZuUXKrmhR4x8hQlv+89m9K lo5jSeTcytCejTJRCm3Jo/SQLn4XvoZA5r0Zv46A0KvCW1HB3WydOIv+3gse8H2V1FAh k/bcy9Q4hYQTimrg481oG2MgHVKwWzhjhpB/WoujMCBShXilKOZzAadhMHpJTQSqPyX4 56THR7KPK4uTV6+hqgyDPcTchC8sAYhysnvR/2bhGMSWspi3ZmsMvyLBAC7UzUddc94Z hzYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695623365; x=1696228165; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HDgdET5rtDgfpk7MPhmyy8y/ZmiNwOCWphKHbytaUxo=; b=WSW9uSA4Bjv52y6noMl9DfqcfbuSQ3xSayZ+9/qcUxNrOApSQrI74JRh4NFxhNq+QG DnKaIg9zrhwFN+gZmePtMhYNSLijq/kUtjpV6pyzOqMc3TdXXS2YDA2abh0sCsSez6Pp EiBSB4zPZAoRFkpZYbpUTuqNONVRwjfELXZy0s2TBTTu917RsMgd/Pmm7VzrI0JozY64 E+JwvZ0Vsmho6tVT6FzFQ3e+93ucvwint6mEL0X4cKcjYAeiTp/lXPn5zvynQPFsNa5D D+oT3XVzHHOd0uv8im6GQHNAiHgfGj5hZN8c2XU5osUOE5HQFXZcma2ShwNxznKBFBl0 36kA== X-Gm-Message-State: AOJu0YznQ3G79q9zGaZ15V/Nmfb1/9SUY+QYo8wPCW1c5Nkn2hK5+9Pe EECaWXr+sWtopHBPr/xWWAIkNKQVU8PwT051uR+l7w== X-Received: by 2002:a05:6102:92:b0:452:68ee:654 with SMTP id t18-20020a056102009200b0045268ee0654mr3575157vsp.2.1695623364698; Sun, 24 Sep 2023 23:29:24 -0700 (PDT) MIME-Version: 1.0 References: <20230923144938.219517-1-wedsonaf@gmail.com> <20230923144938.219517-3-wedsonaf@gmail.com> In-Reply-To: <20230923144938.219517-3-wedsonaf@gmail.com> From: Alice Ryhl Date: Mon, 25 Sep 2023 08:29:13 +0200 Message-ID: Subject: Re: [PATCH v2 2/2] rust: arc: remove `ArcBorrow` in favour of `WithRef` To: Wedson Almeida Filho Cc: rust-for-linux@vger.kernel.org, Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , linux-kernel@vger.kernel.org, Wedson Almeida Filho Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Sun, 24 Sep 2023 23:29:34 -0700 (PDT) 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(-) 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. It also means that we can't convert an Arc with refcount 1 into a UniqueArc. Alice