Page MenuHomeFreeBSD

radix_tree: compute slot from keybarr
ClosedPublic

Authored by dougm on Jul 30 2023, 7:12 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 24, 3:17 PM
Unknown Object (File)
Nov 8 2025, 8:30 PM
Unknown Object (File)
Nov 8 2025, 4:30 PM
Unknown Object (File)
Nov 8 2025, 4:30 PM
Unknown Object (File)
Nov 8 2025, 12:20 PM
Unknown Object (File)
Nov 8 2025, 3:33 AM
Unknown Object (File)
Nov 7 2025, 2:40 AM
Unknown Object (File)
Nov 3 2025, 11:38 PM
Subscribers

Details

Summary

The computation of keybarr(), the function that determines when a search has failed at a non-leaf node, can be done in a way that computes the 'slot' value when keybarr() fails, which is exactly when slot() would next be invoked. Computing things this way saves space in search loops.

From vm_radix_lookup, the amd64 assembly for the search loop before (40 bytes):

2c0: 0f b6 48 0a                  	movzbl	10(%rax), %ecx
2c4: 48 c7 c2 f0 ff ff ff         	movq	$-16, %rdx
2cb: 48 d3 e2                     	shlq	%cl, %rdx
2ce: 48 21 f2                     	andq	%rsi, %rdx
2d1: 48 3b 10                     	cmpq	(%rax), %rdx
2d4: 75 1e                        	jne	0x2f4 <vm_radix_lookup+0x44>
2d6: 48 89 f2                     	movq	%rsi, %rdx
2d9: 48 d3 ea                     	shrq	%cl, %rdx
2dc: 83 e2 0f                     	andl	$15, %edx
2df: 48 8b 44 d0 10               	movq	16(%rax,%rdx,8), %rax
2e4: a8 01                        	testb	$1, %al
2e6: 74 d8                        	je	0x2c0 <vm_radix_lookup+0x10>

and after (28 bytes):

2b0: 48 89 f2                     	movq	%rsi, %rdx
2b3: 48 2b 10                     	subq	(%rax), %rdx
2b6: 0f b6 48 0a                  	movzbl	10(%rax), %ecx
2ba: 48 d3 ea                     	shrq	%cl, %rdx
2bd: 48 83 fa 0f                  	cmpq	$15, %rdx
2c1: 77 15                        	ja	0x2d8 <vm_radix_lookup+0x38>
2c3: 48 8b 44 d0 10               	movq	16(%rax,%rdx,8), %rax
2c8: a8 01                        	testb	$1, %al
2ca: 74 e4                        	je	0x2b0 <vm_radix_lookup+0x10>
Test Plan

Kernel built, and boots.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

dougm requested review of this revision.Jul 30 2023, 7:12 AM
dougm created this revision.
This revision is now accepted and ready to land.Jul 30 2023, 7:26 PM
This revision was automatically updated to reflect the committed changes.