In older versions of Xemn, each DomU could effectively use the system time of the Dom0. That was remove after Xen 4 or so. In versions after that issues of clock drift need to be addressed. I was investigating this and came across a discussion of best practices about setting the Limux clocksource on DomU’s. It seems there has been some performance issues with using “xen” and a recommendation to use “tsc” but it’s not entirely straightforward.
- Xen 4.2 TSC_MODE HOW-TO
- gives this handy code: xm debug-key s; xm dmesg | tail
- which I improved as: sudo xl debug-key s; sudo xl dmesg | grep mode=
- (CMP402) Amazon EC2 Instances Deep Dive (2015)
- recommends “TSC as clocksource”
- Performance Tuning EC2 Instances (2014)
- recommends “tuning clocksource to TSC”
- Two frequently used system calls are ~77% slower on AWS EC2 (2017)
- raises concerns about unexpected backward clock drift
- Running a database on EC2? Your clock could be slowing you down. (2018)
- helpful for getting Xen hypervisor version from inside guest: sudo dmesg | grep -i ‘xen version’
- testing for clocksource acceleration: strace -e gettimeofday,clock_gettime — date >/dev/null
- getting current clocksource: cat /sys/devices/system/clocksource/clocksource0/current_clocksource
- setting clocksource to tsc: echo tsc | sudo tee /sys/devices/system/clocksource/clocksource0/current_clocksource
- How do I manage the clock source for EC2 instances running Linux? (2020)
- “For EC2 instances launched on the AWS Xen Hypervisor, it’s a best practice to use the tsc clock source. Other EC2 instance types, such as C5 or M5, use the AWS Nitro Hypervisor. The recommended clock source for the AWS Nitro Hypervisor is kvm-clock.”
- recommends setting GRUB_CMDLINE_LINUX in grub2: “clocksource=tsc tsc=reliable”