Skip to content

lib/generic-radix-tree: genradix bug fix and optimisations.

David Laight linux-sctp lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest13 patches 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13lib/generic-radix-tree: Fix potentially corrupt treelib/generic-radix-tree.c+17 -200 replies
2/13lib/generic-radix-tree: Optimise out ilog2(variable).lib/generic-radix-tree.c+3 -30 replies
3/13lib/generic-radix-tree: Always use low 8 bits of 'root' for depth.lib/generic-radix-tree.c+9 -60 replies
4/13lib/generic-radix-tree: Optimise __genradix_ptr()lib/generic-radix-tree.c+19 -110 replies
5/13lib/generic-radix-tree: Optimise __genradix_ptr_alloc()lib/generic-radix-tree.c+74 -370 replies
6/13lib/generic-radix-tree: Rename gfp_mask to gfp to shorten lines.lib/generic-radix-tree.c+13 -150 replies
7/13lib/generic-radix-tree: Optimise __genradix_iter_peek()lib/generic-radix-tree.c+8 -160 replies
8/13lib/generic-radix-tree: Save number of bits to shift instead of tree level.lib/generic-radix-tree.c+59 -570 replies
9/13lib/generic-radix-tree: Check sizeof(_type) when defining a tree.include/linux/generic-radix-tree.h+3 -60 replies
10/13lib/generic-radix-tree: Simplify offset calculation:include/linux/generic-radix-tree.h+2 -70 replies
11/13lib/generic-radix-tree: Pass the root pointer to __genradix_ptr.include/linux/generic-radix-tree.h lib/generic-radix-tree.c+3 -40 replies
12/13lib/generic-radix-tree: Inline genradix_ptr() for simple trees.include/linux/generic-radix-tree.h lib/generic-radix-tree.c+39 -180 replies
13/13lib/generic-radix-tree: Simplify __genradix_ptr()lib/generic-radix-tree.c+3 -60 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/13] lib/generic-radix-tree: genradix bug fix and optimisations.

The genradix code is used by SCTP for accessing per-stream data. This means there are quite a lot of lookups but the code wasn't really optimised at all.

Patch 1 fixes a rather nasty bug that could cause all sorts of oddities including having a loop in a tree.
Fortunately the only 2 users of the genradix code in the kernel source tree and neither can possibly hit the bug.

Patches 2 through 11 all reduce codepath. Especially for the common case (for both users) where all the data fits in one page.

Patch 12 inlines the common lookup function for 1 page trees. This also remove the '% constant' calcuation from the lookups. However it will increase code size (but not codepath) because of the number of callers.

Patch 13 removes part of the optimisation for 1 page tress under the assumption that the lookup will have been inlined. The code still works even if inlining didn't happen.

David Laight (13):
01/13: Fix potentially corrupt tree
02/13: Optimise out ilog2(variable).
03/13: Always use low 8 bits of 'root' for depth. 04/13: Optimise __genradix_ptr()
05/13: Optimise __genradix_ptr_alloc()
06/13: Rename gfp_mask to gfp to shorten lines. 07/13: Optimise __genradix_iter_peek()
08/13: Save number of bits to shift instead of tree level. 09/13: Check sizeof(_type) when defining a tree. 10/13: Simplify offset calculation:
11/13: Pass the root pointer to __genradix_ptr. 12/13: Inline genradix_ptr() for simple trees. 13/13: Simplify __genradix_ptr()

 include/linux/generic-radix-tree.h |  54 ++++---
 lib/generic-radix-tree.c           | 224 ++++++++++++++++-------------
 2 files changed, 162 insertions(+), 116 deletions(-)
Signature · 5 lines
2.25.1

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)