Q: Why vfree must not be called in interrupt context?
A: the tlb flushing can deadlock with IRQs disabled as it relies on IPIs
suppose two cpus are in interrupt context (with interrupts disabled),
both then want to vfree which would result in a TLB flush, the TLB flush
will IPI the other cpu to clear its TLB, but the other CPU has interrupts
A: the tlb flushing can deadlock with IRQs disabled as it relies on IPIs
suppose two cpus are in interrupt context (with interrupts disabled),
both then want to vfree which would result in a TLB flush, the TLB flush
will IPI the other cpu to clear its TLB, but the other CPU has interrupts
disabled so both keep waiting for the other to process the TLB flush -> deadlock.
在x86的smp环境下,一个processor可以通过他自己的local apic向其他的cpu 发送interrupt (inter-processor interrupt)。
如果需要在每个cpu上flush tlb的话,就需要用到ipi了。
void flush_tlb_all(void)
{
on_each_cpu(do_flush_tlb_all, NULL, 1);
}