Skip to contentSkip to conversation

Xen clocksource and PV shim

Xen-devel Igor Druzhinin 3 participants 4 messages Jan 30, 2020 – Jan 31, 2020

lore
Share & tools
lore
#0 lore raw

I was debugging constant freezes of PV shim on AMD hardware after going out of a long suspend. As it turned out the root cause of this is platform time jumping forward to the amount of time spent in suspended state. On Intel this issue is papered over by CONSTANT_TSC being set which avoids CPU time sync with platform time.

Upon further examination it appears that jumping is baked into the implementation of L0 Xen and there is no seemingly straight forward way to extract stable continuous rate out of what we have.

I expect this is a known issue with Xen PV clock as I found this almost immediately: https://wiki.debian.org/Xen/Clocksource
Currently I don't understand how in that case Xen clock source could be suitable as a platform timer for nested Xen.

Is my understanding of the situation correct? Could it be fixed in L0 Xen or it's already backed into the ABI? Should we keep Xen platform timer in the source code then? Does using alternative clock source for PV shim make sense?

Igor

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#1 lore raw
Quoted 17 lines · Igor Druzhinin

I was debugging constant freezes of PV shim on AMD hardware after going out of a long suspend. As it turned out the root cause of this is platform time jumping forward to the amount of time spent in suspended state. On Intel this issue is papered over by CONSTANT_TSC being set which avoids CPU time sync with platform time.

Upon further examination it appears that jumping is baked into the implementation of L0 Xen and there is no seemingly straight forward way to extract stable continuous rate out of what we have.

I expect this is a known issue with Xen PV clock as I found this almost immediately: https://wiki.debian.org/Xen/Clocksource
Currently I don't understand how in that case Xen clock source could be suitable as a platform timer for nested Xen.

Quoted 4 lines

Is my understanding of the situation correct? Could it be fixed in L0 Xen or it's already backed into the ABI? Should we keep Xen platform timer in the source code then? Does using alternative clock source for PV shim make sense?

... Ok, I seem to get lost in the weeds of timekeeping code - platform timer infrastructure is already prepared for this sort of scenario while exiting S3. I just need to call resume_platform_timer() from hypervisor_resume() or something similar. Patch will follow.

Although I'm still puzzled why Xen PV clock provides such an unintuitive data to the guest.

Igor

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 3 lines · Igor Druzhinin
Quoted 2 lines · Igor Druzhinin

I was debugging constant freezes of PV shim on AMD hardware after going out of a long suspend.

What is "suspend" here? S3? If so, ...

Quoted 21 lines
Quoted 16 lines

As it turned out the root cause
of this is platform time jumping forward to the amount of time spent in suspended state. On Intel this issue is papered over by CONSTANT_TSC being set which avoids CPU time sync with platform time.

Upon further examination it appears that jumping is baked into the implementation of L0 Xen and there is no seemingly straight forward way to extract stable continuous rate out of what we have.

I expect this is a known issue with Xen PV clock as I found this almost immediately: https://wiki.debian.org/Xen/Clocksource
Currently I don't understand how in that case Xen clock source could be suitable as a platform timer for nested Xen.

Quoted 4 lines

Is my understanding of the situation correct? Could it be fixed in L0 Xen or it's already backed into the ABI? Should we keep Xen platform timer in the source code then? Does using alternative clock source for PV shim make sense?

Quoted 4 lines

... Ok, I seem to get lost in the weeds of timekeeping code - platform timer infrastructure is already prepared for this sort of scenario while exiting S3. I just need to call resume_platform_timer() from hypervisor_resume() or something similar. Patch will follow.

... why would time_resume() not be called? Oh, pv_shim_shutdown() uses PV mechanisms to do the suspend/resume. I wonder what else, besides time_resume(), is missing there.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 32 lines · Jan Beulich
Quoted 3 lines · Igor Druzhinin
Quoted 2 lines · Igor Druzhinin

I was debugging constant freezes of PV shim on AMD hardware after going out of a long suspend.

What is "suspend" here? S3? If so, ...

Quoted 25 lines
Quoted 16 lines

As it turned out the root cause
of this is platform time jumping forward to the amount of time spent in suspended state. On Intel this issue is papered over by CONSTANT_TSC being set which avoids CPU time sync with platform time.

Upon further examination it appears that jumping is baked into the implementation of L0 Xen and there is no seemingly straight forward way to extract stable continuous rate out of what we have.

I expect this is a known issue with Xen PV clock as I found this almost immediately: https://wiki.debian.org/Xen/Clocksource
Currently I don't understand how in that case Xen clock source could be suitable as a platform timer for nested Xen.

Quoted 4 lines

Is my understanding of the situation correct? Could it be fixed in L0 Xen or it's already backed into the ABI? Should we keep Xen platform timer in the source code then? Does using alternative clock source for PV shim make sense?

... Ok, I seem to get lost in the weeds of timekeeping code - platform timer infrastructure is already prepared for this sort of scenario while exiting S3. I just need to call resume_platform_timer() from hypervisor_resume() or something similar. Patch will follow.

AFAICT you will also have to implement the resume hook for plt_xen_timer in order to reset last_value to 0 on resume.

Quoted 3 lines

... why would time_resume() not be called? Oh, pv_shim_shutdown() uses PV mechanisms to do the suspend/resume. I wonder what else, besides time_resume(), is missing there.

Not sure time_resume() is suitable as-is, it pokes at IO ports for PIT which are not implemented, and hence might need some massaging to work on a PVH environment.

I'm not sure there's a lot more that needs resuming, the state of emulated devices is preserved across suspend/resume, and the shim itself only uses event channels, grant tables and the timer PV interfaces, which are the ones that need resuming since state is not preserved for PV interfaces.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel