mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
bitkeeper revision 1.1236.1.181 (424d132aYORx7PllUl-nlTBMndGn4g)
Improved lazy state switching -- flush the state switch through on the first flush IPI received. This avoids needing to receive any further ones at little cost (needed to flush TLB anyway). The main extra cost will be that, when switching back to a guest, we won't save the ctxt switch. But we may have saved an unbounded number of IPI flushes. Signed-off-by: Keir Fraser <keir@xensource.com>
This commit is contained in:
1 parent
354e7e4b6a
commit
00e8ef7605
6 files changed
+52
-90
No files matched your search
@@ -53,7 +53,6 @@ platform_is_hp_ski(void)
|
||||
}
|
||||
|
||||
/* calls in xen/common code that are unused on ia64 */
|
||||
void synchronise_execution_state(unsigned long cpu_mask) { }
|
||||
|
||||
int grant_table_create(struct domain *d) { return 0; }
|
||||
void grant_table_destroy(struct domain *d)
|
||||
|
||||
+37
-38
@@ -744,12 +744,21 @@ long do_switch_to_user(void)
|
||||
return stu.rax;
|
||||
}
|
||||
|
||||
#define switch_kernel_stack(_n,_c) ((void)0)
|
||||
|
||||
#elif defined(__i386__)
|
||||
|
||||
#define load_segments(_p, _n) ((void)0)
|
||||
#define save_segments(_p) ((void)0)
|
||||
#define clear_segments() ((void)0)
|
||||
|
||||
static inline void switch_kernel_stack(struct exec_domain *n, unsigned int cpu)
|
||||
{
|
||||
struct tss_struct *tss = &init_tss[cpu];
|
||||
tss->esp1 = n->arch.kernel_sp;
|
||||
tss->ss1 = n->arch.kernel_ss;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define loaddebug(_ed,_reg) \
|
||||
@@ -772,41 +781,35 @@ static void __context_switch(void)
|
||||
save_segments(p);
|
||||
}
|
||||
|
||||
memcpy(stack_ec,
|
||||
&n->arch.user_ctxt,
|
||||
sizeof(*stack_ec));
|
||||
|
||||
/* Maybe switch the debug registers. */
|
||||
if ( unlikely(n->arch.debugreg[7]) )
|
||||
if ( !is_idle_task(n->domain) )
|
||||
{
|
||||
loaddebug(&n->arch, 0);
|
||||
loaddebug(&n->arch, 1);
|
||||
loaddebug(&n->arch, 2);
|
||||
loaddebug(&n->arch, 3);
|
||||
/* no 4 and 5 */
|
||||
loaddebug(&n->arch, 6);
|
||||
loaddebug(&n->arch, 7);
|
||||
}
|
||||
memcpy(stack_ec,
|
||||
&n->arch.user_ctxt,
|
||||
sizeof(*stack_ec));
|
||||
|
||||
if ( !VMX_DOMAIN(n) )
|
||||
{
|
||||
SET_FAST_TRAP(&n->arch);
|
||||
|
||||
#ifdef __i386__
|
||||
/* Maybe switch the debug registers. */
|
||||
if ( unlikely(n->arch.debugreg[7]) )
|
||||
{
|
||||
/* Switch the kernel ring-1 stack. */
|
||||
struct tss_struct *tss = &init_tss[cpu];
|
||||
tss->esp1 = n->arch.kernel_sp;
|
||||
tss->ss1 = n->arch.kernel_ss;
|
||||
loaddebug(&n->arch, 0);
|
||||
loaddebug(&n->arch, 1);
|
||||
loaddebug(&n->arch, 2);
|
||||
loaddebug(&n->arch, 3);
|
||||
/* no 4 and 5 */
|
||||
loaddebug(&n->arch, 6);
|
||||
loaddebug(&n->arch, 7);
|
||||
}
|
||||
|
||||
if ( !VMX_DOMAIN(n) )
|
||||
{
|
||||
SET_FAST_TRAP(&n->arch);
|
||||
switch_kernel_stack(n, cpu);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
set_bit(cpu, &n->domain->cpuset);
|
||||
write_ptbase(n);
|
||||
clear_bit(cpu, &p->domain->cpuset);
|
||||
|
||||
__asm__ __volatile__ ( "lgdt %0" : "=m" (*n->arch.gdt) );
|
||||
clear_bit(cpu, &p->domain->cpuset);
|
||||
|
||||
percpu_ctxt[cpu].curr_ed = n;
|
||||
}
|
||||
@@ -820,7 +823,7 @@ void context_switch(struct exec_domain *prev, struct exec_domain *next)
|
||||
|
||||
set_current(next);
|
||||
|
||||
if ( ((realprev = percpu_ctxt[smp_processor_id()]. curr_ed) == next) ||
|
||||
if ( ((realprev = percpu_ctxt[smp_processor_id()].curr_ed) == next) ||
|
||||
is_idle_task(next->domain) )
|
||||
{
|
||||
local_irq_enable();
|
||||
@@ -851,18 +854,14 @@ void context_switch(struct exec_domain *prev, struct exec_domain *next)
|
||||
BUG();
|
||||
}
|
||||
|
||||
static void __synchronise_lazy_execstate(void *unused)
|
||||
int __sync_lazy_execstate(void)
|
||||
{
|
||||
if ( percpu_ctxt[smp_processor_id()].curr_ed != current )
|
||||
{
|
||||
__context_switch();
|
||||
load_LDT(current);
|
||||
clear_segments();
|
||||
}
|
||||
}
|
||||
void synchronise_lazy_execstate(unsigned long cpuset)
|
||||
{
|
||||
smp_subset_call_function(__synchronise_lazy_execstate, NULL, 1, cpuset);
|
||||
if ( percpu_ctxt[smp_processor_id()].curr_ed == current )
|
||||
return 0;
|
||||
__context_switch();
|
||||
load_LDT(current);
|
||||
clear_segments();
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned long __hypercall_create_continuation(
|
||||
|
||||
+2
-1
@@ -2827,7 +2827,8 @@ void audit_domain(struct domain *d)
|
||||
|
||||
if ( d != current->domain )
|
||||
domain_pause(d);
|
||||
synchronise_lazy_execstate(~0UL);
|
||||
|
||||
sync_lazy_execstate_all();
|
||||
|
||||
printk("pt base=%lx sh_info=%x\n",
|
||||
pagetable_val(d->exec_domain[0]->arch.guest_table)>>PAGE_SHIFT,
|
||||
|
||||
+7
-43
@@ -154,10 +154,13 @@ asmlinkage void smp_invalidate_interrupt(void)
|
||||
{
|
||||
ack_APIC_irq();
|
||||
perfc_incrc(ipis);
|
||||
if ( flush_va == FLUSHVA_ALL )
|
||||
local_flush_tlb();
|
||||
else
|
||||
local_flush_tlb_one(flush_va);
|
||||
if ( !__sync_lazy_execstate() )
|
||||
{
|
||||
if ( flush_va == FLUSHVA_ALL )
|
||||
local_flush_tlb();
|
||||
else
|
||||
local_flush_tlb_one(flush_va);
|
||||
}
|
||||
clear_bit(smp_processor_id(), &flush_cpumask);
|
||||
}
|
||||
|
||||
@@ -278,45 +281,6 @@ int smp_call_function(
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Run a function on a subset of CPUs (may include local CPU). */
|
||||
int smp_subset_call_function(
|
||||
void (*func) (void *info), void *info, int wait, unsigned long cpuset)
|
||||
{
|
||||
struct call_data_struct data;
|
||||
|
||||
ASSERT(local_irq_is_enabled());
|
||||
|
||||
if ( cpuset & (1UL << smp_processor_id()) )
|
||||
{
|
||||
local_irq_disable();
|
||||
(*func)(info);
|
||||
local_irq_enable();
|
||||
}
|
||||
|
||||
cpuset &= ((1UL << smp_num_cpus) - 1) & ~(1UL << smp_processor_id());
|
||||
if ( cpuset == 0 )
|
||||
return 0;
|
||||
|
||||
data.func = func;
|
||||
data.info = info;
|
||||
data.started = data.finished = 0;
|
||||
data.wait = wait;
|
||||
|
||||
spin_lock(&call_lock);
|
||||
|
||||
call_data = &data;
|
||||
wmb();
|
||||
|
||||
send_IPI_mask(cpuset, CALL_FUNCTION_VECTOR);
|
||||
|
||||
while ( (wait ? data.finished : data.started) != cpuset )
|
||||
cpu_relax();
|
||||
|
||||
spin_unlock(&call_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void stop_this_cpu (void *dummy)
|
||||
{
|
||||
clear_bit(smp_processor_id(), &cpu_online_map);
|
||||
|
||||
@@ -255,7 +255,9 @@ void domain_sleep(struct exec_domain *d);
|
||||
* Force loading of currently-executing domain state on the specified set
|
||||
* of CPUs. This is used to counteract lazy state switching where required.
|
||||
*/
|
||||
void synchronise_lazy_execstate(unsigned long cpuset);
|
||||
#define sync_lazy_execstate_cpuset(_cpuset) flush_tlb_mask(_cpuset)
|
||||
#define sync_lazy_execstate_all() flush_tlb_all()
|
||||
extern int __sync_lazy_execstate(void);
|
||||
|
||||
extern void context_switch(
|
||||
struct exec_domain *prev,
|
||||
@@ -337,7 +339,7 @@ static inline void exec_domain_pause(struct exec_domain *ed)
|
||||
ASSERT(ed != current);
|
||||
atomic_inc(&ed->pausecnt);
|
||||
domain_sleep(ed);
|
||||
synchronise_lazy_execstate(ed->domain->cpuset & (1UL << ed->processor));
|
||||
sync_lazy_execstate_cpuset(ed->domain->cpuset & (1UL << ed->processor));
|
||||
}
|
||||
|
||||
static inline void domain_pause(struct domain *d)
|
||||
@@ -351,7 +353,7 @@ static inline void domain_pause(struct domain *d)
|
||||
domain_sleep(ed);
|
||||
}
|
||||
|
||||
synchronise_lazy_execstate(d->cpuset);
|
||||
sync_lazy_execstate_cpuset(d->cpuset);
|
||||
}
|
||||
|
||||
static inline void exec_domain_unpause(struct exec_domain *ed)
|
||||
@@ -386,7 +388,7 @@ static inline void domain_pause_by_systemcontroller(struct domain *d)
|
||||
domain_sleep(ed);
|
||||
}
|
||||
|
||||
synchronise_lazy_execstate(d->cpuset);
|
||||
sync_lazy_execstate_cpuset(d->cpuset);
|
||||
}
|
||||
|
||||
static inline void domain_unpause_by_systemcontroller(struct domain *d)
|
||||
|
||||
@@ -45,8 +45,6 @@ extern void smp_commence(void);
|
||||
*/
|
||||
extern int smp_call_function(
|
||||
void (*func) (void *info), void *info, int retry, int wait);
|
||||
extern int smp_subset_call_function(
|
||||
void (*func) (void *info), void *info, int wait, unsigned long cpuset);
|
||||
|
||||
/*
|
||||
* True once the per process idle is forked
|
||||
@@ -87,7 +85,6 @@ extern volatile int smp_msg_id;
|
||||
#define cpu_logical_map(cpu) 0
|
||||
#define cpu_number_map(cpu) 0
|
||||
#define smp_call_function(func,info,retry,wait) 0
|
||||
#define smp_subset_call_function(f,i,w,c) ({ if ( (c&1) ) (*f)(i); 0; })
|
||||
#define cpu_online_map 1
|
||||
|
||||
#endif
|
||||
|
||||