From fa8f2c5000cafcaa87182c5f2c021ae1ae52299c Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sun, 9 May 2004 23:25:57 -0700 Subject: [PATCH] Reduce TLB flushing during process migration From: Martin Hicks Another optimization patch from Jack Steiner, intended to reduce TLB flushes during process migration. Most architextures should define tlb_migrate_prepare() to be flush_tlb_mm(), but on i386, it would be a wasted flush, because i386 disconnects previous cpus from the tlb flush automatically. --- include/asm-generic/tlb.h | 2 ++ include/asm-ia64/tlb.h | 2 ++ kernel/sched.c | 10 ++++++++++ 3 files changed, 14 insertions(+) diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h index 1358c5136889..69c11ff2e984 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h @@ -146,4 +146,6 @@ static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page) __pmd_free_tlb(tlb, pmdp); \ } while (0) +#define tlb_migrate_prepare(mm) do { } while(0) + #endif /* _ASM_GENERIC__TLB_H */ diff --git a/include/asm-ia64/tlb.h b/include/asm-ia64/tlb.h index 5d714b2061ed..ee0b0b3c7662 100644 --- a/include/asm-ia64/tlb.h +++ b/include/asm-ia64/tlb.h @@ -211,6 +211,8 @@ __tlb_remove_tlb_entry (struct mmu_gather *tlb, pte_t *ptep, unsigned long addre tlb->end_addr = address + PAGE_SIZE; } +#define tlb_migrate_prepare(mm) flush_tlb_mm(mm) + #define tlb_start_vma(tlb, vma) do { } while (0) #define tlb_end_vma(tlb, vma) do { } while (0) diff --git a/kernel/sched.c b/kernel/sched.c index 025f04bfdf5c..94e19f1a5580 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include #include #include @@ -1127,6 +1129,14 @@ static void sched_migrate_task(task_t *p, int dest_cpu) task_rq_unlock(rq, &flags); wake_up_process(rq->migration_thread); wait_for_completion(&req.done); + + /* + * we want a new context here. This eliminates TLB + * flushes on the cpus where the process executed prior to + * the migration. + */ + tlb_migrate_prepare(current->mm); + return; } out: -- cgit v1.2.3