Skip to contentSkip to conversation

+ swapoff-tmpfs-radix_tree-remember-to-rcu_read_unlock.patch added to -mm tree

PATCH [email protected] 1 participant 1 message Feb 13, 2014 Library code

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

Subject: + swapoff-tmpfs-radix_tree-remember-to-rcu_read_unlock.patch added to -mm tree
To: [email protected],[email protected]
From: [email protected]
Date: Thu, 13 Feb 2014 14:27:19 -0800

The patch titled
Subject: lib/radix-tree.c: swapoff tmpfs radix_tree: remember to rcu_read_unlock
has been added to the -mm tree. Its filename is
swapoff-tmpfs-radix_tree-remember-to-rcu_read_unlock.patch

This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/swapoff-tmpfs-radix_tree-remember-to-rcu_read_unlock.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/swapoff-tmpfs-radix_tree-remember-to-rcu_read_unlock.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: Hugh Dickins <[email protected]>
Subject: 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")

---

 lib/radix-tree.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/radix-tree.c renamed from lib/radix-tree.c~swapoff-tmpfs-radix_tree-remember-to-rcu_read_unlock +3 -1
diff -puN lib/radix-tree.c~swapoff-tmpfs-radix_tree-remember-to-rcu_read_unlock lib/radix-tree.c
@@ -1253,8 +1253,10 @@ unsigned long radix_tree_locate_item(str
 
 		node = indirect_to_ptr(node);
 		max_index = radix_tree_maxindex(node->height);
-		if (cur_index > max_index)
+		if (cur_index > max_index) {
+			rcu_read_unlock();
 			break;
+		}
 
 		cur_index = __locate(node, item, cur_index, &found_index);
 		rcu_read_unlock();

_

Patches currently in -mm which might be from [email protected] are

swapoff-tmpfs-radix_tree-remember-to-rcu_read_unlock.patch mm-vmstat-fix-up-zone-state-accounting.patch fs-cachefiles-use-add_to_page_cache_lru.patch lib-radix-tree-radix_tree_delete_item.patch mm-shmem-save-one-radix-tree-lookup-when-truncating-swapped-pages.patch mm-filemap-move-radix-tree-hole-searching-here.patch mm-fs-prepare-for-non-page-entries-in-page-cache-radix-trees.patch mm-fs-store-shadow-entries-in-page-cache.patch mm-thrash-detection-based-file-cache-sizing.patch lib-radix_tree-tree-node-interface.patch mm-keep-page-cache-radix-tree-nodes-in-check.patch mm-keep-page-cache-radix-tree-nodes-in-check-fix.patch mm-keep-page-cache-radix-tree-nodes-in-check-fix-fix.patch mm-compaction-avoid-isolating-pinned-pages.patch linux-next.patch