Cobalt Preemption of kernel update_fast_timekeeper can cause deadlocks

Lange Norbert norbert.lange at
Wed Dec 19 11:20:35 CET 2018

There is a deadlock issue that haunted me for several weeks,
it is caused by the kernels update of the user-visible
timekeeping structures used by the VDSO clock_gettime functions.

The kernel regularly updates a Timestamp structure, which is accessible in user-mode,
it does so by something akin to a rw-lock in update_fast_timekeeper.

If cobalt preempts the core during holding the lock, any thread trying to read the time
will continue to spin. (This alone is an issue IMHO).
If the cobalt thread itself now call the vDSO function as reader,
it will spin on the lock and block the lock from getting released.

Either the update_fast_timekeeper funtion should not be preemptible by cobalt,
or the spin-lock on reading could fallback to the syscall after a certain amount of retries.

The later is probably easier to implement, but then could randomly demote cobalt threads.
(on the other hand, this would be always a demotion on platforms without the vdso function)

Mit besten Grüßen / Kind regards


Eibesbrunnergasse 20
1120 Vienna / AUSTRIA
p: +43 50805 56684
norbert.lange at

This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system.


Rechtsform/ Legal form: Gesellschaft mit beschränkter Haftung / Corporation

Firmensitz/ Registered seat: Wien

Firmenbuchgericht/ Court of registry: Handelsgericht Wien

Firmenbuchnummer/ Company registration: FN 61833 g

DVR: 0605077

UID-Nr.: ATU14756806

Thank You

More information about the Xenomai mailing list