Page MenuHomeFreeBSD

smp: Use bitwise operation to count cpu number
ClosedPublic

Authored by aokblast on Jan 3 2026, 4:37 PM.
Tags
None
Referenced Files
F146329244: D54474.id172137.diff
Sun, Mar 1, 7:26 PM
Unknown Object (File)
Sat, Feb 28, 6:55 PM
Unknown Object (File)
Mon, Feb 9, 6:22 PM
Unknown Object (File)
Jan 20 2026, 6:34 PM
Unknown Object (File)
Jan 20 2026, 6:31 PM
Unknown Object (File)
Jan 20 2026, 1:01 PM
Unknown Object (File)
Jan 18 2026, 5:04 PM
Unknown Object (File)
Jan 15 2026, 1:49 AM
Subscribers

Details

Summary

Previously, we iterated over all CPUs using CPU_FOREACH and checked
individual bits to count valid CPUs. Refactor this to use a bitwise AND
and popcount to count the number of enabled bits directly.

Diff Detail

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

Event Timeline

This revision is now accepted and ready to land.Jan 3 2026, 4:40 PM

Thanks! Thought I sucessfully booted up on a AMD64 machine, this patch touches the basic logic of smp so I will think twice before landing it.

Thanks! Thought I sucessfully booted up on a AMD64 machine, this patch touches the basic logic of smp so I will think twice before landing it.

It's probably ok, but yes it's a good idea to keep patches in a local tree that you test often. Then you can build some confidence in the changes before landing them.