[PATCH v3 26/35] percpu-rwsem.h: move declarations to percpu-rwsem_types.h

From: Max Kellermann
Date: Sun Feb 11 2024 - 07:35:39 EST


By providing declarations in a lean header, we can reduce header
dependencies.

Signed-off-by: Max Kellermann <max.kellermann@xxxxxxxxx>
---
include/linux/cgroup-defs.h | 2 +-
include/linux/percpu-rwsem.h | 15 +--------------
include/linux/percpu-rwsem_types.h | 24 ++++++++++++++++++++++++
3 files changed, 26 insertions(+), 15 deletions(-)
create mode 100644 include/linux/percpu-rwsem_types.h

diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h
index 878deefba0e1..691c50aeafae 100644
--- a/include/linux/cgroup-defs.h
+++ b/include/linux/cgroup-defs.h
@@ -16,7 +16,7 @@
#include <linux/rcupdate.h>
#include <linux/refcount_types.h>
#include <linux/percpu-refcount_types.h>
-#include <linux/percpu-rwsem.h>
+#include <linux/percpu-rwsem_types.h>
#include <linux/u64_stats_sync.h>
#include <linux/workqueue.h>
#include <linux/bpf-cgroup-defs.h>
diff --git a/include/linux/percpu-rwsem.h b/include/linux/percpu-rwsem.h
index 36b942b67b7d..0f427bd5217a 100644
--- a/include/linux/percpu-rwsem.h
+++ b/include/linux/percpu-rwsem.h
@@ -2,24 +2,11 @@
#ifndef _LINUX_PERCPU_RWSEM_H
#define _LINUX_PERCPU_RWSEM_H

+#include <linux/percpu-rwsem_types.h>
#include <linux/atomic.h>
#include <linux/percpu.h>
-#include <linux/rcuwait.h>
-#include <linux/wait.h>
-#include <linux/rcu_sync.h>
#include <linux/lockdep.h>

-struct percpu_rw_semaphore {
- struct rcu_sync rss;
- unsigned int __percpu *read_count;
- struct rcuwait writer;
- wait_queue_head_t waiters;
- atomic_t block;
-#ifdef CONFIG_DEBUG_LOCK_ALLOC
- struct lockdep_map dep_map;
-#endif
-};
-
#ifdef CONFIG_DEBUG_LOCK_ALLOC
#define __PERCPU_RWSEM_DEP_MAP_INIT(lockname) .dep_map = { .name = #lockname },
#else
diff --git a/include/linux/percpu-rwsem_types.h b/include/linux/percpu-rwsem_types.h
new file mode 100644
index 000000000000..0716d08b758b
--- /dev/null
+++ b/include/linux/percpu-rwsem_types.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_PERCPU_RWSEM_TYPES_H
+#define _LINUX_PERCPU_RWSEM_TYPES_H
+
+#include <linux/rcu_sync.h>
+#include <linux/rcuwait.h>
+#include <linux/types.h>
+#include <linux/wait_types.h>
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+#include <linux/lockdep_types.h>
+#endif
+
+struct percpu_rw_semaphore {
+ struct rcu_sync rss;
+ unsigned int __percpu *read_count;
+ struct rcuwait writer;
+ wait_queue_head_t waiters;
+ atomic_t block;
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+ struct lockdep_map dep_map;
+#endif
+};
+
+#endif
--
2.39.2