powerpc/64s: Trim offlined CPUs from mm_cpumasks
[linux-2.6-block.git] / arch / powerpc / mm / book3s64 / mmu_context.c
index 1c54821de7bfb58a132d2e846b570517087bc594..0c8557220ae28a328a44dbc80d47b7f86be08f60 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/export.h>
 #include <linux/gfp.h>
 #include <linux/slab.h>
+#include <linux/cpu.h>
 
 #include <asm/mmu_context.h>
 #include <asm/pgalloc.h>
@@ -307,3 +308,22 @@ void radix__switch_mmu_context(struct mm_struct *prev, struct mm_struct *next)
        isync();
 }
 #endif
+
+/**
+ * cleanup_cpu_mmu_context - Clean up MMU details for this CPU (newly offlined)
+ *
+ * This clears the CPU from mm_cpumask for all processes, and then flushes the
+ * local TLB to ensure TLB coherency in case the CPU is onlined again.
+ *
+ * KVM guest translations are not necessarily flushed here. If KVM started
+ * using mm_cpumask or the Linux APIs which do, this would have to be resolved.
+ */
+#ifdef CONFIG_HOTPLUG_CPU
+void cleanup_cpu_mmu_context(void)
+{
+       int cpu = smp_processor_id();
+
+       clear_tasks_mm_cpumask(cpu);
+       tlbiel_all();
+}
+#endif