HomeFreeBSD

rb_tree: avoid extra reads in rebalancing

Description

rb_tree: avoid extra reads in rebalancing

In RB_INSERT_COLOR and RB_REMOVE_COLOR, avoid reading a parent pointer
from memory, and then reading the left-color bit from memory, and then
reading the right-color bit from memory, since they're all in the same
field. The compiler can't infer that only the first read is really
necessary, so write the code in a way so that it doesn't have to.

Drop RB_RED_LEFT and RB_RED_RIGHT macros that reach into memory to get
those bits. Drop RB_COLOR, the only thing left using RB_RED_LEFT and
RB_RED_RIGHT after the other changes, and go straight to DIAGNOSTIC
code in subr_stats to implement RB_COLOR for its single, dubious use
there.

Reviewed by: alc
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D36353

(cherry picked from commit 5d91386826d0f360d87ce3f39c9ebf266f149325)

Details

Provenance
dougmAuthored on Aug 29 2022, 4:11 PM
Reviewer
alc
Differential Revision
D36353: rb_tree: avoid extra reads in rebalancing
Parents
rG5830e7391d9f: nfscl: Allow "nolockd" to work for NFSv4 mounts
Branches
Unknown
Tags
Unknown