mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-08-31 06:34:17 +00:00
109 lines
3.2 KiB
Diff
109 lines
3.2 KiB
Diff
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
Date: Fri, 14 Aug 2020 17:08:41 +0200
|
|
Subject: [PATCH 11/22] locking: split out the rbtree definition
|
|
|
|
rtmutex.h needs the definition for rb_root_cached. By including kernel.h
|
|
we will get to spinlock.h which requires rtmutex.h again.
|
|
|
|
Split out the required struct definition and move it into its own header
|
|
file which can be included by rtmutex.h
|
|
|
|
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
---
|
|
include/linux/rbtree.h | 27 +--------------------------
|
|
include/linux/rbtree_type.h | 31 +++++++++++++++++++++++++++++++
|
|
include/linux/rtmutex.h | 2 +-
|
|
3 files changed, 33 insertions(+), 27 deletions(-)
|
|
create mode 100644 include/linux/rbtree_type.h
|
|
|
|
--- a/include/linux/rbtree.h
|
|
+++ b/include/linux/rbtree.h
|
|
@@ -19,19 +19,9 @@
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/stddef.h>
|
|
+#include <linux/rbtree_type.h>
|
|
#include <linux/rcupdate.h>
|
|
|
|
-struct rb_node {
|
|
- unsigned long __rb_parent_color;
|
|
- struct rb_node *rb_right;
|
|
- struct rb_node *rb_left;
|
|
-} __attribute__((aligned(sizeof(long))));
|
|
- /* The alignment might seem pointless, but allegedly CRIS needs it */
|
|
-
|
|
-struct rb_root {
|
|
- struct rb_node *rb_node;
|
|
-};
|
|
-
|
|
#define rb_parent(r) ((struct rb_node *)((r)->__rb_parent_color & ~3))
|
|
|
|
#define RB_ROOT (struct rb_root) { NULL, }
|
|
@@ -112,21 +102,6 @@ static inline void rb_link_node_rcu(stru
|
|
typeof(*pos), field); 1; }); \
|
|
pos = n)
|
|
|
|
-/*
|
|
- * Leftmost-cached rbtrees.
|
|
- *
|
|
- * We do not cache the rightmost node based on footprint
|
|
- * size vs number of potential users that could benefit
|
|
- * from O(1) rb_last(). Just not worth it, users that want
|
|
- * this feature can always implement the logic explicitly.
|
|
- * Furthermore, users that want to cache both pointers may
|
|
- * find it a bit asymmetric, but that's ok.
|
|
- */
|
|
-struct rb_root_cached {
|
|
- struct rb_root rb_root;
|
|
- struct rb_node *rb_leftmost;
|
|
-};
|
|
-
|
|
#define RB_ROOT_CACHED (struct rb_root_cached) { {NULL, }, NULL }
|
|
|
|
/* Same as rb_first(), but O(1) */
|
|
--- /dev/null
|
|
+++ b/include/linux/rbtree_type.h
|
|
@@ -0,0 +1,31 @@
|
|
+/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
+#ifndef _LINUX_RBTREE_TYPE_H
|
|
+#define _LINUX_RBTREE_TYPE_H
|
|
+
|
|
+struct rb_node {
|
|
+ unsigned long __rb_parent_color;
|
|
+ struct rb_node *rb_right;
|
|
+ struct rb_node *rb_left;
|
|
+} __attribute__((aligned(sizeof(long))));
|
|
+/* The alignment might seem pointless, but allegedly CRIS needs it */
|
|
+
|
|
+struct rb_root {
|
|
+ struct rb_node *rb_node;
|
|
+};
|
|
+
|
|
+/*
|
|
+ * Leftmost-cached rbtrees.
|
|
+ *
|
|
+ * We do not cache the rightmost node based on footprint
|
|
+ * size vs number of potential users that could benefit
|
|
+ * from O(1) rb_last(). Just not worth it, users that want
|
|
+ * this feature can always implement the logic explicitly.
|
|
+ * Furthermore, users that want to cache both pointers may
|
|
+ * find it a bit asymmetric, but that's ok.
|
|
+ */
|
|
+struct rb_root_cached {
|
|
+ struct rb_root rb_root;
|
|
+ struct rb_node *rb_leftmost;
|
|
+};
|
|
+
|
|
+#endif
|
|
--- a/include/linux/rtmutex.h
|
|
+++ b/include/linux/rtmutex.h
|
|
@@ -14,7 +14,7 @@
|
|
#define __LINUX_RT_MUTEX_H
|
|
|
|
#include <linux/linkage.h>
|
|
-#include <linux/rbtree.h>
|
|
+#include <linux/rbtree_type.h>
|
|
#include <linux/spinlock_types_raw.h>
|
|
|
|
extern int max_lock_depth; /* for sysctl */
|