1
+ extern crate chrono;
1
2
extern crate epoll;
2
3
extern crate futures;
3
4
extern crate libc;
@@ -9,6 +10,7 @@ extern crate timerfd;
9
10
10
11
extern crate data_model;
11
12
extern crate devices;
13
+ extern crate fc_util;
12
14
extern crate kernel;
13
15
extern crate kvm;
14
16
#[ macro_use]
@@ -50,6 +52,7 @@ use device_manager::legacy::LegacyDeviceManager;
50
52
use device_manager:: mmio:: MMIODeviceManager ;
51
53
use devices:: virtio;
52
54
use devices:: { DeviceEventT , EpollHandler , EpollHandlerPayload } ;
55
+ use fc_util:: now_cputime_us;
53
56
use kernel:: cmdline as kernel_cmdline;
54
57
use kernel:: loader as kernel_loader;
55
58
use kvm:: * ;
@@ -71,6 +74,7 @@ const DEFAULT_KERNEL_CMDLINE: &str = "reboot=k panic=1 pci=off nomodules 8250.nr
71
74
const VCPU_RTSIG_OFFSET : i32 = 0 ;
72
75
const WRITE_METRICS_PERIOD_SECONDS : u64 = 60 ;
73
76
static START_INSTANCE_REQUEST_TS : AtomicUsize = ATOMIC_USIZE_INIT ;
77
+ static START_INSTANCE_REQUEST_CPU_TS : AtomicUsize = ATOMIC_USIZE_INIT ;
74
78
75
79
/// Errors associated with the VMM internal logic. These errors cannot be generated by direct user
76
80
/// input, but can result from bad configuration of the host (for example if Firecracker doesn't
@@ -807,12 +811,22 @@ impl Vmm {
807
811
if addr == MAGIC_IOPORT_SIGNAL_GUEST_BOOT_COMPLETE
808
812
&& data[ 0 ] == MAGIC_VALUE_SIGNAL_GUEST_BOOT_COMPLETE
809
813
{
810
- let boot_time_ns = time:: precise_time_ns ( ) as usize
814
+ let now_cpu_us = now_cputime_us ( ) ;
815
+ let now_us =
816
+ chrono:: Utc :: now ( ) . timestamp_nanos ( ) / 1000 ;
817
+
818
+ let boot_time_us = now_us as usize
811
819
- START_INSTANCE_REQUEST_TS . load ( Ordering :: Acquire ) ;
820
+ let boot_time_cpu_us = now_cpu_us as usize
821
+ - START_INSTANCE_REQUEST_CPU_TS
822
+ . load ( Ordering :: Acquire ) ;
812
823
warn ! (
813
- "Guest-boot-time = {:>6} us {} ms" ,
814
- boot_time_ns / 1000 ,
815
- boot_time_ns / 1000000
824
+ "Guest-boot-time = {:>6} us {} ms, \
825
+ {:>6} CPU us {} CPU ms",
826
+ boot_time_us,
827
+ boot_time_us / 1000 ,
828
+ boot_time_cpu_us,
829
+ boot_time_cpu_us / 1000
816
830
) ;
817
831
}
818
832
io_bus. write ( addr as u64 , data) ;
@@ -955,7 +969,11 @@ impl Vmm {
955
969
}
956
970
957
971
fn start_microvm ( & mut self ) -> std:: result:: Result < VmmData , VmmActionError > {
958
- START_INSTANCE_REQUEST_TS . store ( time:: precise_time_ns ( ) as usize , Ordering :: Release ) ;
972
+ START_INSTANCE_REQUEST_CPU_TS . store ( now_cputime_us ( ) as usize , Ordering :: Release ) ;
973
+ START_INSTANCE_REQUEST_TS . store (
974
+ ( chrono:: Utc :: now ( ) . timestamp_nanos ( ) / 1000 ) as usize ,
975
+ Ordering :: Release ,
976
+ ) ;
959
977
info ! ( "VMM received instance start command" ) ;
960
978
if self . is_instance_initialized ( ) {
961
979
return Err ( VmmActionError :: StartMicrovm (
0 commit comments