Page MenuHomeFreeBSD

random: Define a macro for getting the CPU cycle count
ClosedPublic

Authored by markj on Jul 1 2025, 3:35 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 10, 11:51 PM
Unknown Object (File)
Fri, Oct 10, 11:51 PM
Unknown Object (File)
Fri, Oct 10, 11:51 PM
Unknown Object (File)
Fri, Oct 10, 11:51 PM
Unknown Object (File)
Fri, Oct 10, 5:26 PM
Unknown Object (File)
Fri, Oct 10, 2:54 AM
Unknown Object (File)
Fri, Oct 3, 3:00 PM
Unknown Object (File)
Fri, Oct 3, 1:47 AM
Subscribers

Details

Summary

Entropy queue entries always include the low 32 bits of a CPU cycle
count reading. Introduce a macro for this instead of hard-coding
get_cyclecount() calls everywhere; this is handy for testing purposes
since this way, random(4)'s use of the cycle counter (e.g., the number
of bits we use) can be changed in one place.

No functional change intended.

Diff Detail

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

Event Timeline

markj requested review of this revision.Jul 1 2025, 3:35 PM

lgtm otherwise

sys/dev/random/random_harvestq.h
46–47

Could this just be an inline function instead of a macro?

markj marked an inline comment as done.Jul 1 2025, 4:00 PM
markj added inline comments.
sys/dev/random/random_harvestq.h
46–47

It could, I didn't do it that way since it would require pulling in machine/cpu.h whereas only two files actually need the macro. But, random_harvestq.h isn't widely included anyway, so it should be fine to have it be a function.

markj marked an inline comment as done.

Switch to using a function. (Will update the commit message too.)

This revision is now accepted and ready to land.Jul 1 2025, 4:14 PM