Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1966051rbb; Tue, 27 Feb 2024 06:51:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXzYdN4V/P/9h/Y7gFef3y2PqVInvVWfLjg91GDNv/We/3XMjE6JmzJSkaq8gWHuXSejR3lBHA408oKqQ9WJuc0UW4us5UQE5JvvjOZGQ== X-Google-Smtp-Source: AGHT+IHdEIYquRynoBY8KDyocM/30/yn1nIcPl3RpulrKKai6rSWj8eaY9sm5o896gjRNxIicjVG X-Received: by 2002:a05:6870:9193:b0:21f:f8a9:e892 with SMTP id b19-20020a056870919300b0021ff8a9e892mr7124471oaf.53.1709045502288; Tue, 27 Feb 2024 06:51:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709045502; cv=pass; d=google.com; s=arc-20160816; b=096nqZEqNk+bDUE1dB2wIMUjF2MSG+oTEe4Ak9b2upwufJzpu7d10F3K+9mU+Tk8FJ sHJotYL1OSDehqsc+zAvdt31CNcuXooujfylUs6yjSgJS/Al8KU51P/khj6Cf5itkdN4 romnclOdLgvhxsJD9vy8KuueDRaEyPtyBWCFjyAJa5+9XwV2H7z+MqdFZOUkUla5vmTK NZGHBcVGI3G4FuujwnKiWil995rpnUp/BUNw16QMZp2J3KIP4u+UT3nKRaWLEqjk4XR0 hRv4cLR/uDGhZbM5NCFZZPCXsGIZh36EeJkuXO/T5gSsh5I+Yfr7EbwHp/+t/W8olj7M vIBA== 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=i5VYPShLQ7DBuALAeVASEPVNFC0Vv1VA6Jm1u/KqDTQ=; fh=9bnnpdEq+GFqENZPIyeGa7EwS+5Ewsy6q0rXn6fLBOc=; b=L2bcKcTfB+R5D2FSQ0jWMpYs0qpKehgiA9cvcNaoSitGLhlPGEF+tkfxtdN7XNHCOo CMC2xUku3TCSBJxj2zWfroEGjltV96AuKCg2LXi/t6y4vQqYFg3b20IPXqGcxcrLMyKT gCIfivHTedKnUfHjLomz8xkwwTiTCQd+rorDKlpV00I5OBdEyeOOsuk4pSoX7oFlHunZ KxOHsoOffpZCp2dBFzXAlj9eNVVAACEPuzZQCzqQxjt9N2gc1K7oU6xutCSzW17WkkXy G69YLX5XqvNXxhX0wanbFNDvmYfyIM4AnjJchte7VssYHwJ4N37nZ7kZIrvZ3i63OdgW gBHw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=y2k7kKs4; 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-83431-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83431-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t6-20020a05620a034600b0078794b6bc75si7414249qkm.101.2024.02.27.06.51.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 06:51:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83431-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=y2k7kKs4; 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-83431-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83431-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 6BABB1C23718 for ; Tue, 27 Feb 2024 14:51:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C70913AA29; Tue, 27 Feb 2024 14:51:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="y2k7kKs4" Received: from mail-vs1-f47.google.com (mail-vs1-f47.google.com [209.85.217.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 C5D9313A89E for ; Tue, 27 Feb 2024 14:51:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709045482; cv=none; b=hR9GN+VoZUnBmbOy5gpx11ApNIX7BVU6iduiWcJUH0WWrUrNkyBNC+Y9q20UACGglrVkVg36yeEsJurW8DfFaBMpT6Uis1LfvWuQekkgapGuNLn/RyRYtWj1yMf3zNGGRdKLbWZffz0eG2NmWBz7Wjclik7z+Yp8rzPGLeoytJQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709045482; c=relaxed/simple; bh=i5VYPShLQ7DBuALAeVASEPVNFC0Vv1VA6Jm1u/KqDTQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=k3babUsCnlnTavq/PLNxRhHuzpEiqtLWFAouH51IzMYvK0VrzAdov+JqR5yiwkv7dhJCsKf1WHSenPU8pIs/LqbkJ94PhbZtzQ678TW7wm4H6alMw8g8BGD9O+DwLDuFdkY4HyGtWH8rjCeMJ+31vQLUc+pr2tk2/3SbckCf8H0= 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=y2k7kKs4; arc=none smtp.client-ip=209.85.217.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-vs1-f47.google.com with SMTP id ada2fe7eead31-4706feb17ccso524562137.1 for ; Tue, 27 Feb 2024 06:51:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709045480; x=1709650280; 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=i5VYPShLQ7DBuALAeVASEPVNFC0Vv1VA6Jm1u/KqDTQ=; b=y2k7kKs4CAC1bWyDOTpQJWRaqLpKenKzG3ksauTO5G8NZTPyJo8mW1smdwJpVAlrVt lA6bwVYGcT3eafKR5ZMVepClWHy4BhaxD0fxEg2BZ9vQ+ll60T8XcbOAJviAag4htDCl p38U9j/dat60pTt86znjokUZZQU8A39yY/adXdB6gQkcrytMDPTEy9sme35gjCcUz2kE lWoPcotXDZjnjIcPR0/yzYy7FF5KOCqR8xIIfDFwk6Wg/f7eMHq7D4gHiXGEdQQ1vXrr go3EUIfuex3JnzsMtHqlfiLJCmWHR9P750wMwAZ2K0ZqDY0HBx4WePwLvKtatYjolmbL ty4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709045480; x=1709650280; 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=i5VYPShLQ7DBuALAeVASEPVNFC0Vv1VA6Jm1u/KqDTQ=; b=UyCv1/aTsyvY8+/lG48qMy/LK9W99dVA1+UYvnSXL00SNWa2xRZkgfyYXgnnX+7+Hw lGDHrx5Y9STh0Qkh8owrfC3d6EQQ3awnSR+5uyTvrnR7s4X9lOu+sIc3rS/EqxNB65Yc 2OnkQJornf0JAY4lWzfZ9myZuQY0R2gCGGsCfYgB/5N39e2ixK25ZWr3GQ9Nxns87QLb oBjcUMcIql2rEpPiHmL7WrEfOUv0D0sR/ZqLHfo/qcueKqv6HiHiAd04Ol35Qj9V5nXT weolumpXehdac2bWRLQ6rCL9GNz2VGwXcc59z2214necMAxxduVqdD9Tyc7nuPDyT6BA jUvw== X-Forwarded-Encrypted: i=1; AJvYcCUA7/xe5YSQ33Zd1VjGsCmvdXWsLbhBV9xPJUsXGRHi+7rRLSOQ5bt4yXSw7PNj8aWPG6afnawkdWKw1eEWMwH03S7ZSgtAirGD8RCW X-Gm-Message-State: AOJu0YzBnapJZTvtuR0P9xMiBeoWL8mq34hfVLn7VyJGKFj/zIkMba3L IsCt2uSRbrvrteK5LF3ETHfCXKN4KI7Yei2zx41lIWpQxSKsT7NQq+/1A61TQ+geqldQg5EUmu2 Yhbbwrj+Z7N7Y6gTfnatJ/P0vrjESktBVJ7/v X-Received: by 2002:a05:6102:55a4:b0:470:3ade:af52 with SMTP id dc36-20020a05610255a400b004703adeaf52mr8740310vsb.6.1709045479638; Tue, 27 Feb 2024 06:51:19 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240226-rust-locks-get-mut-v4-1-24abf57707a8@gmail.com> In-Reply-To: <20240226-rust-locks-get-mut-v4-1-24abf57707a8@gmail.com> From: Alice Ryhl Date: Tue, 27 Feb 2024 15:51:08 +0100 Message-ID: Subject: Re: [PATCH v4] 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 26, 2024 at 2:55=E2=80=AFPM Mathys-Gasnier via B4 Relay wrote: > > From: Mathys-Gasnier > > Having a mutable reference guarantees that no other threads have > access to the lock, so we can take advantage of that to grant callers > access to the protected data without the the cost of acquiring and > releasing the locks. Since the lifetime of the data is tied to the > mutable reference, the borrow checker guarantees that the usage is safe. > > Reviewed-by: Martin Rodriguez Reboredo > Signed-off-by: Mathys-Gasnier Reviewed-by: Alice Ryhl