[IA64] Avoid unnecessary TLB flushes when allocating memory

Improve performance of memory allocations on ia64 by avoiding a global TLB
purge to purge a single page from the file cache. This happens whenever we
evict a page from the buffer cache to make room for some other allocation.

Test case: Run 'find /usr -type f | xargs cat > /dev/null' in the
background to fill the buffer cache, then run something that uses memory,
e.g. 'gmake -j50 install'. Instrumentation showed that the number of
global TLB purges went from a few millions down to about 170 over a 12
hours run of the above.

The performance impact is particularly noticeable under virtualization,
because a virtual TLB is generally both larger and slower to purge than
a physical one.

Signed-off-by: Christophe de Dinechin <ddd@hp.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>

authored by de Dinechin, Christophe (Integrity VM) and committed by Tony Luck aec103bf 3cdc7fc7

+15 -3
+15 -3
arch/ia64/mm/tlb.c
··· 10 10 * IPI based ptc implementation and A-step IPI implementation. 11 11 * Rohit Seth <rohit.seth@intel.com> 12 12 * Ken Chen <kenneth.w.chen@intel.com> 13 + * Christophe de Dinechin <ddd@hp.com>: Avoid ptc.e on memory allocation 13 14 */ 14 15 #include <linux/module.h> 15 16 #include <linux/init.h> ··· 90 89 { 91 90 static DEFINE_SPINLOCK(ptcg_lock); 92 91 93 - if (mm != current->active_mm || !current->mm) { 94 - flush_tlb_all(); 95 - return; 92 + struct mm_struct *active_mm = current->active_mm; 93 + 94 + if (mm != active_mm) { 95 + /* Restore region IDs for mm */ 96 + if (mm && active_mm) { 97 + activate_context(mm); 98 + } else { 99 + flush_tlb_all(); 100 + return; 101 + } 96 102 } 97 103 98 104 /* HW requires global serialization of ptc.ga. */ ··· 115 107 } while (start < end); 116 108 } 117 109 spin_unlock(&ptcg_lock); 110 + 111 + if (mm != active_mm) { 112 + activate_context(active_mm); 113 + } 118 114 } 119 115 120 116 void