radix tree: fix sibling entry handling in radix_tree_descend()
The fixes to the radix tree test suite show that the multi-order case is
broken. The basic reason is that the radix tree code uses tagged
pointers with the "internal" bit in the low bits, and calculating the
pointer indices was supposed to mask off those bits. But gcc will
notice that we then use the index to re-create the pointer, and will
avoid doing the arithmetic and use the tagged pointer directly.
This cleans the code up, using the existing is_sibling_entry() helper to
validate the sibling pointer range (instead of open-coding it), and
using entry_to_node() to mask off the low tag bit from the pointer. And
once you do that, you might as well just use the now cleaned-up pointer
[ Side note: the multi-order code isn't actually ever used in the kernel
right now, and the only reason I didn't just delete all that code is
that Kirill Shutemov piped up and said:
"Well, my ext4-with-huge-pages patchset uses multi-order entries.
It also converts shmem-with-huge-pages and hugetlb to them.
I'm okay with converting it to other mechanism, but I need
something. (I looked into Konstantin's RFC patchset. It looks
okay, but I don't feel myself qualified to review it as I don't
know much about radix-tree internals.)"
 http://lkml.kernel.org/r/147230727479.9957.1087787722571077339.stgit@zurg ]
Reported-by: Matthew Wilcox <firstname.lastname@example.org>
Cc: Andrew Morton <email@example.com>
Cc: Ross Zwisler <firstname.lastname@example.org>
Cc: Johannes Weiner <email@example.com>
Cc: Kirill A. Shutemov <firstname.lastname@example.org>
Cc: Konstantin Khlebnikov <email@example.com>
Cc: Cedric Blancher <firstname.lastname@example.org>
Signed-off-by: Linus Torvalds <email@example.com>
1 file changed