xen: credit2: try to avoid tickling cpus subject to ratelimiting
With context switching ratelimiting enabled, the following
pattern is quite common in a scheduling trace:
0.
000845622 |||||||||||.x||| d32768v12 csched2:runq_insert d0v13, position 0
0.
000845831 |||||||||||.x||| d32768v12 csched2:runq_tickle_new d0v13, processor = 12, credit =
10135529
0.
000846546 |||||||||||.x||| d32768v12 csched2:burn_credits d2v7, credit =
2619231, delta = 255937
[1] 0.
000846739 |||||||||||.x||| d32768v12 csched2:runq_tickle cpu 12
[...]
[2] 0.
000850597 ||||||||||||x||| d32768v12 csched2:schedule cpu 12, rq# 1, busy, SMT busy, tickled
0.
000850760 ||||||||||||x||| d32768v12 csched2:burn_credits d2v7, credit =
2614028, delta = 5203
[3] 0.
000851022 ||||||||||||x||| d32768v12 csched2:ratelimit triggered
[4] 0.
000851614 ||||||||||||x||| d32768v12 runstate_continue d2v7 running->running
Basically, what happens is that runq_tickle() realizes
d0v13 should preempt d2v7, running on cpu 12, as it
has higher credits (
10135529 vs.
2619231). It therefore
tickles cpu 12 [1], which, in turn, schedules [2].
But --surprise surprise-- d2v7 has run for less than the
ratelimit interval [3], and hence it is _not_ preempted,
and continues to run. This indeed looks fine. Actually,
this is what ratelimiting is there for. Note, however,
that:
1) we interrupted cpu 12 for nothing;
2) what if, say on cpu 8, there is a vcpu that has:
+ less credit than d0v13 (so d0v13 can well
preempt it),
+ more credit than d2v7 (that's why it was not
selected to be preempted),
+ run for more than the ratelimiting interval
(so it can really be scheduled out)?
With this patch, if we are in case 2), we'd realize
that tickling 12 would be pointless, and we'll continue
looking, eventually finding and tickling 8.
Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@eu.citrix.com>