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:
Tomas Hruby
2011-10-26 15:43:36 +00:00
committed by Tomas Hruby
parent 0468fca72b
commit 0a55e63413
4 changed files with 74 additions and 20 deletions

View File

@@ -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);