Arvind M | 8e87d85 | 2018-01-29 00:04:29 -0800 | [diff] [blame] | 1 | From 84a7d00ceec75535412e1a1311802fa686246fc7 Mon Sep 17 00:00:00 2001 |
Allen Martin | 685e0f8 | 2016-07-26 19:34:29 -0700 | [diff] [blame] | 2 | From: Thomas Gleixner <tglx@linutronix.de> |
| 3 | Date: Sun, 17 Jul 2011 21:33:18 +0200 |
Arvind M | 10268e7 | 2017-12-04 22:18:06 -0800 | [diff] [blame] | 4 | Subject: [PATCH 073/366] radix-tree: Make RT aware |
Allen Martin | 685e0f8 | 2016-07-26 19:34:29 -0700 | [diff] [blame] | 5 | |
| 6 | Disable radix_tree_preload() on -RT. This functions returns with |
| 7 | preemption disabled which may cause high latencies and breaks if the |
| 8 | user tries to grab any locks after invoking it. |
| 9 | |
| 10 | Signed-off-by: Thomas Gleixner <tglx@linutronix.de> |
Allen Martin | 685e0f8 | 2016-07-26 19:34:29 -0700 | [diff] [blame] | 11 | --- |
| 12 | include/linux/radix-tree.h | 7 ++++++- |
| 13 | lib/radix-tree.c | 5 ++++- |
| 14 | 2 files changed, 10 insertions(+), 2 deletions(-) |
| 15 | |
| 16 | diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h |
Ishan Mittal | b799826 | 2017-01-17 16:11:50 +0530 | [diff] [blame] | 17 | index 5d5174b..8ddbd6e 100644 |
Allen Martin | 685e0f8 | 2016-07-26 19:34:29 -0700 | [diff] [blame] | 18 | --- 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 | /** |
| 43 | diff --git a/lib/radix-tree.c b/lib/radix-tree.c |
Ishan Mittal | b799826 | 2017-01-17 16:11:50 +0530 | [diff] [blame] | 44 | index 6b79e90..f27e0bc 100644 |
Allen Martin | 685e0f8 | 2016-07-26 19:34:29 -0700 | [diff] [blame] | 45 | --- 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 M | 10268e7 | 2017-12-04 22:18:06 -0800 | [diff] [blame] | 80 | 1.9.1 |
Allen Martin | 685e0f8 | 2016-07-26 19:34:29 -0700 | [diff] [blame] | 81 | |