[phk@FreeBSD.org: Neat little, not so simple project...]
Profiling based optimization means better performance.
Here’s phk’s suggestion:
We can compile our kernel with "--test-coverage --profile-arcs" to do basic-block profiling (see kernbb(8) and gcov(1)/gcc(1) docs.)
Modify the code GCC inserts, so that it records if giant was held in one bit, and if not held in another, ie: if (giant) *counter_loc |= 1; else *counter_loc |= 2; Run your kernel for a few days. Use kernbb(8) to retrieve output. Produce graphics/statistics showing which code is Giant, which is giant free and which is mixed mode. Consider for instance the "xterm unreadable" font approach, and render the source files into pngs (a 800x660 png holds ten by ten standard pages without margins between) where you color the characters and lines by the result: black - not executed. red - executed with giant always yellow - executed with mixed giant holding green - never executed with giant. Brownie points: Get slashdotted when they discover you did it. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.