From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.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 9EDED4C8FF7 for ; Fri, 5 Jun 2026 11:17:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780658228; cv=none; b=JTVl+bBX3k7A1dRgOjb+nzYm3oc1k2/DLyvV5L+sVH7SyS4cPqR4QDuTU5AY7Bszou0ZopX+s+Tc2MIc59LjwkMUMWCNgPVcJ4gN8c7w10I9H1iTPiFRR8KlN1wXhv3fHmc8iVPapYiP7c/f0DAajUBPRkWA9SFm0W+1kFkocpE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780658228; c=relaxed/simple; bh=Jfhhoy1F0ebcVxM7LEmEEcwMSkV1JGLOusEFPE2K4+c=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=HD0IAw7qNsbsL23f7CN81TviAMDtD5EBKP0OVsbtiGLF3ey1tXt3EMZYGVEDIbJLM/GohhjJ0oPQhqKCnks9WsYpAh/0T/xQa+uAcmfCxSZfJkwsyqf8hltlKH2NHuJyziGDKTbJmH+ZsBxRwc2JSIpCksQhodM5aP3B82uHs0I= 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=GSHsKHuq; arc=none smtp.client-ip=209.85.128.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="GSHsKHuq" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-490b79e6b94so13246875e9.2 for ; Fri, 05 Jun 2026 04:17:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780658226; x=1781263026; 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=9+aRoATs22S45omivn7vkQA5BKTx+/lYuCUoy7Taidw=; b=GSHsKHuqfCvlQfegaZ4uzvb0RZNyKBgLVD+cJCncCwPwpryhiJWzIyCtcyYVWxHA8F wbMLLNwmyJ8CJPMjNyy6w6A+FGaCRxB/qXjutmQfWEFaoVlDU58G2muPit/npTBtao+b Zw0NREIPcndHqKhm3RWPCjzis9cxmUHzFmE0x7+tym6Giu5JdAhsz0959cMypHcMVvPB UVDM/d8YvufhuGA1+F82Le+t6k0iHjQP77g+J0BiM9+9GtEgafm2HCNr47lq9LNaXrbP +Z11NQ1IDFaastlL4vfyuDpv//i5Gp6bq+BpYdIRfe7pE1Ly49/bUBvVemWWB3tJPFCK /gcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780658226; x=1781263026; 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=9+aRoATs22S45omivn7vkQA5BKTx+/lYuCUoy7Taidw=; b=rjkr+cucthI1ST4IOEO5bnstZjJyencmw/VjjkbxoJnlbBSVS+oUL5D0fGWMvLxIzI kn1OfUukolLpOKpjG7AIrWis24GwLXr6spbrWC6z5c6eMnSQT9QKiQotZIqgU8H0u+Uk lBjzC/+LshJ3RgxOBFXGpgcsPhKgmk85glSORO1ngKYtfyOx+RLsvAEeGistKXlEgDQY CrKL4PlMgWTM/HbyvhMoBDV6hbBC7tGyzV9iLj/oDUEwB370qGgEzdQPxFWsSYY0D6al uBVWjLRMFtydNeAdFGzDuo64pKR/YA48prsTpcAr/m59oJKNfCLWAuUe78/WyUTgu1sZ 3gxQ== X-Forwarded-Encrypted: i=1; AFNElJ+S5Yuc77fcrRUvG7rjoBf/fw5y6RBYvoMR0tZ81QKDEySAjsoyioy6AAKC1fkR71AWytHMdrnG759liTQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzWWMkfoFaLyc1Uq3mmrL2MtZHl0tHPx/c6VecP2UyoMPPxH9xp nJzkDWhpcY9xwZZYgAJjH3vQOKDhz+FYyDmEMq/fKm8VWkftQOKe/ADlVg4L2tBKyy0kG4/nrGY zOLzt0l4XP/TsiuJkRw== X-Received: from wmbjq12.prod.google.com ([2002:a05:600c:55cc:b0:487:2186:fcf7]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:45d1:b0:489:2005:b36e with SMTP id 5b1f17b1804b1-490c26055aemr42019955e9.19.1780658225644; Fri, 05 Jun 2026 04:17:05 -0700 (PDT) Date: Fri, 5 Jun 2026 11:17:04 +0000 In-Reply-To: <20260605-xarray-lockdep-fix-v2-1-25a5509abee3@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260605-xarray-lockdep-fix-v2-1-25a5509abee3@kernel.org> Message-ID: Subject: Re: [PATCH v2] rust: xarray: fix false positive lockdep warnings From: Alice Ryhl To: Andreas Hindborg Cc: Miguel Ojeda , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Benno Lossin , Trevor Gross , Danilo Krummrich , Tamir Duberstein , Boqun Feng , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Fri, Jun 05, 2026 at 11:14:29AM +0200, Andreas Hindborg wrote: > `xa_init_flags()` is a static inline that expands `spin_lock_init()`, > which generates a single static `lock_class_key` per compilation unit. > When used through the Rust binding helper, every Rust `XArray` > instance ends up sharing that single key. Lockdep then sees concurrent > locking of distinct Rust `XArray`s as recursive locking on the same > class and emits false-positive lock-ordering reports. > > Add a custom helper `xa_init_flags_with_key()` that mirrors > `xa_init_flags()` but takes an explicit name and `struct > lock_class_key` from the caller. Update `XArray::new` to take a name > and a `LockClassKey`, and add a `new_xarray!` macro that uses > `optional_name!` and `static_lock_class!` to generate a unique class > per instantiation site. > > Remove the now unused `rust_helper_xa_init_flags`. > > This was previously part of the series at [1]. > > Link: https://lore.kernel.org/r/20251203-xarray-entry-send-v1-0-9e5ffd5e3cf0@kernel.org [1] > Fixes: 210b81578efbe ("rust: xarray: Add an abstraction for XArray") > Suggested-by: Alice Ryhl > Acked-by: Tamir Duberstein > Signed-off-by: Andreas Hindborg Reviewed-by: Alice Ryhl