Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time behaves funny #55

Open
trasz opened this issue Oct 5, 2017 · 2 comments
Open

Time behaves funny #55

trasz opened this issue Oct 5, 2017 · 2 comments
Labels

Comments

@trasz
Copy link
Contributor

trasz commented Oct 5, 2017

Sometimes - I'm not sure what it depends on, it kind of seems to occur on a freshly booted system, I can observe this:

root@qemu-cheri256-en322:~ # openssl speed          
Doing mdc2 for 3s on 16 size blocks: 261185 mdc2's in 17.26s                                            
Doing mdc2 for 3s on 64 size blocks: 73792 mdc2's in 22.44s                                             
Doing mdc2 for 3s on 256 size blocks: 21042 mdc2's in 22.23s                                            
Doing mdc2 for 3s on 1024 size blocks: 627 mdc2's in 1.63s                                              
Doing mdc2 for 3s on 8192 size blocks: 80 mdc2's in 1.79s                                               
Doing md4 for 3s on 16 size blocks: 93682 md4's in 1.75s                                                
Doing md4 for 3s on 64 size blocks: 75587 md4's in 1.76s                                                
Doing md4 for 3s on 256 size blocks: 57932 md4's in 1.92s
Doing md4 for 3s on 1024 size blocks: 27391 md4's in 1.87s
Doing md4 for 3s on 8192 size blocks: 35787 md4's in 22.10s
Doing md5 for 3s on 16 size blocks: 74512 md5's in 1.98s

At the same time in another terminal:

# while :; do date; sleep 10; done                  
Thu Jan  1 00:01:12 UTC 1970                        
Thu Jan  1 00:01:43 UTC 1970                        
Thu Jan  1 00:02:06 UTC 1970                        
Thu Jan  1 00:02:30 UTC 1970                        
Thu Jan  1 00:02:40 UTC 1970                        
Thu Jan  1 00:03:10 UTC 1970                        
Thu Jan  1 00:03:20 UTC 1970     

Also this, there was about 10 seconds between invocations; observe how clock0 has rate 566, but the actual value doesn't change at all:

# vmstat -i                                         
interrupt                          total       rate 
int0 pcib0                          2605         12 
int5 clock0                       118852        566 
Total                             121457        579 
# vmstat -i                                         
interrupt                          total       rate 
int0 pcib0                          2612         12 
int5 clock0                       118852        567 
Total                             121464        580 
@trasz trasz added the bug label Oct 5, 2017
@trasz trasz mentioned this issue Oct 10, 2017
@trasz
Copy link
Contributor Author

trasz commented Oct 10, 2017

Looks like it's caused by b79c3d9.

trasz referenced this issue Oct 10, 2017
The MIPS Count register is incremented every 2 cycles, not every
cycle (according to sys/mips/include/clock.h).

Also, instead of using muldiv64() to convert from ticks to nanoseconds:
	y = muldiv64(x, get_ticks_per_sec(), TIMER_FREQ)
where y = number of system ticks and x = device ticks we can just do:
	y = x * 10ns (for 100Mhz clock)
@trasz
Copy link
Contributor Author

trasz commented Oct 12, 2017

A plausible explanation (proposed by Alex) is that the Qemu timer interrupt fires from the host's virtual timer, and thus its frequency depends on how much host CPU time the qemu process is using at the moment. At the same time the Counter CP0 register is updated from the host's monotonic clock (a wallclock), so the guest time keeps being updated correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant