For some time I've suffered from the infamous clocksource problem with all Linux hosts that aren't running the Citrix provided kernels. I'm bit old fashioned and I want to run Debian provided kernels instead the Citrix ones, mostly because the Debian kernel receives security updates.
During the fight with my own server last night, it finally dawned to me.
The clocksource problem appears after you suspend a Linux host and the kernel in the virtual machine starts spewing this:
Mar 5 09:24:17 co kernel: [461562.007153] clocksource/0: Time went backwards: ret=f03d318c7db9 delta=-200458290723043 shadow=f03d1d566f4a offset=143675d9
I've been trying to figure out what is different with Citrix and Debian kernels, because the problem doesn't occur with the Citrix provided kernel.
The final hint to solving this problem came from Debian wiki. The same issue is mentioned there, but the workaround is not something I like. I perfer making sure that the host server has the correct time and the virtual machine just follows that time.
But the real clue was the clocksource line. It turns out that the Citrix kernel uses jiffies as the clocksource per default, while Debian uses the xen clocksource. It would make sense that the xen clocksource is more accurate since it's native to the hypervisor.
So by just running this on the domU fixes the problem:
echo "jiffies"> /sys/devices/system/clocksource/clocksource0/current_clocksource
There is no need to decouple the clock from the host, which is
exactly what I needed. To make this change permanent, you need to
clocksource=jiffies to the bootparameters of your
You can do this by modifying grub configuration and adding
clocksource=jiffies to the kopt line and running
update-grub. Or you can use XenCenter and modify the virtual
machine parameters and
clocksource=jiffies to boot
It's also worth noting that this problem does apply to plain vanilla Debian installations as well, so reading that whole wiki page is a good idea.