|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFC 3/4] xen/x86: split context_switch()
Split up context_switch() to prepare switching of the used stack.
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
xen/arch/x86/domain.c | 67 ++++++++++++++++++++++++++++-----------------------
1 file changed, 37 insertions(+), 30 deletions(-)
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index da1bf1a97b..c0cb2cae64 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -1673,38 +1673,10 @@ static void __context_switch(void)
per_cpu(curr_vcpu, cpu) = n;
}
-
-void context_switch(struct vcpu *prev, struct vcpu *next)
+static void context_switch_irqoff(struct vcpu *prev, struct vcpu *next,
+ unsigned int cpu)
{
- unsigned int cpu = smp_processor_id();
const struct domain *prevd = prev->domain, *nextd = next->domain;
- cpumask_t dirty_mask;
-
- ASSERT(local_irq_is_enabled());
-
- cpumask_copy(&dirty_mask, next->vcpu_dirty_cpumask);
- /* Allow at most one CPU at a time to be dirty. */
- ASSERT(cpumask_weight(&dirty_mask) <= 1);
- if ( unlikely(!cpumask_test_cpu(cpu, &dirty_mask) &&
- !cpumask_empty(&dirty_mask)) )
- {
- /* Other cpus call __sync_local_execstate from flush ipi handler. */
- flush_tlb_mask(&dirty_mask);
- }
-
- if ( prev != next )
- {
- _update_runstate_area(prev);
- vpmu_switch_from(prev);
- np2m_schedule(NP2M_SCHEDLE_OUT);
- }
-
- if ( is_hvm_domain(prevd) && !list_empty(&prev->arch.hvm_vcpu.tm_list) )
- pt_save_timer(prev);
-
- local_irq_disable();
-
- set_current(next);
if ( (per_cpu(curr_vcpu, cpu) == next) ||
(is_idle_domain(nextd) && cpu_online(cpu)) )
@@ -1760,6 +1732,41 @@ void context_switch(struct vcpu *prev, struct vcpu *next)
BUG();
}
+void context_switch(struct vcpu *prev, struct vcpu *next)
+{
+ unsigned int cpu = smp_processor_id();
+ const struct domain *prevd = prev->domain;
+ cpumask_t dirty_mask;
+
+ ASSERT(local_irq_is_enabled());
+
+ cpumask_copy(&dirty_mask, next->vcpu_dirty_cpumask);
+ /* Allow at most one CPU at a time to be dirty. */
+ ASSERT(cpumask_weight(&dirty_mask) <= 1);
+ if ( unlikely(!cpumask_test_cpu(cpu, &dirty_mask) &&
+ !cpumask_empty(&dirty_mask)) )
+ {
+ /* Other cpus call __sync_local_execstate from flush ipi handler. */
+ flush_tlb_mask(&dirty_mask);
+ }
+
+ if ( prev != next )
+ {
+ _update_runstate_area(prev);
+ vpmu_switch_from(prev);
+ np2m_schedule(NP2M_SCHEDLE_OUT);
+ }
+
+ if ( is_hvm_domain(prevd) && !list_empty(&prev->arch.hvm_vcpu.tm_list) )
+ pt_save_timer(prev);
+
+ local_irq_disable();
+
+ set_current(next);
+
+ context_switch_irqoff(prev, next, cpu);
+}
+
void continue_running(struct vcpu *same)
{
/* See the comment above. */
--
2.13.6
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |