SMP - fixed IPI livelock
- two CPUs can issue IPI to each other now without any hazzard - we must be able to handle synchronous scheduling IPIs from other CPUs when we are waiting for attention from another one. Otherwise we might livelock. - necessary barriers to prevent reordering
This commit is contained in:
@@ -17,8 +17,13 @@
|
||||
#ifdef USE_APIC
|
||||
#include "apic.h"
|
||||
#endif
|
||||
|
||||
#include "spinlock.h"
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
#include "kernel/smp.h"
|
||||
#endif
|
||||
|
||||
#define CLOCK_ACK_BIT 0x80 /* PS/2 clock interrupt acknowledge bit */
|
||||
|
||||
/* Clock parameters. */
|
||||
@@ -235,6 +240,20 @@ PUBLIC void context_stop(struct proc * p)
|
||||
bkl_succ[cpu] += !(!(succ == 0));
|
||||
|
||||
p->p_cycles = add64(p->p_cycles, sub64(tsc, *__tsc_ctr_switch));
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
/*
|
||||
* Since at the time we got a scheduling IPI we might have been
|
||||
* waiting for BKL already, we may miss it due to a similar IPI to
|
||||
* the cpu which is already waiting for us to handle its. This
|
||||
* results in a live-lock of these two cpus.
|
||||
*
|
||||
* Therefore we always check if there is one pending and if so,
|
||||
* we handle it straight away so the other cpu can continue and
|
||||
* we do not deadlock.
|
||||
*/
|
||||
smp_sched_handler();
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
read_tsc_64(&tsc);
|
||||
|
||||
Reference in New Issue
Block a user