aboutsummaryrefslogtreecommitdiffstats
path: root/lib/radix-tree.c
diff options
context:
space:
mode:
authorHugh Dickins <hughd@google.com>2014-03-03 18:38:23 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-03-04 10:55:47 -0500
commit5f30fc94ca985974fd54de454c7a6070388443db (patch)
tree61eaa530adadd74be8a5b80d5cbc547505ac0f48 /lib/radix-tree.c
parent3b7a6418c7494b8bf0bf0537ddee1dedbca10f51 (diff)
lib/radix-tree.c: swapoff tmpfs radix_tree: remember to rcu_read_unlock
Running fsx on tmpfs with concurrent memhog-swapoff-swapon, lots of BUG: sleeping function called from invalid context at kernel/fork.c:606 in_atomic(): 0, irqs_disabled(): 0, pid: 1394, name: swapoff 1 lock held by swapoff/1394: #0: (rcu_read_lock){.+.+.+}, at: [<ffffffff812520a1>] radix_tree_locate_item+0x1f/0x2b6 followed by ================================================ [ BUG: lock held when returning to user space! ] 3.14.0-rc1 #3 Not tainted ------------------------------------------------ swapoff/1394 is leaving the kernel with locks still held! 1 lock held by swapoff/1394: #0: (rcu_read_lock){.+.+.+}, at: [<ffffffff812520a1>] radix_tree_locate_item+0x1f/0x2b6 after which the system recovered nicely. Whoops, I long ago forgot the rcu_read_unlock() on one unlikely branch. Fixes e504f3fdd63d ("tmpfs radix_tree: locate_item to speed up swapoff") Signed-off-by: Hugh Dickins <hughd@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/radix-tree.c')
-rw-r--r--lib/radix-tree.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 7811ed3b4e70..bd4a8dfdf0b8 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -1253,8 +1253,10 @@ unsigned long radix_tree_locate_item(struct radix_tree_root *root, void *item)
1253 1253
1254 node = indirect_to_ptr(node); 1254 node = indirect_to_ptr(node);
1255 max_index = radix_tree_maxindex(node->height); 1255 max_index = radix_tree_maxindex(node->height);
1256 if (cur_index > max_index) 1256 if (cur_index > max_index) {
1257 rcu_read_unlock();
1257 break; 1258 break;
1259 }
1258 1260
1259 cur_index = __locate(node, item, cur_index, &found_index); 1261 cur_index = __locate(node, item, cur_index, &found_index);
1260 rcu_read_unlock(); 1262 rcu_read_unlock();