Skip to contentSkip to conversation

Scheduling and the periodic timer

DISCUSSION Juergen Gross 4 participants 6 messages Feb 1, 2019 – Feb 4, 2019 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

While working on my core scheduling series I stumbled over the periodic timer. Could it be this timer never worked correctly?

When the vcpu with an active periodic timer is running everything seems to be fine. But when not running the timer is stopped in schedule(). So a vcpu going to idle relying to be woken up by the periodic timer will remain sleeping until another event is happening. The periodic timer won't fire as it is stopped.

The periodic timer is used via VCPUOP_set_periodic_timer only, and today's Linux kernel isn't using it at all. So I guess this timer not really working as it should is no big issue.

I just wanted to mention that fact, maybe someone is keen repairing this issue.

Juergen

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

#1 lore raw
Quoted 9 lines · Juergen Gross

While working on my core scheduling series I stumbled over the periodic timer. Could it be this timer never worked correctly?

When the vcpu with an active periodic timer is running everything seems to be fine. But when not running the timer is stopped in schedule(). So a vcpu going to idle relying to be woken up by the periodic timer will remain sleeping until another event is happening. The periodic timer won't fire as it is stopped.

Quoted 6 lines

The periodic timer is used via VCPUOP_set_periodic_timer only, and today's Linux kernel isn't using it at all. So I guess this timer not really working as it should is no big issue.

I just wanted to mention that fact, maybe someone is keen repairing this issue.

Do you mean to say that, after the next schedule(), any configured periodic timer ceases to provide further interrupts?

~Andrew

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

#2 lore raw
Quoted 14 lines · Andrew Cooper
Quoted 13 lines · Juergen Gross

While working on my core scheduling series I stumbled over the periodic timer. Could it be this timer never worked correctly?

When the vcpu with an active periodic timer is running everything seems to be fine. But when not running the timer is stopped in schedule(). So a vcpu going to idle relying to be woken up by the periodic timer will remain sleeping until another event is happening. The periodic timer won't fire as it is stopped.

The periodic timer is used via VCPUOP_set_periodic_timer only, and today's Linux kernel isn't using it at all. So I guess this timer not really working as it should is no big issue.

Quoted 5 lines
Quoted 2 lines

I just wanted to mention that fact, maybe someone is keen repairing this issue.

Do you mean to say that, after the next schedule(), any configured periodic timer ceases to provide further interrupts?

No, it just won't wake the vcpu up. As soon as the vcpu is running the timer will run again and it will provide interrupts again. In case an interrupt was due during the vcpu was not running that interrupt will be delivered as soon as the vcpu starts running again.

Juergen

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

#3 lore raw
In reply to Juergen Gross
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 01.02.19 at 08:26, <[email protected]> wrote:

While working on my core scheduling series I stumbled over the periodic timer. Could it be this timer never worked correctly?

When the vcpu with an active periodic timer is running everything seems to be fine. But when not running the timer is stopped in schedule(). So a vcpu going to idle relying to be woken up by the periodic timer will remain sleeping until another event is happening. The periodic timer won't fire as it is stopped.

Quoted 3 lines

The periodic timer is used via VCPUOP_set_periodic_timer only, and today's Linux kernel isn't using it at all. So I guess this timer not really working as it should is no big issue.

Interesting. Our kernels have been using it until SLE11 SP1, as did the old 2.6.18 one that all of our old kernels were derived from. Yet the same code is present already in 3.2.0's schedule(). Are you sure this timer is meant to wake the vCPU at the set rate, rather than just surfacing events if the vCPU is running? Looking at vcpu_periodic_timer_work()'s calculation of the next event time also suggests to me that there's no guarantee that the event will indeed surface at the set rate.

Jan

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 14 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 01.02.19 at 08:26, <[email protected]> wrote:

While working on my core scheduling series I stumbled over the periodic timer. Could it be this timer never worked correctly?

When the vcpu with an active periodic timer is running everything seems to be fine. But when not running the timer is stopped in schedule(). So a vcpu going to idle relying to be woken up by the periodic timer will remain sleeping until another event is happening. The periodic timer won't fire as it is stopped.

Quoted 3 lines

The periodic timer is used via VCPUOP_set_periodic_timer only, and today's Linux kernel isn't using it at all. So I guess this timer not really working as it should is no big issue.

Quoted 8 lines

Interesting. Our kernels have been using it until SLE11 SP1, as did the old 2.6.18 one that all of our old kernels were derived from. Yet the same code is present already in 3.2.0's schedule(). Are you sure this timer is meant to wake the vCPU at the set rate, rather than just surfacing events if the vCPU is running? Looking at vcpu_periodic_timer_work()'s calculation of the next event time also suggests to me that there's no guarantee that the event will indeed surface at the set rate.

That's correct. The set rate just is the minimum time between two interrupts.

The usability of such a timer is questionable in the best case IMO.

Juergen

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

#6 lore raw
Quoted 18 lines · Juergen Gross
Quoted 8 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 01.02.19 at 08:26, <[email protected]> wrote:

The periodic timer is used via VCPUOP_set_periodic_timer only, and
today's Linux kernel isn't using it at all. So I guess this timer not
really working as it should is no big issue.

Quoted 8 lines

Interesting. Our kernels have been using it until SLE11 SP1, as did the old 2.6.18 one that all of our old kernels were derived from. Yet the same code is present already in 3.2.0's schedule(). Are you sure this timer is meant to wake the vCPU at the set rate, rather than just surfacing events if the vCPU is running? Looking at vcpu_periodic_timer_work()'s calculation of the next event time also suggests to me that there's no guarantee that the event will indeed surface at the set rate.

Quoted 5 lines

That's correct. The set rate just is the minimum time between two interrupts.

The usability of such a timer is questionable in the best case IMO.

Yes, I vaguely recall discussing about this with someone, and the outcome being <<Well, everyone should be using the single-shot timer anyway, these days>>, and then we probably dropped the ball (I can't find the thread right now, maybe it was on IRC). :-(

IAC, I do agree that it does not make any sense to stop the timer for the vcpu being descheduled. And we really should either fix this... or we can get just get rid of the timer entirely, as it's basically delivering events at pseudo-random rate! :-O

I can look into that.

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Software Engineer @ SUSE https://www.suse.com/

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