1+ extern crate chrono;
12extern crate epoll;
23extern crate futures;
34extern crate libc;
@@ -9,6 +10,7 @@ extern crate timerfd;
910
1011extern crate data_model;
1112extern crate devices;
13+ extern crate fc_util;
1214extern crate kernel;
1315extern crate kvm;
1416#[ macro_use]
@@ -50,6 +52,7 @@ use device_manager::legacy::LegacyDeviceManager;
5052use device_manager:: mmio:: MMIODeviceManager ;
5153use devices:: virtio;
5254use devices:: { DeviceEventT , EpollHandler , EpollHandlerPayload } ;
55+ use fc_util:: now_cputime_us;
5356use kernel:: cmdline as kernel_cmdline;
5457use kernel:: loader as kernel_loader;
5558use kvm:: * ;
@@ -71,6 +74,7 @@ const DEFAULT_KERNEL_CMDLINE: &str = "reboot=k panic=1 pci=off nomodules 8250.nr
7174const VCPU_RTSIG_OFFSET : i32 = 0 ;
7275const WRITE_METRICS_PERIOD_SECONDS : u64 = 60 ;
7376static START_INSTANCE_REQUEST_TS : AtomicUsize = ATOMIC_USIZE_INIT ;
77+ static START_INSTANCE_REQUEST_CPU_TS : AtomicUsize = ATOMIC_USIZE_INIT ;
7478
7579/// Errors associated with the VMM internal logic. These errors cannot be generated by direct user
7680/// input, but can result from bad configuration of the host (for example if Firecracker doesn't
@@ -807,12 +811,22 @@ impl Vmm {
807811 if addr == MAGIC_IOPORT_SIGNAL_GUEST_BOOT_COMPLETE
808812 && data[ 0 ] == MAGIC_VALUE_SIGNAL_GUEST_BOOT_COMPLETE
809813 {
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
811819 - 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 ) ;
812823 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
816830 ) ;
817831 }
818832 io_bus. write ( addr as u64 , data) ;
@@ -955,7 +969,11 @@ impl Vmm {
955969 }
956970
957971 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+ ) ;
959977 info ! ( "VMM received instance start command" ) ;
960978 if self . is_instance_initialized ( ) {
961979 return Err ( VmmActionError :: StartMicrovm (
0 commit comments