Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2480245rdb; Mon, 12 Feb 2024 06:22:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVYeMuI7uZ2nZNmcRrw4pJ5oCw06I/VXU7AVK20b+DxEUO0dTgtLbuY23GHMAw7Mi/e0nh X-Received: by 2002:a05:6102:1263:b0:46d:1ce2:d0f1 with SMTP id q3-20020a056102126300b0046d1ce2d0f1mr2972663vsg.6.1707747759112; Mon, 12 Feb 2024 06:22:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707747759; cv=pass; d=google.com; s=arc-20160816; b=wFVETVNSnwGZX+Kdn8OqYeMNU03/xImtWFShJli1kAVHeZRwLUhsIV40UBZthIcJU1 3VG1hK5c1ESCRUpCqjBmcTVUBUJyhkVv3UQwocJ5+oHEdlPKC9lBmfPglx6SRo+sk2hR RUBwctg77RtKWkd+UKmgSpSbNby3duAR79Oqf6VsOEJgLGH+ovBHfvU99rg9+YenPO1R bRvlf5MR9N0fDZQzKNfRq4y1l7myisRP8BnTUJ+McQvr7ary6Y9n3OkIGWTj0wrG8rUj 7XP5IO0GgPwysABJ6mxRK17FhdEcLjoeTsKYhIXWlERC/HuBUtE/NffHkSTXxI7GWfd1 hAzA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=I3LbdBXEWnAUnj+b+2jhT2ldLpLCcKlNQ2zbvZ1/YpM=; fh=WwVnJvkPiXP0tf7S0Sm62PrZpY9PfRmjDDLRn+1K/Xs=; b=f097irzCbnMfY9qe9o+zQH8Y3QJY/3MTU1fWULszsWfjNgqjOYC4t+We04v3FcDbQd 997RSuqwpsV70mhH8rgFhbtYNesoiNToAmerHWjRH0Ga8Foou8F43rCH4rL9a9wHvx3+ i2PccTV455qO4ZauKaFohf68eOEqz9zms/LRJApEDpFbUlCnhqXOaEVTFLeFb+z42Vq5 YXlbsnT4M2hkKMolpLVjAEFbzFUgtULZE6vaDKVUF0P00qIp2jLX1JxZyOTY5P5CHnZH mQUNZgf1m72PPdi9Er7QQUb0Srh/MRY7SP4H2q7QfE0Y9u7I3bGHtQgRMfAWzVj0S0Dx 0s+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=QdngOZQo; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-61822-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61822-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCXVVDEolUzzBssyTvvjYO7sY6HAGQ3j8sI/V44gI+DjG4QYN+gQ+fVx4jyLutFpsQgH5OeAg1D3lIyArVObfHB3+hX6j6tWLz8ObuK4hw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i5-20020a67f585000000b0046b23c374aesi642802vso.201.2024.02.12.06.22.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 06:22:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61822-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=QdngOZQo; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-61822-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61822-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id CC1E61C20699 for ; Mon, 12 Feb 2024 14:22:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 63E813BB30; Mon, 12 Feb 2024 14:22:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QdngOZQo" Received: from mail-ua1-f47.google.com (mail-ua1-f47.google.com [209.85.222.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 330893B78D for ; Mon, 12 Feb 2024 14:22:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707747748; cv=none; b=AweSGcVPSVrvmGpuhchUxNI+sBqjPm9rTDlpOyr7iVoMyVKKnFsWK5xPMl48S7Ol2XBiLeSLuzNoi3kn3B1v5bFbvt0CVo0KR5ILTzc65+TL5QA5SmCfZHJsU7DeXlgGvR/JmPike4kpgbQHo94sBAE8WriXq3KRIIyEZIm3GFY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707747748; c=relaxed/simple; bh=fPFMCUSQsbybYYsyahcIf+x82OS1p8+vzVVjBWGByI4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=GaM7b7OyahePPKOh6sWC8TeX90YPuyt4ez8WA0/33MZIMtezBlgMy9RzSjbq4D8KaDfuCyDbh1fIVF2NnRlflFsJm00UJ74v1uasc2SDNzuWZxyNlvdafrZGHdg+LrtwnBvZiRM6zFO+itOvUOFC03LnEqSqOfnxjimKoKyd9iQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=QdngOZQo; arc=none smtp.client-ip=209.85.222.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ua1-f47.google.com with SMTP id a1e0cc1a2514c-7d5c257452dso874611241.0 for ; Mon, 12 Feb 2024 06:22:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707747746; x=1708352546; 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=I3LbdBXEWnAUnj+b+2jhT2ldLpLCcKlNQ2zbvZ1/YpM=; b=QdngOZQorjz8pwucczOJ3oVwy/OpsXpfLA6pOGGghemnmaO5emtS8VJOZj+M//PsQE lyR1qdftpmuTRU05uqm6GWkWD0GlpyTfTQXSZEXWJzsDlXNgazfwrv6/1yN38CwZwAi1 lhrngJd5OiX4QCDZObAyGI0/XvcdzqsSvUBRUy/9tveZ+roMsE7dwxdG23mHImiVMsUQ k/3aI2gfCH9w1y7UKGmsZrQk5y9hj2wjfl892jQscLeF4Rjh92Kztqfo65lzkUSodKN5 Exo3jPTgB8/5+0g6WSZRbwTUrYmPTwgxivR/UCzGFZs08K+bPyqYX65+7pEVK6QDxDMY Y1Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707747746; x=1708352546; 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=I3LbdBXEWnAUnj+b+2jhT2ldLpLCcKlNQ2zbvZ1/YpM=; b=m6ZkyGXPN2QPRT2AhWq41I7RNrsdO1zSExlE5gOvvD90xH6r9wcaSzRSdJPF6/pynU 9DB5Bcuqx7iPwSzH0xbL0DocvPg2wzHCqexa36u24aGsCCUU/9AqBbhzWefrSwfEaHBA XYZVsb2QehXY1Tg8hKBqucRnQUyxoQJk/LoagppjmxHcxPCB3GVFSaD/JJdUBoP+uqrv 3MEdV7GsGe8jMcoUnIC0OK4gmbZR0YoGs+JMSQ244B2+ar06D26EKTiv3oEX+umD2zg+ 62DCZS/y7TsoT1ECFpS25NtEzGK8kkemHUf4O5DoyKo/lLXKsLTXfdfMiTqwq0VTy7uO TQlw== X-Gm-Message-State: AOJu0YzCu4gL7rRXOehl1SHXk0AA4Iov1xGRX4RO0UMindzwnjrPKZ30 gEr7rKsweCBChj/5vRKS+B+JG7IrY/HICSVA2EG/VyJBHVPy+yV1bcOZUyJm7xBHI7Y9MSk2+rP XUC7TYiqpo4d7EC1zvbO/WXqchXBkDFaIZ+F0 X-Received: by 2002:a05:6122:4a8b:b0:4c0:7756:547c with SMTP id fa11-20020a0561224a8b00b004c07756547cmr1723692vkb.6.1707747745819; Mon, 12 Feb 2024 06:22:25 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240212-rust-locks-get-mut-v2-1-5ccd34c2b70b@gmail.com> In-Reply-To: <20240212-rust-locks-get-mut-v2-1-5ccd34c2b70b@gmail.com> From: Alice Ryhl Date: Mon, 12 Feb 2024 15:22:14 +0100 Message-ID: Subject: Re: [PATCH v2] rust: locks: Add `get_mut` method to `Lock` To: mathys35.gasnier@gmail.com Cc: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Rodriguez Reboredo Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 other = 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>. Alice