schedule(): hold runq lock for the entire duration of context switching
releasing the runq lock after loading page tables but before the actual context switch can leave execution in an inconsistent if the current process is descheduled from an IRQ between these two steps. this patch holds the runq lock with IRQs disabled and makes the context switch a single atomic operation.
This commit is contained in:
@ -1012,6 +1012,18 @@ void ihk_mc_init_context(ihk_mc_kernel_context_t *new_ctx,
|
||||
}
|
||||
|
||||
extern char enter_user_mode[];
|
||||
|
||||
/*
|
||||
* Release runq_lock before entering user space.
|
||||
* This is needed because schedule() holds the runq lock throughout
|
||||
* the context switch and when a new process is created it starts
|
||||
* execution in enter_user_mode, which in turn calls this function.
|
||||
*/
|
||||
void release_runq_lock(void)
|
||||
{
|
||||
ihk_mc_spinlock_unlock(&(cpu_local_var(runq_lock)),
|
||||
cpu_local_var(runq_irqstate));
|
||||
}
|
||||
|
||||
/*@
|
||||
@ requires \valid(ctx);
|
||||
|
||||
@ -206,6 +206,7 @@ x86_syscall:
|
||||
|
||||
.globl enter_user_mode
|
||||
enter_user_mode:
|
||||
callq release_runq_lock
|
||||
movq $0, %rdi
|
||||
movq %rsp, %rsi
|
||||
call check_signal
|
||||
|
||||
Reference in New Issue
Block a user