linux/Documentation/core-api
Yiwei Lin cd047867ee rbtree: Update augmented data on the way down in rb_add_augmented_cached()
rb_add_augmented_cached() links the new node and then calls
->propagate() from the parent up to the root to bring the augmented
data of the ancestors up to date.  It marks that as "suboptimal": every
augmented user that open-codes its insertion (interval trees, vmalloc,
drm_mm, gpu buddy, ...) instead folds the new node's value into each
ancestor while walking down, which touches no sibling and needs no
second pass.  ->propagate() has to read both children of every
ancestor until it finds one whose value did not change.

Add a ->merge() callback to struct rb_augment_callbacks that folds the
augmented data of a node being inserted into one of its future
ancestors, and use it on the descent.  RB_DECLARE_CALLBACKS() derives
it from the RB_AUG() list, so every user of the template gets it for
free, and sched/eevdf, the only caller of the helper, needs no change.

The new node's augmented data must describe the node alone before the
call.  That was already required, since ->propagate() read it, and
sched/eevdf sets it up that way.

Measured with rbtree_test's cached augmented test switched to
rb_add_augmented_cached() (next patch), nnodes cached insert+delete,
median of 5 runs, for reference also the open-coded descent used by
augmented test 1.  Raspberry Pi 4 Model B (Cortex-A72, 1.8 GHz), arch
timer ticks (54 MHz):

    nnodes    open-coded      before       after
       100           459         500         442  (-11.6%)
     10000        182046      186144      180208   (-3.2%)
    100000       5533679     5711647     5579444   (-2.3%)

x86-64 KVM guest (Intel i7-13800H), cycles:

    nnodes    open-coded      before       after
       100          7657        7622        7059   (-7.4%)
     10000       4738075     5075847     4627462   (-8.8%)
    100000      75618429    79840335    71324700  (-10.7%)

The other rbtree_test numbers are unchanged and the augmented invariant
checks still pass on both.

Signed-off-by: Yiwei Lin <s921975628@gmail.com>
Assisted-by: LLM
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20261005093236.62702-4-s921975628@gmail.com
2026-10-13 13:51:27 +02:00
..
irq Documentation: Add managed interrupts 2026-04-11 07:07:02 -06:00
kho kho: add support for linked-block serialization 2026-06-03 21:15:46 +03:00
real-time Documentation: Extend the real-time hardware bits with some firmware bits 2026-08-13 09:26:18 -06:00
wrappers
asm-annotations.rst
assoc_array.rst Documentation: assoc_array: Format internal tree layout tables 2025-10-17 14:23:04 -06:00
boot-time-mm.rst
cachetlb.rst
cgroup.rst doc/cgroup: Fix title underline length 2025-01-15 09:46:18 +01:00
circular-buffers.rst
cleanup.rst cleanup: Add usage and style documentation 2024-08-05 16:54:41 +02:00
cpu_hotplug.rst Documentation: core-api/cpu_hotplug: Remove stale cpu0_hotplug docs 2026-05-15 08:44:24 -06:00
debug-objects.rst
debugging-via-ohci1394.rst
dma-api-howto.rst docs: dma-api: document __dma_from_device_group_begin()/end() 2025-12-31 19:28:12 -05:00
dma-api.rst docs: dma-api: remove needless bracket 2026-07-15 10:51:28 -06:00
dma-attributes.rst dma-mapping: Add internal shared allocation attribute 2026-07-31 08:40:58 +02:00
dma-isa-lpc.rst
entry.rst entry, treewide: Make syscall_enter_from_user_mode[_work]() indicate syscall execution 2026-07-20 20:38:40 +02:00
errseq.rst errseq: add missing bracket 2026-07-15 10:51:28 -06:00
floating-point.rst arch: add ARCH_HAS_KERNEL_FPU_SUPPORT 2024-05-19 14:36:17 -07:00
folio_queue.rst docs: folio_queue: Fix minor typo in folio_queue page 2025-08-12 12:40:15 -06:00
genalloc.rst
generic-radix-tree.rst
genericirq.rst treewide: Update email address 2026-01-11 06:09:11 -10:00
gfp_mask-from-fs-io.rst docs: core-api/gfp_mask-from-fs-io: indicate that vmalloc supports GFP_NOFS/GFP_NOIO 2024-11-22 10:42:37 -07:00
housekeeping.rst docs: housekeeping: Fix struct member access in code example 2026-05-15 08:25:16 -06:00
idr.rst
index.rst Docs: SMP: add an SMP docbook chapter 2026-07-15 10:51:27 -06:00
kernel-api.rst block: Include bvec.h kernel-doc in the htmldocs 2026-05-29 05:34:25 -06:00
kobject.rst docs: Update documentation to avoid mentioning of kernel.h 2025-12-22 14:59:18 -07:00
kref.rst Documentation: adopt new coding style of type-aware kmalloc-family 2026-05-03 08:54:21 -06:00
librs.rst treewide: Update email address 2026-01-11 06:09:11 -10:00
list.rst Docs: list: Fix bracket 2026-07-15 10:51:27 -06:00
liveupdate.rst liveupdate: luo_flb: introduce File-Lifecycle-Bound global state 2026-02-08 00:13:33 -08:00
local_ops.rst
maple_tree.rst maple_tree: document erase and allocations better 2026-08-24 18:43:31 -07:00
memory-allocation.rst docs/core-api: memory-allocation: GFP_NOWAIT doesn't need __GFP_NOWARN 2024-07-29 15:10:25 -06:00
memory-hotplug.rst docs: memory-hotplug: fix typo 'fo' -> 'for' in NODE_ADDED_FIRST_MEMORY description 2026-03-17 08:42:05 -06:00
min_heap.rst Documentation/core-api: min_heap: remove documented but unimplemented min_heap_empty() 2026-07-22 10:24:49 -06:00
mm-api.rst mm: rename swap.c to folio.c 2026-08-04 19:18:35 -07:00
netlink.rst
packing.rst docs: packing: fix brackets 2026-07-15 10:51:27 -06:00
padata.rst
parser.rst Documentation: core-api: add generic parser docbook 2024-12-11 09:07:40 -07:00
pin_user_pages.rst mm: remove page_mkclean() 2024-07-03 19:30:17 -07:00
printk-basics.rst Documentation: printk: Add section about avoiding lockups 2026-03-17 08:37:49 -06:00
printk-formats.rst vsprintf: Add upper case flavour to %p[mM] 2026-06-12 14:20:25 +02:00
printk-index.rst docs:core-api: fixed typos and grammar in printk-index page 2024-05-07 08:01:11 -06:00
protection-keys.rst Documentation/protection-keys: add AArch64 to documentation 2024-10-14 17:27:48 +01:00
rbtree.rst rbtree: Update augmented data on the way down in rb_add_augmented_cached() 2026-10-13 13:51:27 +02:00
refcount-vs-atomic.rst refcount: provide ops for cases when object's memory can be reused 2025-03-16 22:06:19 -07:00
SMP.rst Docs: SMP: add an SMP docbook chapter 2026-07-15 10:51:27 -06:00
swiotlb.rst dma/swiotlb: introduce Kconfig option for compile-time default pool size 2026-07-17 09:15:38 +02:00
symbol-namespaces.rst docs: symbol-namespaces: mention sysfs attribute 2026-03-19 22:49:37 +00:00
this_cpu_ops.rst docs: Improve discussion of this_cpu_ptr(), add raw_cpu_ptr() 2025-02-04 21:50:06 -08:00
timekeeping.rst
tracepoint.rst
unaligned-memory-access.rst move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
union_find.rst Documentation: Fix the compilation errors in union_find.rst 2024-08-02 08:58:16 -10:00
watch_queue.rst
workqueue.rst docs: workqueue: Fix bracket 2026-07-09 10:55:59 -10:00
xarray.rst xarray: add xas_try_split() to split a multi-index entry 2025-03-17 22:06:59 -07:00