From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f73.google.com (mail-ej1-f73.google.com [209.85.218.73]) (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 3030141611C for ; Tue, 7 Jul 2026 13:17:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783430279; cv=none; b=dIAVtopAi3L4aDadlKKAgq6eAtBow2xJNqrIgwgpXCuVZKrvdldXKRBtMa6skZKWMKNjFZB2wfF1HMltjrY4yHd/Dh95WCg5CiO9iCbtKcwPY1+FlUMaBlJmRR0rMq00Gh+YYfdJOZHnJ98PHRMnKZ8/Ot6eyTbfa62psUs0gIQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783430279; c=relaxed/simple; bh=tAMUXcmv/xhf2xPlTN+bLmugvCtqb6Rh4aDlsSZNEwQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Hk2c7oUL7/avHg+fNMUcDfB0Q1mIegMPFxQCz53b9hGqG35yHY9rcmpn9E272e1J1oUyRGV1bvXzk/SEEGIF9stZFPHgrTdGwKoJ1SkVWo2ddhc9j+IKw8RA5BkeKHXvw2rZREOZxmwEv6joymD9ky16V9dYbNu4MOksB4FVU8M= 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=T3Ns3QcT; arc=none smtp.client-ip=209.85.218.73 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="T3Ns3QcT" Received: by mail-ej1-f73.google.com with SMTP id a640c23a62f3a-c08306ae1c3so155093266b.1 for ; Tue, 07 Jul 2026 06:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1783430276; x=1784035076; 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=kzxK+arJ9J97K1TUSriH2dwU/5+hYBpsdZm0cvYaBMY=; b=T3Ns3QcT9VqfK31DMsl0HBSu4ouRdF8ME2TG/Mfc777JsndPGwTiqRP+tQZyDgJyfu UxXtKLpa1Nc2WA4h56s/12eNUFLR1YlPtpoMd1swJAECKsoaBUFIxMM6CguMedOI0QjO OE77yUKqgFUXPHuhmQ2pX+5VxT6ARgh/hClmUJd3anOEKz2J2g/BUsHsv2PII1lGbzp5 uTF2x123Im/sHTUKZt2Q78oDrR4CkQu6SZ9RCOzLebCtIIG3dmXkpon2e4hFY9ZaOm9Y JsLewTn3cwmLCDbae1BcHr9ByPRb1jjEp6VlvJ6Qwqz/KLqLk6JXlxYCUoqla3yI+m+v zNuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783430276; x=1784035076; 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=kzxK+arJ9J97K1TUSriH2dwU/5+hYBpsdZm0cvYaBMY=; b=CNfOcpmoFy4g8o/GmiMEd8kZ8kMIeMeCj+4GIzmbyhq1m5Hmgaj4brZDfOKPEM+AlC GA9ZY3uW3A+QNvYocu/hVrefHdMBYRJW/WpJLE3eagF36jDQID/nRzyFg/gZHW4Jp1Ow NvtRHG1voXksxbKwKZ6vkgeS8GxUveKx2Wq6pnuZTYURRRWKrrG+FcdTNOssAlIn/mw0 yoTLWqs0d8oC1KI6g96WVOFm9CNhL1SlALvNuZLKypB+W3LIlndkiTvQ+6YPAGExLabY hAZOWcZjhHPR6wnPXrPxdwFNGZuCi9iUgSeoL8oy8Yn/EjOoSQGCC4XoC1jUpwIW3sTj lylg== X-Forwarded-Encrypted: i=1; AFNElJ8EjsOh/G4FQisAL0msgUV+vLGtPIMQdwwkOBP4yKw74jH3S1V4SwA3XG6QFIRtLiHobAlMm7yMLgN1qBM=@vger.kernel.org X-Gm-Message-State: AOJu0YxCFqsK2gfLq6jvEw8tKNIEjwa75NspHXHSF8P0asyf/4qpJQP3 QL3qHydCpOMXec1NeMUWmwOMo/uYU7FAHWKf0O/Yjs8cunqmRQeKTtUeR8WUDXMDnxYQoyggY9j /qy8LhT264bZtVlXAJw== X-Received: from ejcer3.prod.google.com ([2002:a17:907:7383:b0:c12:8073:a083]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a17:907:97ce:b0:c0c:b5ca:931 with SMTP id a640c23a62f3a-c15a68c53cdmr281610566b.31.1783430276051; Tue, 07 Jul 2026 06:17:56 -0700 (PDT) Date: Tue, 7 Jul 2026 13:17:55 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260623-pr-ratelimited-v1-0-cc922f544dc0@google.com> <20260623-pr-ratelimited-v1-2-cc922f544dc0@google.com> Message-ID: Subject: Re: [PATCH 2/5] rust: sync: add const constructor for raw_spinlock_t From: Alice Ryhl To: Gary Guo Cc: Greg Kroah-Hartman , Carlos Llamas , Boqun Feng , "Onur =?utf-8?B?w5Z6a2Fu?=" , Andreas Hindborg , Benno Lossin , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Daniel Almeida , Danilo Krummrich , Ingo Molnar , Lyude Paul , Miguel Ojeda , Peter Zijlstra , Trevor Gross , Waiman Long , Will Deacon , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Wed, Jul 01, 2026 at 05:15:55PM +0100, Gary Guo wrote: > On Tue Jun 23, 2026 at 4:38 PM BST, Alice Ryhl wrote: > > The abstractions for pr_*_ratelimited! need to construct a global > > `struct ratelimit_state`, which contains a `raw_spinlock_t` field. Thus, > > add a const constructor for the `raw_spinlock_t` type. > > > > The SPINLOCK_OWNER_INIT constant isn't mirrored via a const helper > > because bindgen generates a 'static mut' instead of a constant from the > > pointer constant., > > > > The __ARCH_SPIN_LOCK_UNLOCKED constant cannot be translated by bindgen > > because it's a define for a struct without type annotations, so it's > > explicitly declared in Rust. > > > > Signed-off-by: Alice Ryhl > > +/// Helper for creating a raw unlocked `bindings::raw_spinlock_t`. > > +/// > > +/// For use in statics containing raw spinlocks. > > +pub const fn raw_spin_lock_unlocked(name: &'static CStr) -> bindings::raw_spinlock_t { > > These functions (incl. raw_lockdep_map) should really be private functions. Hmm, I think there could be cases where a driver needs to interact with C code directly where this is useful. Even if use from drivers is discouraged, I don't think we need to go out of our way to prevent it. It's like the bindings crate. Alice