Commit d9ab2481 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Aichun Shi
Browse files

rbtree: Add generic add and find helpers

mainline inclusion
from mainline-v5.12-rc1
commit 2d24dd57
category: feature
feature: SPR PMU uncore support
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I5BECO



Intel-SIG: commit 2d24dd57 rbtree: Add generic add and find helpers
This commit is backported as a dependency for SPR PMU uncore support.

-------------------------------------

I've always been bothered by the endless (fragile) boilerplate for
rbtree, and I recently wrote some rbtree helpers for objtool and
figured I should lift them into the kernel and use them more widely.

Provide:

partial-order; less() based:
 - rb_add(): add a new entry to the rbtree
 - rb_add_cached(): like rb_add(), but for a rb_root_cached

total-order; cmp() based:
 - rb_find(): find an entry in an rbtree
 - rb_find_add(): find an entry, and add if not found

 - rb_find_first(): find the first (leftmost) matching entry
 - rb_next_match(): continue from rb_find_first()
 - rb_for_each(): iterate a sub-tree using the previous two

Inlining and constant propagation should see the compiler inline the
whole thing, including the various compare functions.

Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Reviewed-by: default avatarMichel Lespinasse <walken@google.com>
Acked-by: default avatarDavidlohr Bueso <dbueso@suse.de>
Signed-off-by: default avatarYunying Sun <yunying.sun@intel.com>
Signed-off-by: default avatarAichun Shi <aichun.shi@intel.com>
parent 4821226b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment