: PV-domain SMP performance XEN-part
PATCH 1/1 : PV-domain SMP performance XEN-part
Signature · 6 lines
-- Juergen Gross Principal Developer IP SW OS6 Telephone: +49 (0) 89 636 47950 Fujitsu Siemens Computers e-mail: [email protected] Otto-Hahn-Ring 6 Internet: www.fujitsu-siemens.com D-81739 Muenchen Company details: www.fujitsu-siemens.com/imprint.html
Add possibility for guest to mark a vcpu not to be descheduled.
# HG changeset patch
# User [email protected]
# Date 1229510869 -3600
# Node ID a854d67dd0f0aa11986d0ed741681cf671ceb7ac # Parent a76b4e00e1862035240ec6403a8f081be61b1e2b added support of vcpu preempt disable
xen/common/schedule.c +22 -0
@@ -778,6 +778,7 @@ static void schedule(void)struct schedule_data *sd;struct task_slice next_slice;s32 r_time;/* time for new dom to run */ +int is_idle =is_idle_domain (prev->domain);ASSERT (!in_irq ());ASSERT (this_cpu (mc_state).flags ==0 );
@@ -787,6 +788,22 @@ static void schedule(void) sd = &this_cpu (schedule_data);spin_lock_irq (&sd->schedule_lock); + +if ( !is_idle &&unlikely (vcpu_info (prev, no_desched)) ) + { +if ( !vcpu_info (prev, desched_delay) ) + { +vcpu_info (prev, desched_delay) =1 ; + sd->delay_desched = now +MILLISECS (1 ); +stop_timer (&sd->s_timer); +set_timer (&sd->s_timer, sd->delay_desched); + } +if ( now < sd->delay_desched ) + { +spin_unlock_irq (&sd->schedule_lock); +return continue_running (prev); + } + }stop_timer (&sd->s_timer);
@@ -797,6 +814,11 @@ static void schedule(void) next = next_slice.task; sd->curr = next; + sd->delay_desched =0 ; +if ( !is_idle ) + { +vcpu_info (prev, desched_delay) =0 ; + }set_timer (&sd->s_timer, now + r_time);
xen/include/public/xen.h +9 -0
@@ -434,9 +434,18 @@ struct vcpu_info {* non-zero mask therefore guarantees that the VCPU will not receive * an upcall activation. The mask is cleared when the VCPU requests * to block: this avoids wakeup-waiting races. +* +* The guest can set 'no_desched' to a non-zero value to avoid being +* descheduled. If the hypervisor didn't deschedule the VCPU due to +* 'no_desched' being set, it will itself set 'desched_delay' to inform +* the guest to give up control voluntaryly later. This is just a wish +* of the guest which the hypervisor may not obey (and it will deschedule +* the guest after a reasonable time anyway). */ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; +uint8_t no_desched; +uint8_t desched_delay;unsigned long evtchn_pending_sel;struct arch_vcpu_info arch;struct vcpu_time_info time;
xen/include/xen/sched-if.h +1 -0
@@ -16,6 +16,7 @@ struct schedule_data {struct vcpu *idle;/* idle task for this cpu */ void *sched_priv;struct timer s_timer;/* scheduling timer */ +s_time_t delay_desched;/* time of delayed deschedule */ } __cacheline_aligned; DECLARE_PER_CPU(struct schedule_data, schedule_data);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 6 lines · George Dunlap
The idea might be interesting, but this implementation needs some work. Xen shouldn't be reading a guest-writable bit of memory to determine if it's already delayed the guest; it needs to store that information somewhere else. As it is, a rogue guest could extend its time indefinitely by just writing 0 there every couple hundred instructions.
Thanks for finding this one!
The correction is quite simple, I can just use sd->delay_desched for this purpose instead.
Quoted 7 lines
It should probably be something taken care of in the individual schedulers, rather than in the abstract scheduling code.
At any rate, let's see if there's a significant performance difference between this and yield-after-spinning-awhile, and then we can work on the architecture.
Agreed.
Juergen
Signature · 5 lines
Juergen Gross Principal Developer IP SW OS6 Telephone: +49 (0) 89 636 47950 Fujitsu Siemens Computers e-mail: [email protected] Otto-Hahn-Ring 6 Internet: www.fujitsu-siemens.com D-81739 Muenchen Company details: www.fujitsu-siemens.com/imprint.html