Page MenuHomeFreeBSD

x86: simplify ceil(log2(x)) function
ClosedPublic

Authored by dougm on Tue, Jun 4, 5:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Jun 13, 7:26 PM
Unknown Object (File)
Sat, Jun 8, 11:47 AM
Unknown Object (File)
Fri, Jun 7, 1:05 AM
Unknown Object (File)
Thu, Jun 6, 6:43 PM
Unknown Object (File)
Wed, Jun 5, 2:50 PM
Unknown Object (File)
Wed, Jun 5, 1:50 PM
Unknown Object (File)
Tue, Jun 4, 6:13 PM
Subscribers

Details

Summary

A function called mask_width in one place and log2 in the other calculates its value in a more complex way than necessary. A simpler implementation offered here saves a few bytes in the functions that call it. 128 bytes in add_deterministic_cache, in particular.

Diff Detail

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

Event Timeline

dougm requested review of this revision.Tue, Jun 4, 5:10 PM

Looks good to me.
A bit ashamed that I could not figure that fls(x - 1) does the job if zero is handled as a special case.

This revision is now accepted and ready to land.Tue, Jun 4, 5:30 PM
alc added inline comments.
sys/amd64/vmm/x86.c
63–64

Update the comment?

This revision was automatically updated to reflect the committed changes.