From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (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 44D7238F250 for ; Mon, 8 Jun 2026 07:29:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780903793; cv=none; b=TX/BPQBKD8gwz7qInI0fvFwPg4eZPzLizCt8tQJDTTA/7/W3ZpCVYp3yKP/Z7Tblng3AMMGL0+m1ig5DMRXIt4R7To5CMdD94aMCWiJnV7xasTx2S3UedtwMip8+2PYupN4pwlUT+injzWj/vTHsT/JeSPCgfSux9UCjJMafy8k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780903793; c=relaxed/simple; bh=Z3sHtoVgr5N5sinKLE6ie47tjXWmHwNCo+5LweGujeQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=DgJlOmg3CL9/+J1bJwdHMpp4Z0x+Aaw3AB/Dj8XswIhMtzW8sHiuJztTIv8Oh+cJ3OD9Z+8mx+Dq9k5cfypLLPZfV4mr3/K8oawd0oXOfXMCHUJ0Dp8O0mSPHQtHkkDmQXGQXkC40Sb57Ie+aF9UohGSB3ze8D790mHE8aQDZyE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=CfolGHQ7; arc=none smtp.client-ip=209.85.128.74 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=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="CfolGHQ7" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-490cc1ae292so8199145e9.1 for ; Mon, 08 Jun 2026 00:29:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780903790; x=1781508590; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=eIZ7MQAZt89pNLsUkNnmleJFvuNKGT68ArqhClWf7/4=; b=CfolGHQ7cdgOHCaNr2jhQJfTPcl9ugc5Z34VWG23eZL2xLjt07XuXPK9NfmEoaAmp2 OamgF0z5kmr4tLWEL7JaK3yJbhQxaXe7fKcRK5+OrLVJXYAcorOCpJoMk/naNHVFGYqO 80w0Hzd8Z5mrVv3S2SC8orJTSTRuSk4V/3v9HHy1cc9kBYieG03rj296KjGxJCMnsOfe FEmgv6jzU23uoVdgbgc4Pwx6vvNopSHJ+xRXPU27T6eu5FsdqqnvhctZ3jxPTn/7FBYG oSP4tLHdKJjv1AI32Ef0ypuKOGET0JN3IQsPaSsSn6GjDSKbep+OHdpjMDdvayORliPD f+WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780903790; x=1781508590; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eIZ7MQAZt89pNLsUkNnmleJFvuNKGT68ArqhClWf7/4=; b=UdQeODbliaxviBk4VkBHdXU5xvRAkYE8sldG9wPC1IN9FOsBpO5IsZ3Sy0Qk+R5mSq JMCbpFGW+kXkBDFBdw9ACuD/auBx3iqubq1A/fg5MaBiqI8b+s0DPnHr4aY6Lzl58YlU M8tUcx52RowUK9M02Wq0xiQZyjMYtVweAyZN7yZ/vzoTLnvl/4FCT3BMtyPnDAOhO9e0 PoMU7dTsEWWWMar6M55nV19KxWI1RM4iItmpHMqyaPUA0zx86EkrQH9NZrVgkZK0ElNR fO2YKlcmNNphPPMhCHZZf+z4YXjL3i/+hhCC0mT7gGr8Ra3jqDCduxKTdHtUVp9kYEuK 5MuQ== X-Forwarded-Encrypted: i=1; AFNElJ8rQkar+B9du0wXJ8VVre/N+3G3BqXvvIy+l2DtmbNbmE5rhk/4X0WTmBqa74OgAaSsTOdvmEJRxNDPEK0=@vger.kernel.org X-Gm-Message-State: AOJu0Ywof/XiNZNO0XabkkCFhHp54gDp6m4S5/SunS3NOSYjI1274upX C6qSgoxlaohVGsJeXBOJI/smAozqB5+LkYlCWOvhv/Zv/xhhFknl1x4+9OtJss1mY7Bok3LNeSP 9c6J0qApl2M4U2IBVBg== X-Received: from wmdd11.prod.google.com ([2002:a05:600c:a20b:b0:48f:e178:4b87]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:83cf:b0:490:b26c:64ad with SMTP id 5b1f17b1804b1-490c2cc3103mr178763755e9.5.1780903789602; Mon, 08 Jun 2026 00:29:49 -0700 (PDT) Date: Mon, 8 Jun 2026 07:29:48 +0000 In-Reply-To: <20260605-export-do-unlocked-v2-1-e23001390231@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260605-export-do-unlocked-v2-1-e23001390231@kernel.org> Message-ID: Subject: Re: [PATCH v2] rust: sync: export lock::do_unlocked From: Alice Ryhl To: Andreas Hindborg Cc: Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Miguel Ojeda , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Benno Lossin , Trevor Gross , Danilo Krummrich , Boqun Feng , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Fri, Jun 05, 2026 at 02:57:07PM +0200, Andreas Hindborg wrote: > Export lock::do_unlocked publicly. Add documentation for the method. > > Reviewed-by: Benno Lossin > Signed-off-by: Andreas Hindborg Reviewed-by: Alice Ryhl > rust/kernel/sync/lock.rs | 26 +++++++++++++++++++++++++- > 1 file changed, 25 insertions(+), 1 deletion(-) > > diff --git a/rust/kernel/sync/lock.rs b/rust/kernel/sync/lock.rs > index 10b6b5e9b024..9c549e469785 100644 > --- a/rust/kernel/sync/lock.rs > +++ b/rust/kernel/sync/lock.rs > @@ -238,7 +238,31 @@ pub fn lock_ref(&self) -> &'a Lock { > self.lock > } > > - pub(crate) fn do_unlocked(&mut self, cb: impl FnOnce() -> U) -> U { > + /// Temporarily unlock the lock to execute the given closure. > + /// > + /// This method unlocks the lock before calling the closure `cb`, and re-locks it afterwards. > + /// This is useful when you need to perform operations that are not allowed while holding > + /// certain locks, such as allocating memory (which is prohibited while holding a spinlock). > + /// > + /// # Examples > + /// > + /// ``` > + /// use kernel::{new_spinlock, prelude::*}; > + /// use pin_init::stack_pin_init; I think the prelude is imported automatically. Alice