: MM: Make Page Tables Reloctable: Conditional TLB Flush
Subsystems (8)
RFC PATCH 1/2 : MM: Make Page Tables Reloctable: Conditional TLB Flush
These Patches make page tables relocatable for numa, memory defragmentation, and memory hotblug. The potential need to rewalk the page tables before making any changes causes a 3% peformance degredation in the lmbench page miss micro benchmark.
----
These patches are against 2.6.23 kernel.org kernel.
The lmbech results are available if any wants to see them. This version of the patch is x86_64 specific. The per archictecture part of the patch is limited to allocating new page tables and reloading the pgd. The main differences between this version and the previous one is that a flag in the MM is used to determine if the page tables need to be rewalked, a race when split page table locks were used was fixed, and per-arch page table allocation functions were used to allocate the new page tables.
If there are no complaints, I intend to make a new version of these patches against the latest mm kernel, put some #ifdefs for supported vs unsuportted archs and request inclusion in the mm kernel.
arch/arm/kernel/smp.c +2 -0
@@ -713,6 +713,8 @@ void flush_tlb_mm(struct mm_struct *mm) {cpumask_t mask = mm->cpu_vm_mask; +clear_bit (MMF_NEED_FLUSH , mm->flags); +on_each_cpu_mask (ipi_flush_tlb_mm, mm,1 ,1 , mask); }
arch/avr32/mm/tlb.c +2 -0
@@ -249,6 +249,8 @@ void flush_tlb_kernel_range(unsigned lonvoid flush_tlb_mm (struct mm_struct *mm) { +clear_bit (MMF_NEED_FLUSH , mm->flags); +/* Invalidate all TLB entries of this process by getting a new ASID */ if (mm->context !=NO_CONTEXT ) {unsigned long flags;
arch/cris/arch-v10/mm/tlb.c +2 -0
@@ -69,6 +69,8 @@ flush_tlb_mm(struct mm_struct *mm)D (printk ("tlb: flush mm context %d (%p)\n" , page_id, mm)); +clear_bit (MMF_NEED_FLUSH , mm->flags); +if (page_id ==NO_CONTEXT )return ;
arch/cris/arch-v32/kernel/smp.c +1 -0
@@ -237,6 +237,7 @@ void flush_tlb_all(void)void flush_tlb_mm (struct mm_struct *mm) { +clear_bit (MMF_NEED_FLUSH , mm->flags);__flush_tlb_mm (mm);flush_tlb_common (mm,FLUSH_ALL ,0 );/* No more mappings in other CPUs */
arch/i386/kernel/smp.c +2 -0
@@ -410,6 +410,8 @@ void flush_tlb_mm (struct mm_struct * mm {cpumask_t cpu_mask; +clear_bit (MMF_NEED_FLUSH , mm->flags); +preempt_disable (); cpu_mask = mm->cpu_vm_mask;cpu_clear (smp_processor_id (), cpu_mask);
arch/i386/mach-voyager/voyager_smp.c +2 -0
@@ -924,6 +924,8 @@ flush_tlb_mm (struct mm_struct * mm) {unsigned long cpu_mask; +clear_bit (MMF_NEED_FLUSH , mm->flags); +preempt_disable (); cpu_mask =cpus_addr (mm->cpu_vm_mask)[0 ] & ~(1 <<smp_processor_id ());
arch/alpha/kernel/smp.c +2 -0
@@ -850,6 +850,8 @@ flush_tlb_mm(struct mm_struct *mm) {preempt_disable (); +clear_bit (MMF_NEED_FLUSH , mm->flags); +if (mm == current->active_mm) {flush_tlb_current (mm);if (atomic_read (&mm->mm_users) <=1 ) {
arch/ia64/kernel/smp.c +2 -0
@@ -325,6 +325,8 @@ smp_flush_tlb_all (void)void smp_flush_tlb_mm (struct mm_struct *mm) { +clear_bit (MMF_NEED_FLUSH , mm->flags); +preempt_disable ();/* this happens for the common case of a single-threaded fork(): */ if (likely (mm == current->active_mm &&atomic_read (&mm->mm_users) ==1 ))
arch/m32r/kernel/smp.c +2 -0
@@ -280,6 +280,8 @@ void smp_flush_tlb_mm(struct mm_struct *unsigned long *mmc;unsigned long flags; +clear_bit (MMF_NEED_FLUSH , mm->flags); +preempt_disable (); cpu_id =smp_processor_id (); mmc = &mm->context[cpu_id];
arch/mips/kernel/smp.c +2 -0
@@ -387,6 +387,8 @@ static inline void smp_on_each_tlb(voidvoid flush_tlb_mm (struct mm_struct *mm) { +clear_bit (MMF_NEED_FLUSH , mm->flags); +preempt_disable ();if ((atomic_read (&mm->mm_users) !=1 ) || (current->mm != mm)) {
arch/powerpc/mm/tlb_32.c +2 -0
@@ -144,6 +144,8 @@ void flush_tlb_mm(struct mm_struct *mm) {struct vm_area_struct *mp; +clear_bit (MMF_NEED_FLUSH , mm->flags); +if (Hash ==0 ) {_tlbia ();return ;
arch/ppc/mm/tlb.c +2 -0
@@ -144,6 +144,8 @@ void flush_tlb_mm(struct mm_struct *mm) {struct vm_area_struct *mp; +clear_bit (MMF_NEED_FLUSH , mm->flags); +if (Hash ==0 ) {_tlbia ();return ;
arch/sh64/mm/fault.c +2 -0
@@ -517,6 +517,8 @@ void flush_tlb_mm(struct mm_struct *mm) ++calls_to_flush_tlb_mm;#endif +clear_bit (MMF_NEED_FLUSH , mm->flags); +if (mm->context ==NO_CONTEXT )return ;
arch/sparc/kernel/smp.c +2 -0
@@ -163,6 +163,8 @@ void smp_flush_cache_mm(struct mm_structvoid smp_flush_tlb_mm (struct mm_struct *mm) { +clear_bit (MMF_NEED_FLUSH , mm->flags); +if (mm->context !=NO_CONTEXT ) {cpumask_t cpu_mask = mm->cpu_vm_mask;cpu_clear (smp_processor_id (), cpu_mask);
arch/sparc64/kernel/smp.c +2 -0
@@ -1112,6 +1112,8 @@ void smp_flush_tlb_mm(struct mm_struct *u32 ctx =CTX_HWBITS (mm->context);int cpu =get_cpu (); +clear_bit (MMF_NEED_FLUSH , mm->flags); +if (atomic_read (&mm->mm_users) ==1 ) { mm->cpu_vm_mask =cpumask_of_cpu (cpu); goto local_flush_and_out;
arch/um/kernel/tlb.c +1 -0
@@ -402,6 +402,7 @@ void flush_tlb_range(struct vm_area_struvoid flush_tlb_mm (struct mm_struct *mm) { +clear_bit (MMF_NEED_FLUSH , mm->flags);CHOOSE_MODE_PROC (flush_tlb_mm_tt, flush_tlb_mm_skas, mm); }
arch/xtensa/mm/tlb.c +2 -0
@@ -63,6 +63,8 @@ void flush_tlb_all (void)void flush_tlb_mm (struct mm_struct *mm) { +clear_bit (MMF_NEED_FLUSH , mm->flags); +if (mm == current->active_mm) {int flags;local_save_flags (flags);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Ross-san.
Thanks.
This feature is necessary for memory-hotremove.
Especially, if VMEMMAP_SPARSEMEM is configured, the pagetables of vmemmap must be migrated from removing memory.
Could you rebase them for newest kernel or -mm? And please remove many of "#if 1" in the second patch.
Bye.
Quoted 232 lines
These Patches make page tables relocatable for numa, memory defragmentation, and memory hotblug. The potential need to rewalk the page tables before making any changes causes a 3% peformance degredation in the lmbench page miss micro benchmark.
Signed-off-by [email protected]----
These patches are against 2.6.23 kernel.org kernel.
The lmbech results are available if any wants to see them. This version of the patch is
x86_64specific. The per archictecture part of the patch is limited to allocating new page tables and reloading the pgd. The main differences between this version and the previous one is that a flag in the MM is used to determine if the page tables need to be rewalked, a race when split page table locks were used was fixed, and per-arch page table allocation functions were used to allocate the new page tables.If there are no complaints, I intend to make a new version of these patches against the latest mm kernel, put some #ifdefs for supported vs unsuportted archs and request inclusion in the mm kernel.
diff -uprwNbB -X 2.6.23/Documentation/dontdiff
2.6.23/arch/arm/kernel/smp.c2.6.23a/arch/arm/kernel/smp.carch/arm/kernel/smp.c +2
-0@@ -713,6 +713,8 @@ void flush_tlb_mm(struct mm_struct *mm) {cpumask_t mask = mm->cpu_vm_mask; +clear_bit (MMF_NEED_FLUSH , mm->flags); +on_each_cpu_mask (ipi_flush_tlb_mm, mm,1 ,1 , mask); }diff -uprwNbB -X 2.6.23/Documentation/dontdiff
2.6.23/arch/avr32/mm/tlb.c2.6.23a/arch/avr32/mm/tlb.carch/avr32/mm/tlb.c +2
-0@@ -249,6 +249,8 @@ void flush_tlb_kernel_range(unsigned lonvoid flush_tlb_mm (struct mm_struct *mm) { +clear_bit (MMF_NEED_FLUSH , mm->flags); +/* Invalidate all TLB entries of this process by getting a new ASID */ if (mm->context !=NO_CONTEXT ) {unsigned long flags;diff -uprwNbB -X 2.6.23/Documentation/dontdiff
2.6.23/arch/cris/arch-v10/mm/tlb.c2.6.23a/arch/cris/arch-v10/mm/tlb.carch/cris/arch-v10/mm/tlb.c +2
-0@@ -69,6 +69,8 @@ flush_tlb_mm(struct mm_struct *mm)D (printk ("tlb: flush mm context %d (%p)\n" , page_id, mm)); +clear_bit (MMF_NEED_FLUSH , mm->flags); +if (page_id ==NO_CONTEXT )return ;diff -uprwNbB -X 2.6.23/Documentation/dontdiff
2.6.23/arch/cris/arch-v32/kernel/smp.c2.6.23a/arch/cris/arch-v32/kernel/smp.carch/cris/arch-v32/kernel/smp.c +1
-0@@ -237,6 +237,7 @@ void flush_tlb_all(void)void flush_tlb_mm (struct mm_struct *mm) { +clear_bit (MMF_NEED_FLUSH , mm->flags);__flush_tlb_mm (mm);flush_tlb_common (mm,FLUSH_ALL ,0 );/* No more mappings in other CPUs */ diff -uprwNbB -X 2.6.23/Documentation/dontdiff
2.6.23/arch/i386/kernel/smp.c2.6.23a/arch/i386/kernel/smp.carch/i386/kernel/smp.c +2
-0@@ -410,6 +410,8 @@ void flush_tlb_mm (struct mm_struct * mm {cpumask_t cpu_mask; +clear_bit (MMF_NEED_FLUSH , mm->flags); +preempt_disable (); cpu_mask = mm->cpu_vm_mask;cpu_clear (smp_processor_id (), cpu_mask);diff -uprwNbB -X 2.6.23/Documentation/dontdiff
2.6.23/arch/i386/mach-voyager/voyager_smp.c2.6.23a/arch/i386/mach-voyager/voyager_smp.carch/i386/mach-voyager/voyager_smp.c +2
-0@@ -924,6 +924,8 @@ flush_tlb_mm (struct mm_struct * mm) {unsigned long cpu_mask; +clear_bit (MMF_NEED_FLUSH , mm->flags); +preempt_disable (); cpu_mask =cpus_addr (mm->cpu_vm_mask)[0 ] & ~(1 <<smp_processor_id ());diff -uprwNbB -X 2.6.23/Documentation/dontdiff
2.6.23/arch/alpha/kernel/smp.c2.6.23a/arch/alpha/kernel/smp.carch/alpha/kernel/smp.c +2
-0@@ -850,6 +850,8 @@ flush_tlb_mm(struct mm_struct *mm) {preempt_disable (); +clear_bit (MMF_NEED_FLUSH , mm->flags); +if (mm == current->active_mm) {flush_tlb_current (mm);if (atomic_read (&mm->mm_users) <=1 ) {diff -uprwNbB -X 2.6.23/Documentation/dontdiff
2.6.23/arch/ia64/kernel/smp.c2.6.23a/arch/ia64/kernel/smp.carch/ia64/kernel/smp.c +2
-0@@ -325,6 +325,8 @@ smp_flush_tlb_all (void)void smp_flush_tlb_mm (struct mm_struct *mm) { +clear_bit (MMF_NEED_FLUSH , mm->flags); +preempt_disable ();/* this happens for the common case of a single-threaded fork(): */ if (likely (mm == current->active_mm &&atomic_read (&mm->mm_users) ==1 ))diff -uprwNbB -X 2.6.23/Documentation/dontdiff
2.6.23/arch/m32r/kernel/smp.c2.6.23a/arch/m32r/kernel/smp.carch/m32r/kernel/smp.c +2
-0@@ -280,6 +280,8 @@ void smp_flush_tlb_mm(struct mm_struct *unsigned long *mmc;unsigned long flags; +clear_bit (MMF_NEED_FLUSH , mm->flags); +preempt_disable (); cpu_id =smp_processor_id (); mmc = &mm->context[cpu_id];diff -uprwNbB -X 2.6.23/Documentation/dontdiff
2.6.23/arch/mips/kernel/smp.c2.6.23a/arch/mips/kernel/smp.carch/mips/kernel/smp.c +2
-0@@ -387,6 +387,8 @@ static inline void smp_on_each_tlb(voidvoid flush_tlb_mm (struct mm_struct *mm) { +clear_bit (MMF_NEED_FLUSH , mm->flags); +preempt_disable ();if ((atomic_read (&mm->mm_users) !=1 ) || (current->mm != mm)) {diff -uprwNbB -X 2.6.23/Documentation/dontdiff
2.6.23/arch/powerpc/mm/tlb_32.c2.6.23a/arch/powerpc/mm/tlb_32.carch/powerpc/mm/tlb_32.c +2
-0@@ -144,6 +144,8 @@ void flush_tlb_mm(struct mm_struct *mm) {struct vm_area_struct *mp; +clear_bit (MMF_NEED_FLUSH , mm->flags); +if (Hash ==0 ) {_tlbia ();return ;diff -uprwNbB -X 2.6.23/Documentation/dontdiff
2.6.23/arch/ppc/mm/tlb.c2.6.23a/arch/ppc/mm/tlb.carch/ppc/mm/tlb.c +2
-0@@ -144,6 +144,8 @@ void flush_tlb_mm(struct mm_struct *mm) {struct vm_area_struct *mp; +clear_bit (MMF_NEED_FLUSH , mm->flags); +if (Hash ==0 ) {_tlbia ();return ;diff -uprwNbB -X 2.6.23/Documentation/dontdiff
2.6.23/arch/sh64/mm/fault.c2.6.23a/arch/sh64/mm/fault.carch/sh64/mm/fault.c +2
-0@@ -517,6 +517,8 @@ void flush_tlb_mm(struct mm_struct *mm) ++calls_to_flush_tlb_mm;#endif +clear_bit (MMF_NEED_FLUSH , mm->flags); +if (mm->context ==NO_CONTEXT )return ;diff -uprwNbB -X 2.6.23/Documentation/dontdiff
2.6.23/arch/sparc/kernel/smp.c2.6.23a/arch/sparc/kernel/smp.carch/sparc/kernel/smp.c +2
-0@@ -163,6 +163,8 @@ void smp_flush_cache_mm(struct mm_structvoid smp_flush_tlb_mm (struct mm_struct *mm) { +clear_bit (MMF_NEED_FLUSH , mm->flags); +if (mm->context !=NO_CONTEXT ) {cpumask_t cpu_mask = mm->cpu_vm_mask;cpu_clear (smp_processor_id (), cpu_mask);diff -uprwNbB -X 2.6.23/Documentation/dontdiff
2.6.23/arch/sparc64/kernel/smp.c2.6.23a/arch/sparc64/kernel/smp.carch/sparc64/kernel/smp.c +2
-0@@ -1112,6 +1112,8 @@ void smp_flush_tlb_mm(struct mm_struct *u32 ctx =CTX_HWBITS (mm->context);int cpu =get_cpu (); +clear_bit (MMF_NEED_FLUSH , mm->flags); +if (atomic_read (&mm->mm_users) ==1 ) { mm->cpu_vm_mask =cpumask_of_cpu (cpu); goto local_flush_and_out;diff -uprwNbB -X 2.6.23/Documentation/dontdiff
2.6.23/arch/um/kernel/tlb.c2.6.23a/arch/um/kernel/tlb.carch/um/kernel/tlb.c +1
-0@@ -402,6 +402,7 @@ void flush_tlb_range(struct vm_area_struvoid flush_tlb_mm (struct mm_struct *mm) { +clear_bit (MMF_NEED_FLUSH , mm->flags);CHOOSE_MODE_PROC (flush_tlb_mm_tt, flush_tlb_mm_skas, mm); }diff -uprwNbB -X 2.6.23/Documentation/dontdiff
2.6.23/arch/xtensa/mm/tlb.c2.6.23a/arch/xtensa/mm/tlb.carch/xtensa/mm/tlb.c +2
-1@@ -63,6 +63,8 @@ void flush_tlb_all (void)void flush_tlb_mm (struct mm_struct *mm) { +clear_bit (MMF_NEED_FLUSH , mm->flags); +if (mm == current->active_mm) {int flags;local_save_flags (flags); --To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 8 lines
Yasunori Goto -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 3 lines · Yasunori Goto
Could you rebase them for newest kernel or -mm? And please remove many of "#if 1" in the second patch.
Sorry, the #if 1's are debugging code. I thought I had already gotten them all. I've just built the latest -mm. I'll be porting the patches over the next couple of days.
Ross
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>