id summary reporter owner description type status priority component version resolution keywords cc guest host
7915 Mircosecond timer returns value from the past sethbollinger "We're running a ubuntu 10.04 (2.6.32-27-generic) guest on a ubuntu 10.10 (2.6.35-22-server) server using VirtualBox 4.0 (or 3.2.8). If I enable 2 virtual CPUs on the guest, every once in a while the timer will tick backwards by ~4-60 microseconds. If I allocate 1 virtual CPU instead of 2, this problem seems to happen much less often. I have tried a bunch of different things having to do with timer migration, disabling tickless support, and specifying the timer to use on the kernel load line. The only thing that seems to work is using jiffies for the counter, which limits you to HZ resolution (which would be a good reason from a microsecond resolution problem to go away :)).
I've looked through the timer get code in VMM/VMMAll/TMAllCpu.cpp, but it looks like returning a TSC value in the past is protected against so I don't understand how it's happening. My only guess is that somehow the timer value is set to a time in the past so the last seen protection on the get isn't working, but I don't have any proof.
I will try to gather some data using system tap next week. If there's any other data I can gather, please let me know. I see that it looks like some stats are logged when these time conditions occur, but I don't know how to capture them. I would be happy to capture them if someone would point me to a webpage that explains how.
Here's python and C code to recreate the issue on the guest:
#######################################
import time
print(""Start time => %s"" % time.ctime())
while True:
t = time.time()
c = time.time()
if c < t:
print(""ERROR:\nCURR => %f\nLAST => %f"" % (c, t))
break
print(""End time => %s"" % time.ctime())
#######################################
#include
#include
int main()
{
struct timeval last, curr;
while(1)
{
gettimeofday(&last, 0);
gettimeofday(&curr, 0);
if ((last.tv_sec == curr.tv_sec) && (curr.tv_usec < last.tv_usec))
{
printf(""ERROR:\nCURR => %d\nLAST => %d"", curr.tv_usec, last.tv_usec);
break;
}
}
}
#######################################
" defect closed major other VirtualBox 4.0.0 fixed other other