blob: d4ea9ce619ab54efb6b5302033db1f7bd79f6d96 [file] [log] [blame]
Arvind M8e87d852018-01-29 00:04:29 -08001From 84a7d00ceec75535412e1a1311802fa686246fc7 Mon Sep 17 00:00:00 2001
Allen Martin685e0f82016-07-26 19:34:29 -07002From: Thomas Gleixner <tglx@linutronix.de>
3Date: Sun, 17 Jul 2011 21:33:18 +0200
Arvind M10268e72017-12-04 22:18:06 -08004Subject: [PATCH 073/366] radix-tree: Make RT aware
Allen Martin685e0f82016-07-26 19:34:29 -07005
6Disable radix_tree_preload() on -RT. This functions returns with
7preemption disabled which may cause high latencies and breaks if the
8user tries to grab any locks after invoking it.
9
10Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Allen Martin685e0f82016-07-26 19:34:29 -070011---
12 include/linux/radix-tree.h | 7 ++++++-
13 lib/radix-tree.c | 5 ++++-
14 2 files changed, 10 insertions(+), 2 deletions(-)
15
16diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
Ishan Mittalb7998262017-01-17 16:11:50 +053017index 5d5174b..8ddbd6e 100644
Allen Martin685e0f82016-07-26 19:34:29 -070018--- a/include/linux/radix-tree.h
19+++ b/include/linux/radix-tree.h
20@@ -277,8 +277,13 @@ radix_tree_gang_lookup(struct radix_tree_root *root, void **results,
21 unsigned int radix_tree_gang_lookup_slot(struct radix_tree_root *root,
22 void ***results, unsigned long *indices,
23 unsigned long first_index, unsigned int max_items);
24+#ifndef CONFIG_PREEMPT_RT_FULL
25 int radix_tree_preload(gfp_t gfp_mask);
26 int radix_tree_maybe_preload(gfp_t gfp_mask);
27+#else
28+static inline int radix_tree_preload(gfp_t gm) { return 0; }
29+static inline int radix_tree_maybe_preload(gfp_t gfp_mask) { return 0; }
30+#endif
31 void radix_tree_init(void);
32 void *radix_tree_tag_set(struct radix_tree_root *root,
33 unsigned long index, unsigned int tag);
34@@ -303,7 +308,7 @@ unsigned long radix_tree_locate_item(struct radix_tree_root *root, void *item);
35
36 static inline void radix_tree_preload_end(void)
37 {
38- preempt_enable();
39+ preempt_enable_nort();
40 }
41
42 /**
43diff --git a/lib/radix-tree.c b/lib/radix-tree.c
Ishan Mittalb7998262017-01-17 16:11:50 +053044index 6b79e90..f27e0bc 100644
Allen Martin685e0f82016-07-26 19:34:29 -070045--- a/lib/radix-tree.c
46+++ b/lib/radix-tree.c
47@@ -196,13 +196,14 @@ radix_tree_node_alloc(struct radix_tree_root *root)
48 * succeed in getting a node here (and never reach
49 * kmem_cache_alloc)
50 */
51- rtp = this_cpu_ptr(&radix_tree_preloads);
52+ rtp = &get_cpu_var(radix_tree_preloads);
53 if (rtp->nr) {
54 ret = rtp->nodes;
55 rtp->nodes = ret->private_data;
56 ret->private_data = NULL;
57 rtp->nr--;
58 }
59+ put_cpu_var(radix_tree_preloads);
60 /*
61 * Update the allocation stack trace as this is more useful
62 * for debugging.
63@@ -242,6 +243,7 @@ radix_tree_node_free(struct radix_tree_node *node)
64 call_rcu(&node->rcu_head, radix_tree_node_rcu_free);
65 }
66
67+#ifndef CONFIG_PREEMPT_RT_FULL
68 /*
69 * Load up this CPU's radix_tree_node buffer with sufficient objects to
70 * ensure that the addition of a single element in the tree cannot fail. On
71@@ -310,6 +312,7 @@ int radix_tree_maybe_preload(gfp_t gfp_mask)
72 return 0;
73 }
74 EXPORT_SYMBOL(radix_tree_maybe_preload);
75+#endif
76
77 /*
78 * Return the maximum key which can be store into a
79--
Arvind M10268e72017-12-04 22:18:06 -0800801.9.1
Allen Martin685e0f82016-07-26 19:34:29 -070081