By providing declarations in a lean header, we can reduce header
dependencies.
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
include/linux/backing-dev-defs.h | 2 +-
include/linux/comedi/comedidev.h | 2 +-
include/linux/gnss.h | 2 +-
include/linux/i3c/master.h | 2 +-
include/linux/ipc_namespace.h | 2 +-
include/linux/leds.h | 2 +-
include/linux/mfd/intel-m10-bmc.h | 2 +-
include/linux/mm_types.h | 2 +-
include/linux/nfs_fs.h | 2 +-
include/linux/posix-clock.h | 2 +-
include/linux/quota.h | 2 +-
include/linux/rwsem.h | 48 +------------------
include/linux/rwsem_types.h | 78 +++++++++++++++++++++++++++++++
include/linux/tty.h | 2 +-
include/linux/user_namespace.h | 2 +-
include/net/sch_generic.h | 2 +-
include/rdma/ib_verbs.h | 2 +-
include/sound/core.h | 2 +-
18 files changed, 95 insertions(+), 63 deletions(-)
create mode 100644 include/linux/rwsem_types.h
@@ -15,7 +15,7 @@
#include <linux/kref_types.h>
#ifdef CONFIG_CGROUP_WRITEBACK
-#include <linux/rwsem.h>
+#include <linux/rwsem_types.h>
#endif
struct page;
@@ -13,7 +13,7 @@
#include <linux/dma-mapping.h>
#include <linux/mutex_types.h>
#include <linux/spinlock_types.h>
-#include <linux/rwsem.h>
+#include <linux/rwsem_types.h>
#include <linux/kref_types.h>
#include <linux/comedi.h>
@@ -12,7 +12,7 @@
#include <linux/device.h>
#include <linux/kfifo.h>
#include <linux/mutex_types.h>
-#include <linux/rwsem.h>
+#include <linux/rwsem_types.h>
#include <linux/types.h>
#include <linux/wait.h>
@@ -14,7 +14,7 @@
#include <linux/i2c.h>
#include <linux/i3c/ccc.h>
#include <linux/i3c/device.h>
-#include <linux/rwsem.h>
+#include <linux/rwsem_types.h>
#include <linux/workqueue_types.h>
#define I3C_HOT_JOIN_ADDR 0x2
@@ -4,7 +4,7 @@
#include <linux/err.h>
#include <linux/idr.h>
-#include <linux/rwsem.h>
+#include <linux/rwsem_types.h>
#include <linux/notifier.h>
#include <linux/nsproxy.h>
#include <linux/ns_common.h>
@@ -11,7 +11,7 @@
#include <dt-bindings/leds/common.h>
#include <linux/device.h>
#include <linux/mutex_types.h>
-#include <linux/rwsem.h>
+#include <linux/rwsem_types.h>
#include <linux/spinlock_types.h>
#include <linux/timer_types.h>
#include <linux/types.h>
@@ -11,7 +11,7 @@
#include <linux/bits.h>
#include <linux/dev_printk.h>
#include <linux/regmap.h>
-#include <linux/rwsem.h>
+#include <linux/rwsem_types.h>
#define M10BMC_N3000_LEGACY_BUILD_VER 0x300468
#define M10BMC_N3000_SYS_BASE 0x300800
@@ -12,7 +12,7 @@
#include <linux/spinlock_types.h>
#include <linux/rbtree_types.h>
#include <linux/maple_tree_types.h>
-#include <linux/rwsem.h>
+#include <linux/rwsem_types.h>
#include <linux/cpumask.h>
#include <linux/uprobes.h>
#include <linux/rcupdate.h>
@@ -24,7 +24,7 @@
#include <linux/pagemap.h>
#include <linux/rbtree_types.h>
#include <linux/refcount_types.h>
-#include <linux/rwsem.h>
+#include <linux/rwsem_types.h>
#include <linux/sunrpc/debug.h>
#include <linux/sunrpc/auth.h>
@@ -11,7 +11,7 @@
#include <linux/fs.h>
#include <linux/poll.h>
#include <linux/posix-timers.h>
-#include <linux/rwsem.h>
+#include <linux/rwsem_types.h>
struct posix_clock;
struct posix_clock_context;
@@ -34,7 +34,7 @@
#include <linux/list.h>
#include <linux/mutex_types.h>
-#include <linux/rwsem.h>
+#include <linux/rwsem_types.h>
#include <linux/spinlock_types.h>
#include <linux/percpu_counter.h>
@@ -8,10 +8,10 @@
#ifndef _LINUX_RWSEM_H
#define _LINUX_RWSEM_H
+#include <linux/rwsem_types.h>
#include <linux/linkage.h>
#include <linux/types.h>
-#include <linux/list.h>
#include <linux/spinlock.h>
#include <linux/atomic.h>
#include <linux/err.h>
@@ -29,43 +29,6 @@
#ifndef CONFIG_PREEMPT_RT
-#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
-#include <linux/osq_lock.h>
-#endif
-
-/*
- * For an uncontended rwsem, count and owner are the only fields a task
- * needs to touch when acquiring the rwsem. So they are put next to each
- * other to increase the chance that they will share the same cacheline.
- *
- * In a contended rwsem, the owner is likely the most frequently accessed
- * field in the structure as the optimistic waiter that holds the osq lock
- * will spin on owner. For an embedded rwsem, other hot fields in the
- * containing structure should be moved further away from the rwsem to
- * reduce the chance that they will share the same cacheline causing
- * cacheline bouncing problem.
- */
-struct rw_semaphore {
- atomic_long_t count;
- /*
- * Write owner or one of the read owners as well flags regarding
- * the current state of the rwsem. Can be used as a speculative
- * check to see if the write owner is running on the cpu.
- */
- atomic_long_t owner;
-#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
- struct optimistic_spin_queue osq; /* spinner MCS lock */
-#endif
- raw_spinlock_t wait_lock;
- struct list_head wait_list;
-#ifdef CONFIG_DEBUG_RWSEMS
- void *magic;
-#endif
-#ifdef CONFIG_DEBUG_LOCK_ALLOC
- struct lockdep_map dep_map;
-#endif
-};
-
/* In all implementations count != 0 means locked */
static inline int rwsem_is_locked(struct rw_semaphore *sem)
{
@@ -124,15 +87,6 @@ static inline int rwsem_is_contended(struct rw_semaphore *sem)
#else /* !CONFIG_PREEMPT_RT */
-#include <linux/rwbase_rt.h>
-
-struct rw_semaphore {
- struct rwbase_rt rwbase;
-#ifdef CONFIG_DEBUG_LOCK_ALLOC
- struct lockdep_map dep_map;
-#endif
-};
-
#define __RWSEM_INITIALIZER(name) \
{ \
.rwbase = __RWBASE_INITIALIZER(name), \
new file mode 100644
@@ -0,0 +1,78 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* rwsem.h: R/W semaphores, public interface
+ *
+ * Written by David Howells (dhowells@redhat.com).
+ * Derived from asm-i386/semaphore.h
+ */
+
+#ifndef _LINUX_RWSEM_TYPES_H
+#define _LINUX_RWSEM_TYPES_H
+
+#include <linux/list.h>
+#include <linux/spinlock_types.h>
+#include <linux/atomic.h>
+
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+#include <linux/lockdep_types.h>
+# define __RWSEM_DEP_MAP_INIT(lockname) \
+ .dep_map = { \
+ .name = #lockname, \
+ .wait_type_inner = LD_WAIT_SLEEP, \
+ },
+#else
+# define __RWSEM_DEP_MAP_INIT(lockname)
+#endif
+
+#ifndef CONFIG_PREEMPT_RT
+
+#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
+#include <linux/osq_lock.h>
+#endif
+
+/*
+ * For an uncontended rwsem, count and owner are the only fields a task
+ * needs to touch when acquiring the rwsem. So they are put next to each
+ * other to increase the chance that they will share the same cacheline.
+ *
+ * In a contended rwsem, the owner is likely the most frequently accessed
+ * field in the structure as the optimistic waiter that holds the osq lock
+ * will spin on owner. For an embedded rwsem, other hot fields in the
+ * containing structure should be moved further away from the rwsem to
+ * reduce the chance that they will share the same cacheline causing
+ * cacheline bouncing problem.
+ */
+struct rw_semaphore {
+ atomic_long_t count;
+ /*
+ * Write owner or one of the read owners as well flags regarding
+ * the current state of the rwsem. Can be used as a speculative
+ * check to see if the write owner is running on the cpu.
+ */
+ atomic_long_t owner;
+#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
+ struct optimistic_spin_queue osq; /* spinner MCS lock */
+#endif
+ raw_spinlock_t wait_lock;
+ struct list_head wait_list;
+#ifdef CONFIG_DEBUG_RWSEMS
+ void *magic;
+#endif
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+ struct lockdep_map dep_map;
+#endif
+};
+
+#else /* !CONFIG_PREEMPT_RT */
+
+#include <linux/rwbase_rt.h>
+
+struct rw_semaphore {
+ struct rwbase_rt rwbase;
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+ struct lockdep_map dep_map;
+#endif
+};
+
+#endif /* CONFIG_PREEMPT_RT */
+
+#endif /* _LINUX_RWSEM_TYPES_H */
@@ -13,7 +13,7 @@
#include <linux/mutex_types.h>
#include <linux/tty_flags.h>
#include <uapi/linux/tty.h>
-#include <linux/rwsem.h>
+#include <linux/rwsem_types.h>
#include <linux/llist.h>
@@ -6,7 +6,7 @@
#include <linux/ns_common.h>
#include <linux/sched.h>
#include <linux/workqueue_types.h>
-#include <linux/rwsem.h>
+#include <linux/rwsem_types.h>
#include <linux/sysctl.h>
#include <linux/err.h>
@@ -12,7 +12,7 @@
#include <linux/list.h>
#include <linux/refcount.h>
#include <linux/mutex_types.h>
-#include <linux/rwsem.h>
+#include <linux/rwsem_types.h>
#include <linux/atomic.h>
#include <linux/hashtable.h>
#include <net/gen_stats.h>
@@ -18,7 +18,7 @@
#include <linux/dma-mapping.h>
#include <linux/kref_types.h>
#include <linux/list.h>
-#include <linux/rwsem.h>
+#include <linux/rwsem_types.h>
#include <linux/workqueue_types.h>
#include <linux/irq_poll.h>
#include <uapi/linux/if_ether.h>
@@ -10,7 +10,7 @@
#include <linux/device.h>
#include <linux/sched.h> /* wake_up() */
#include <linux/mutex_types.h> /* struct mutex */
-#include <linux/rwsem.h> /* struct rw_semaphore */
+#include <linux/rwsem_types.h> /* struct rw_semaphore */
#include <linux/stringify.h>
#include <linux/printk.h>
#include <linux/wait.h>