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)
Tue, Apr 23, 12:13 AM
Unknown Object (File)
Jan 9 2024, 4:53 PM
Unknown Object (File)
Dec 23 2023, 2:44 AM
Unknown Object (File)
Dec 12 2023, 9:20 AM
Unknown Object (File)
Nov 15 2023, 11:47 PM
Unknown Object (File)
Aug 16 2023, 4:57 AM
Unknown Object (File)
Aug 16 2023, 4:22 AM
Unknown Object (File)
Jul 31 2023, 9:36 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

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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.