5eaa6f01f5
The code tracks a counter which is the number of events until the next sample. On context switch in, it loads the saved counter. On context switch out, it tries to calculate a new saved counter. Problems: 1. The saved counter was shared by all threads in a process. However, this means that all threads would be initially loaded with the same saved counter. However, that could result in sampling more often than once every X number of events. 2. The calculation to determine a new saved counter was backwards. It added when it should have subtracted, and subtracted when it should have added. Assume a single-threaded process with a reload count of 1000 events. Assuming the counter on context switch in was 100 and the counter on context switch out was 50 (meaning the thread has "consumed" 50 more events), the code would calculate a new saved counter of 150 (instead of the proper 50). Fix: 1. As soon as the saved counter is used to initialize a monitor for a thread on context switch in, set the saved counter to the reload count. That way, subsequent threads to use the saved counter will get the full reload count, assuring we sample at least once every X number of events (across all threads). 2. Change the calculation of the saved counter. Due to the change to the saved counter in #1, we simply need to add (modulo the reload count) the remaining counter time we retrieve from the CPU when a thread is context switched out. Differential Revision: https://reviews.freebsd.org/D4122 Approved by: gnn (mentor) MFC after: 1 month Sponsored by: Juniper Networks |
||
---|---|---|
.. | ||
hwpmc_amd.c | ||
hwpmc_amd.h | ||
hwpmc_arm64_md.c | ||
hwpmc_arm64.c | ||
hwpmc_arm64.h | ||
hwpmc_arm.c | ||
hwpmc_armv7.c | ||
hwpmc_armv7.h | ||
hwpmc_core.c | ||
hwpmc_core.h | ||
hwpmc_e500.c | ||
hwpmc_intel.c | ||
hwpmc_logging.c | ||
hwpmc_mips24k.c | ||
hwpmc_mips74k.c | ||
hwpmc_mips.c | ||
hwpmc_mod.c | ||
hwpmc_mpc7xxx.c | ||
hwpmc_octeon.c | ||
hwpmc_pentium.c | ||
hwpmc_pentium.h | ||
hwpmc_piv.c | ||
hwpmc_piv.h | ||
hwpmc_powerpc.c | ||
hwpmc_powerpc.h | ||
hwpmc_ppc970.c | ||
hwpmc_ppro.c | ||
hwpmc_ppro.h | ||
hwpmc_soft.c | ||
hwpmc_soft.h | ||
hwpmc_sparc64.c | ||
hwpmc_tsc.c | ||
hwpmc_tsc.h | ||
hwpmc_uncore.c | ||
hwpmc_uncore.h | ||
hwpmc_x86.c | ||
hwpmc_xscale.c | ||
hwpmc_xscale.h | ||
pmc_events.h |