diff options
author | Patrick Williams <iawillia@us.ibm.com> | 2014-02-20 11:49:55 -0600 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2014-02-27 11:38:15 -0600 |
commit | 0f33e04d51a9ad3e37fa40db8970f166ff84432e (patch) | |
tree | ad8e757df37d05f6697e8b43439e25dfde8a09a8 /src/kernel/timemgr.C | |
parent | c114092812658e8bd4006e260befae121a0d48ab (diff) | |
download | talos-hostboot-0f33e04d51a9ad3e37fa40db8970f166ff84432e.tar.gz talos-hostboot-0f33e04d51a9ad3e37fa40db8970f166ff84432e.zip |
Ensure small sleeps are accurate through a context switch.
Change-Id: Ie4efdf83d3baee1526f786a78118022baa67a73a
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/9052
Tested-by: Jenkins Server
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/kernel/timemgr.C')
-rw-r--r-- | src/kernel/timemgr.C | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/kernel/timemgr.C b/src/kernel/timemgr.C index 39cb4b807..37d258029 100644 --- a/src/kernel/timemgr.C +++ b/src/kernel/timemgr.C @@ -26,6 +26,8 @@ #include <kernel/task.H> #include <kernel/cpumgr.H> #include <util/misc.H> +#include <kernel/misc.H> +#include <sys/task.h> uint64_t TimeManager::iv_timebaseFreq = 0xFFFFFFFF; @@ -154,6 +156,17 @@ bool TimeManager::simpleDelay(uint64_t i_sec, uint64_t i_nsec) uint64_t threshold = getTimeSliceCount()/YIELD_THRESHOLD_PER_SLICE; uint64_t delay = convertSecToTicks(i_sec, i_nsec); + bool isUserspace = !KernelMisc::in_kernel_mode(); + + // TB is not synchronized between cores, so if we're doing a poll we need + // to pin the task to the current cpu. Otherwise the getTB can get a + // drifted answer after a task migration. + if (isUserspace) + { + task_affinity_pin(); + } + + // Do polling delay. if(delay < threshold) { uint64_t expire = getCurrentTimeBase() + delay; @@ -165,6 +178,11 @@ bool TimeManager::simpleDelay(uint64_t i_sec, uint64_t i_nsec) result = true; } + if (isUserspace) + { + task_affinity_unpin(); + } + return result; } |