Commit 224101ed authored by Jeremy Fitzhardinge's avatar Jeremy Fitzhardinge
Browse files

x86/paravirt: finish change from lazy cpu to context switch start/end



Impact: fix lazy context switch API

Pass the previous and next tasks into the context switch start
end calls, so that the called functions can properly access the
task state (esp in end_context_switch, in which the next task
is not yet completely current).

Signed-off-by: default avatarJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Acked-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
parent b407fc57
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ struct desc_ptr;
struct tss_struct;
struct mm_struct;
struct desc_struct;
struct task_struct;

/*
 * Wrapper type for pointers to code which uses the non-standard
@@ -203,7 +204,8 @@ struct pv_cpu_ops {

	void (*swapgs)(void);

	struct pv_lazy_ops lazy_mode;
	void (*start_context_switch)(struct task_struct *prev);
	void (*end_context_switch)(struct task_struct *next);
};

struct pv_irq_ops {
@@ -1414,20 +1416,21 @@ enum paravirt_lazy_mode {
};

enum paravirt_lazy_mode paravirt_get_lazy_mode(void);
void paravirt_enter_lazy_cpu(void);
void paravirt_leave_lazy_cpu(void);
void paravirt_start_context_switch(struct task_struct *prev);
void paravirt_end_context_switch(struct task_struct *next);

void paravirt_enter_lazy_mmu(void);
void paravirt_leave_lazy_mmu(void);

#define  __HAVE_ARCH_START_CONTEXT_SWITCH
static inline void arch_start_context_switch(void)
static inline void arch_start_context_switch(struct task_struct *prev)
{
	PVOP_VCALL0(pv_cpu_ops.lazy_mode.enter);
	PVOP_VCALL1(pv_cpu_ops.start_context_switch, prev);
}

static inline void arch_end_context_switch(void)
static inline void arch_end_context_switch(struct task_struct *next)
{
	PVOP_VCALL0(pv_cpu_ops.lazy_mode.leave);
	PVOP_VCALL1(pv_cpu_ops.end_context_switch, next);
}

#define  __HAVE_ARCH_ENTER_LAZY_MMU_MODE
+2 −0
Original line number Diff line number Diff line
@@ -83,6 +83,8 @@ static inline void __init paravirt_pagetable_setup_done(pgd_t *base)
#define pte_val(x)	native_pte_val(x)
#define __pte(x)	native_make_pte(x)

#define arch_end_context_switch(prev)	do {} while(0)

#endif	/* CONFIG_PARAVIRT */

/*
+6 −8
Original line number Diff line number Diff line
@@ -270,20 +270,20 @@ void paravirt_leave_lazy_mmu(void)
	leave_lazy(PARAVIRT_LAZY_MMU);
}

void paravirt_enter_lazy_cpu(void)
void paravirt_start_context_switch(struct task_struct *prev)
{
	if (percpu_read(paravirt_lazy_mode) == PARAVIRT_LAZY_MMU) {
		arch_leave_lazy_mmu_mode();
		set_thread_flag(TIF_LAZY_MMU_UPDATES);
		set_ti_thread_flag(task_thread_info(prev), TIF_LAZY_MMU_UPDATES);
	}
	enter_lazy(PARAVIRT_LAZY_CPU);
}

void paravirt_leave_lazy_cpu(void)
void paravirt_end_context_switch(struct task_struct *next)
{
	leave_lazy(PARAVIRT_LAZY_CPU);

	if (test_and_clear_thread_flag(TIF_LAZY_MMU_UPDATES))
	if (test_and_clear_ti_thread_flag(task_thread_info(next), TIF_LAZY_MMU_UPDATES))
		arch_enter_lazy_mmu_mode();
}

@@ -399,10 +399,8 @@ struct pv_cpu_ops pv_cpu_ops = {
	.set_iopl_mask = native_set_iopl_mask,
	.io_delay = native_io_delay,

	.lazy_mode = {
		.enter = paravirt_nop,
		.leave = paravirt_nop,
	},
	.start_context_switch = paravirt_nop,
	.end_context_switch = paravirt_nop,
};

struct pv_apic_ops pv_apic_ops = {
+1 −1
Original line number Diff line number Diff line
@@ -407,7 +407,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
	 * done before math_state_restore, so the TS bit is up
	 * to date.
	 */
	arch_end_context_switch();
	arch_end_context_switch(next_p);

	/* If the task has used fpu the last 5 timeslices, just do a full
	 * restore of the math state immediately to avoid the trap; the
+1 −1
Original line number Diff line number Diff line
@@ -428,7 +428,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
	 * done before math_state_restore, so the TS bit is up
	 * to date.
	 */
	arch_end_context_switch();
	arch_end_context_switch(next_p);

	/*
	 * Switch FS and GS.
Loading