Page MenuHomeFreeBSD

smp: Use bitwise operation to count cpu number
AcceptedPublic

Authored by aokblast on Jan 3 2026, 4:37 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Jan 20, 6:34 PM
Unknown Object (File)
Tue, Jan 20, 6:31 PM
Unknown Object (File)
Tue, Jan 20, 1:01 PM
Unknown Object (File)
Sun, Jan 18, 5:04 PM
Unknown Object (File)
Thu, Jan 15, 1:49 AM
Unknown Object (File)
Tue, Jan 13, 1:45 PM
Unknown Object (File)
Sat, Jan 10, 8:34 PM
Unknown Object (File)
Sat, Jan 10, 5:09 AM
Subscribers

Details

Reviewers
markj
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 Passed
Unit
No Test Coverage
Build Status
Buildable 69589
Build 66472: arc lint + arc unit

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.