From nobody Mon Sep 15 19:11:15 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cQZPw1qdxz67srb; Mon, 15 Sep 2025 19:11:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cQZPv6CkQz4FcN; Mon, 15 Sep 2025 19:11:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757963476; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ymXwOI3IAC84SWhsyd0PH46YuHyYKT5sF2r3sb7Pu+o=; b=nmAht87scB1pa2xOZ4X79NTYGScASpkALYLf+1K05Pv25of9K1zp0Lj1eop/8bR1yiodXU ZZVrzfCTBQQzri7Ni7jmaHraTbWltIc7mQo8OEwVQxSzeEeyEXbTke9P1jfIEckVmGoH34 YeM6qTHslYyMldY7P3ZIj1C2Z7W0+9YSV1Lqw+u2OHMKnpaIh+dCdEGw4Xvm7B7RWIYbVZ qfYidHiYGbSb6Fdl9dAo3Ijof7pcUQ67IC/uNKaMwjcEWr+eEGUZ+N8GyDVUbh+1zY7beM GUfo1gYZTDC0ThRXf1xPDCFnfwxWYEVzSWycoko5HBku2+OAvOTnbWRsWsLcsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757963476; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ymXwOI3IAC84SWhsyd0PH46YuHyYKT5sF2r3sb7Pu+o=; b=gF1bKwQbYtmL1kOul7WHKZhfWErFoN2xA4offuk//gHVaf0xgVnsFJiVy3N+iCg6F0wG5q tTlkDi7BMZdjFP8qYh4uo1716yuDj3DBqApxl88ARFInKtamk+BD2LKQHvqWVx2zX7NyMY Emx3bZ7CNh+JD/wPvBrJbSLvNC7AcADwPxiN/g0oOxAIN+kfAOU6IBAJ/seJJzin0jBBU0 uBgrnc2uU81FDDxOYf4gaQr/I02Zj59ALuUZvQPv/pc32FSBceqTDuAxfbZn5DHkDoPLBE XtF+cb11Gjll1NkM/JR4cuUgUnug9omXsTkM2d/Os9U3mA35q3A/0u/u+gc58g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1757963476; a=rsa-sha256; cv=none; b=mlp963fvPFuyomhB4Yqfc1Utht0lZm1ZhCBxWLPlvQh4aJmBakA8tc+m1I955tChb7seDh Fuuc90OoMNgxuEcu2doqp1uo5UhewJ8mt3jbhqJcg6hGJHbEuzyYnt0Lva7dLecw3kB4uL wMp5RLrF7jfH+lddoN52V6OoboEGHcZLHgSWD/lL4/mIEQE8mwxGoG0WX+fqTT+936JFPl cyh8uQI5jfM9DdBw8eUFWKtrDQ70lYv4Nn9COV4dYn4h2mcC27e9Cp0azM8Hjs5TgY34RT OVjxO+3ZsFRTGdCdMvlDzrFtI+jsP5AUzI2bfZlMACpVW1YgJ/+2qVMIXmJccw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cQZPv5nX0z16s9; Mon, 15 Sep 2025 19:11:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 58FJBFRi049922; Mon, 15 Sep 2025 19:11:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58FJBF9x049919; Mon, 15 Sep 2025 19:11:15 GMT (envelope-from git) Date: Mon, 15 Sep 2025 19:11:15 GMT Message-Id: <202509151911.58FJBF9x049919@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 4d5a78c5f40a - stable/15 - LinuxKPI: add DEFINE_LOCK_GUARD_0 for rcu List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 4d5a78c5f40aa2dfd672ccfa4a6fff93e216c32b Auto-Submitted: auto-generated The branch stable/15 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=4d5a78c5f40aa2dfd672ccfa4a6fff93e216c32b commit 4d5a78c5f40aa2dfd672ccfa4a6fff93e216c32b Author: Bjoern A. Zeeb AuthorDate: 2025-09-04 20:25:30 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-09-15 14:52:31 +0000 LinuxKPI: add DEFINE_LOCK_GUARD_0 for rcu This adds guard support for non-real-types like rcu locking meaning that we need to keep the lock state separately ourselves. _T is still special and needs to be updated. Given it may not be used it needs an __unused attribute (we are using the LinuxKPI __maybe_unused which indeed is more expressive in this case). Sponsored by: The FreeBSD Foundation (initially) Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D52076 (cherry picked from commit 3f48a0fe53ca7e001852f4a406c1bdfab1cd2f6d) --- sys/compat/linuxkpi/common/include/linux/cleanup.h | 35 ++++++++++++++++++++++ .../linuxkpi/common/include/linux/rcupdate.h | 5 +++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/sys/compat/linuxkpi/common/include/linux/cleanup.h b/sys/compat/linuxkpi/common/include/linux/cleanup.h index 45c2a2359ddf..5bb146f082ed 100644 --- a/sys/compat/linuxkpi/common/include/linux/cleanup.h +++ b/sys/compat/linuxkpi/common/include/linux/cleanup.h @@ -55,4 +55,39 @@ #define __free(_n) __cleanup(__free_##_n) +/* + * Given this is a _0 version it should likely be broken up into parts. + * But we have no idead what a _1, _2, ... version would do different + * until we see a call. + * This is used for a not-real-type (rcu). We use a bool to "simulate" + * the lock held. Also _T still special, may not always be used, so tag + * with __unused (or better the LinuxKPI __maybe_unused). + */ +#define DEFINE_LOCK_GUARD_0(_n, _lock, _unlock, ...) \ + \ + typedef struct { \ + bool lock; \ + __VA_ARGS__; \ + } guard_ ## _n ## _t; \ + \ + static inline void \ + guard_ ## _n ## _destroy(guard_ ## _n ## _t *_T) \ + { \ + if (_T->lock) { \ + _unlock; \ + } \ + } \ + \ + static inline guard_ ## _n ## _t \ + guard_ ## _n ## _create(void) \ + { \ + guard_ ## _n ## _t _tmp; \ + guard_ ## _n ## _t *_T __maybe_unused; \ + \ + _tmp.lock = true; \ + _T = &_tmp; \ + _lock; \ + return (_tmp); \ + } + #endif /* _LINUXKPI_LINUX_CLEANUP_H */ diff --git a/sys/compat/linuxkpi/common/include/linux/rcupdate.h b/sys/compat/linuxkpi/common/include/linux/rcupdate.h index 85d766c8dbc9..4aceb7296cd6 100644 --- a/sys/compat/linuxkpi/common/include/linux/rcupdate.h +++ b/sys/compat/linuxkpi/common/include/linux/rcupdate.h @@ -1,7 +1,7 @@ /*- * Copyright (c) 2016-2017 Mellanox Technologies, Ltd. * All rights reserved. - * Copyright (c) 2024 The FreeBSD Foundation + * Copyright (c) 2024-2025 The FreeBSD Foundation * * Portions of this software were developed by Björn Zeeb * under sponsorship from the FreeBSD Foundation. @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -162,4 +163,6 @@ void linux_synchronize_rcu(unsigned type); #define init_rcu_head_on_stack(...) #define destroy_rcu_head_on_stack(...) +DEFINE_LOCK_GUARD_0(rcu, rcu_read_lock(), rcu_read_unlock()) + #endif /* _LINUXKPI_LINUX_RCUPDATE_H_ */