android_kernel_samsung_msm8976/arch/sparc/mm
David S. Miller f36391d279 sparc64: Fix race in TLB batch processing.
As reported by Dave Kleikamp, when we emit cross calls to do batched
TLB flush processing we have a race because we do not synchronize on
the sibling cpus completing the cross call.

So meanwhile the TLB batch can be reset (tb->tlb_nr set to zero, etc.)
and either flushes are missed or flushes will flush the wrong
addresses.

Fix this by using generic infrastructure to synchonize on the
completion of the cross call.

This first required getting the flush_tlb_pending() call out from
switch_to() which operates with locks held and interrupts disabled.
The problem is that smp_call_function_many() cannot be invoked with
IRQs disabled and this is explicitly checked for with WARN_ON_ONCE().

We get the batch processing outside of locked IRQ disabled sections by
using some ideas from the powerpc port. Namely, we only batch inside
of arch_{enter,leave}_lazy_mmu_mode() calls.  If we're not in such a
region, we flush TLBs synchronously.

1) Get rid of xcall_flush_tlb_pending and per-cpu type
   implementations.

2) Do TLB batch cross calls instead via:

	smp_call_function_many()
		tlb_pending_func()
			__flush_tlb_pending()

3) Batch only in lazy mmu sequences:

	a) Add 'active' member to struct tlb_batch
	b) Define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
	c) Set 'active' in arch_enter_lazy_mmu_mode()
	d) Run batch and clear 'active' in arch_leave_lazy_mmu_mode()
	e) Check 'active' in tlb_batch_add_one() and do a synchronous
           flush if it's clear.

4) Add infrastructure for synchronous TLB page flushes.

	a) Implement __flush_tlb_page and per-cpu variants, patch
	   as needed.
	b) Likewise for xcall_flush_tlb_page.
	c) Implement smp_flush_tlb_page() to invoke the cross-call.
	d) Wire up global_flush_tlb_page() to the right routine based
           upon CONFIG_SMP

5) It turns out that singleton batches are very common, 2 out of every
   3 batch flushes have only a single entry in them.

   The batch flush waiting is very expensive, both because of the poll
   on sibling cpu completeion, as well as because passing the tlb batch
   pointer to the sibling cpus invokes a shared memory dereference.

   Therefore, in flush_tlb_pending(), if there is only one entry in
   the batch perform a completely asynchronous global_flush_tlb_page()
   instead.

Reported-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Dave Kleikamp <dave.kleikamp@oracle.com>
2013-04-19 17:26:26 -04:00
..
Makefile sparc32: introduce run-time patching of srmmu access functions 2012-05-27 23:52:49 -07:00
extable.c sparc: Add module.h to files previously implicitly using it. 2011-10-31 19:30:54 -04:00
fault_32.c readahead: fault retry breaks mmap file read random detection 2012-10-09 16:22:47 +09:00
fault_64.c sparc64: Fix tsb_grow() in atomic context. 2013-02-20 09:46:08 -08:00
gup.c sparc64: Fix get_user_pages_fast() wrt. THP. 2013-02-13 12:22:14 -08:00
highmem.c sparc32: move kmap_init() to highmem.c 2012-07-26 16:46:17 -07:00
hugetlbpage.c mm: use vm_unmapped_area() in hugetlbfs on sparc64 architecture 2012-12-11 17:22:26 -08:00
hypersparc.S
init_32.c swap: add per-partition lock for swapfile 2013-02-23 17:50:17 -08:00
init_64.c memory-hotplug: remove memmap of sparse-vmemmap 2013-02-23 17:50:12 -08:00
init_64.h sparc64: Support 2GB and 16GB page sizes for kernel linear mappings. 2012-09-06 18:13:58 -07:00
io-unit.c sparc32: Convert mmu_* interfaces from btfixup to method ops. 2012-05-13 13:57:05 -07:00
iommu.c sparc/iommu: fix typo s/265KB/256KB/ 2013-03-31 19:29:12 -04:00
leon_mm.c sparc32: srmmu_probe now knows about leon too 2012-05-27 23:52:51 -07:00
srmmu.c sparc/srmmu: clear trailing edge of bitmap properly 2013-03-31 19:29:12 -04:00
srmmu.h sparc32,leon: move leon mmu functions to leon_mm.c 2012-05-19 23:27:38 -07:00
srmmu_access.S sparc32: introduce run-time patching of srmmu access functions 2012-05-27 23:52:49 -07:00
swift.S
tlb.c sparc64: Fix race in TLB batch processing. 2013-04-19 17:26:26 -04:00
tsb.c sparc64: Fix race in TLB batch processing. 2013-04-19 17:26:26 -04:00
tsunami.S
ultra.S sparc64: Fix race in TLB batch processing. 2013-04-19 17:26:26 -04:00
viking.S sparc32: remove runtime btfix support 2012-05-14 14:05:09 -07:00