Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp708063rdb; Thu, 15 Feb 2024 12:55:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVCI88LbIpcNQAXonsYPo3LHbPhZHDTqxILxGTX1dQY4v9JAmvKZKO7Ujek5NFlHJRfgp2ryto1Nq8JfxX8l7cCsN74dT05sk+Pcr3hgQ== X-Google-Smtp-Source: AGHT+IFjwJcnjnXhsMrF6xvY9JXZfl76HRqOyrPA5Jh3ny+KU+B1E5P9VXslb2YFBOqzUu8U6a+7 X-Received: by 2002:a17:906:d930:b0:a3d:a3b2:ebf1 with SMTP id rn16-20020a170906d93000b00a3da3b2ebf1mr1677702ejb.77.1708030553997; Thu, 15 Feb 2024 12:55:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708030553; cv=pass; d=google.com; s=arc-20160816; b=SYFWjebWBRuSXIPqHc/47tO9irfM5TMVrXBN1fwwXtEPVNSqIP6XkkqFJJE+LL3aA0 VCUDgvM9jqeNWdkQuF6npT7alA9qaK5Y7HpL2H71+cTzaRbVuqUeiGZQAmfPzYtnWdo1 AGrVISd3JsujZq7fRjk2pLFdF795nEpIAGdpT6RRkRjuYcq8Lw/LOKJkeerYqdsh9nuF 1nLzxoZs+WKY+hW3RohCEizCrsucwFzHMhtkG6+X9n1x1dWrFOg2mLhT7pz8BkNlQ9V/ aXX79F4u8OBxbbTmivtuaOtRuL6sjt5cxwpLfnZU1IUR691P73T4OWTB5eg/PKNPxW80 rV5g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:feedback-id:references :in-reply-to:message-id:subject:cc:from:to:date:dkim-signature; bh=I2h/y93EAF/twExyQBodY/TNxbTPVRXIQA2iO81nDHM=; fh=qcRZMlP0JvRnaYZ5hUAKoX9cwnTIeGoZo6VIb45DNFQ=; b=o87YzAPmdZrgFyCN5Nhri+u+hRcjCQXd63FFloHfXEh1kbkI9jfuMRTcMvvBGAU04t TAJ9t+ajpZiKnOxychd6iRwcmROwoW9YNxKjVPMmBvnf2d+yzaZ8ifcJ0DkOzMO27JHc jD2p22W4t+8y8jdQ+lTuRCRBvIkbvKthecTj0I43PRpaE1hNYUyraybnYuFCNs0xEFv5 MoURcLKwv4rdCjmgwABbk53EuO6olEeN/lmerv/auM/HrjtZl+elKhDygRShM5ixyagH qkQ+OvUKi3vl8aXazh8243nPaRs7Qw27EPBpK0z3aq91jyiYtkGBNyAUBGnLWjwK5q7T U3tQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=L09ZpbTP; arc=pass (i=1 spf=pass spfdomain=proton.me dkim=pass dkdomain=proton.me dmarc=pass fromdomain=proton.me); spf=pass (google.com: domain of linux-kernel+bounces-67676-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67676-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id xa9-20020a170907b9c900b00a3d6e2d6c91si899459ejc.959.2024.02.15.12.55.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 12:55:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67676-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=L09ZpbTP; arc=pass (i=1 spf=pass spfdomain=proton.me dkim=pass dkdomain=proton.me dmarc=pass fromdomain=proton.me); spf=pass (google.com: domain of linux-kernel+bounces-67676-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67676-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id BB0051F26173 for ; Thu, 15 Feb 2024 20:55:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EE2A813B79F; Thu, 15 Feb 2024 20:55:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="L09ZpbTP" Received: from mail-0301.mail-europe.com (mail-0301.mail-europe.com [188.165.51.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1AC6013AA42 for ; Thu, 15 Feb 2024 20:55:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.165.51.139 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708030543; cv=none; b=S0NXbwfKFcDChDa8IR04Fyut88Ep+SRNCFdjVff8niuSfSXeo66tqD/3DLM3qb/zhQXcSlK5UiMH4yadps9O/vvuY5bDGkc5ofoPSBU5MONijjHJVzbBU1MCqPVsuXHahP0uW9mZrCp6TA3k2q4PPX0riGKszg7i1ipz5mXt4Is= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708030543; c=relaxed/simple; bh=KIzclAEwIBOpeiVA2+aczTSaIGRAkzsbbq/mkVVWP3w=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZhJ+yUezwYhaBezFz8kgs99pBggMEBj09KIz4HKHDZtcvrsparToCJYdzll0la3uPwp9gM6wCRCV3VkIC1Yso3Y0w7aLX0E7aem+NtIxJUNkrxOyX3J+sHYcsABCnaeRMK4JSdJSGEfIT7zeaayynChGF2C5+IylYs+/hVl9R6g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b=L09ZpbTP; arc=none smtp.client-ip=188.165.51.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1708030531; x=1708289731; bh=I2h/y93EAF/twExyQBodY/TNxbTPVRXIQA2iO81nDHM=; 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=L09ZpbTPW4NhqOgttk85t9GN/cPdz5IspaAs/NTTA8hHGGxf+7MN+acZ08CWhbenJ VJNAirwqu98ppKBKAkGI0ghy0YyX3vCck9y+4cAwi1BwqWXv4oZzwGpfvZMgEDtFoZ 6OpU9wUKVkCmszaJwIVYwi+cVkKhs+HijEWBp6+x834wBbpOOJ1c3qusCCRZpLqyum DahMNNA6LNsRSF5bauuEI3jdvA9240zKdpQItQS3smvegNHXyCsHh0pJ//oNs+dZEO iV5pQvJ/c7eRueI9lHwJkbBRughouLgPpjD1s4tPlSI6bQ9gJ1/BQ7FbZgG+D6dy8T kKswLbYzOgqiA== Date: Thu, 15 Feb 2024 20:55:11 +0000 To: Wedson Almeida Filho , Alice Ryhl From: Benno Lossin Cc: mathys35.gasnier@gmail.com, Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Rodriguez Reboredo Subject: Re: [PATCH v2] rust: locks: Add `get_mut` method to `Lock` Message-ID: In-Reply-To: References: <20240212-rust-locks-get-mut-v2-1-5ccd34c2b70b@gmail.com> Feedback-ID: 71780778:user:proton Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 15.02.24 17:50, Wedson Almeida Filho wrote: > On Mon, 12 Feb 2024 at 11:22, Alice Ryhl wrote: >> >> On Mon, Feb 12, 2024 at 3:13=E2=80=AFPM Mathys-Gasnier via B4 Relay >> wrote: >>> + /// Gets the data contained in the lock >>> + /// Having a mutable reference to the lock guarantees that no othe= r threads have access to the lock. >>> + /// Making it safe to get a mutable reference to the lock content. >>> + pub fn get_mut(&mut self) -> &mut T { >>> + self.data.get_mut() >>> + } >> >> It's impossible to call this method. You can never have a mutable >> reference to a Linux mutex because we pin our locks. At most, you can >> have a Pin<&mut Self>. >=20 > Perhaps you meant to say that it's impossible to call this method > without unsafe blocks? From a `Pin<&mut T>`, we can call > `get_unchecked_mut` to get an `&mut T`. That is the wrong way to design this, since it forces an extra `unsafe` call. Instead this function's receiver type should be `self: Pin<&mut Self>`. --=20 Cheers, Benno