android_kernel_google_msm/arch
David S. Miller bf6f841f7f sparc64: Fix race in TLB batch processing.
[ Commits f36391d279 and
  f0af97070a upstream. ]

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-05-01 09:41:03 -07:00
..
alpha alpha: Add irongate_io to PCI bus resources 2013-04-12 09:38:45 -07:00
arm ARM: 7698/1: perf: fix group validation when using enable_on_exec 2013-04-25 21:19:55 -07:00
avr32 signal: Define __ARCH_HAS_SA_RESTORER so we know whether to clear sa_restorer 2013-04-05 10:04:14 -07:00
blackfin blackfin: fix ifdef fustercluck in mach-bf538/boards/ezkit.c 2012-04-26 14:46:51 -04:00
c6x irq: Kill pointless irqd_to_hw export 2012-04-10 22:39:17 -06:00
cris signal: Define __ARCH_HAS_SA_RESTORER so we know whether to clear sa_restorer 2013-04-05 10:04:14 -07:00
frv frv: Add missing RCU idle APIs on idle loop 2012-10-13 05:38:54 +09:00
h8300 signal: Define __ARCH_HAS_SA_RESTORER so we know whether to clear sa_restorer 2013-04-05 10:04:14 -07:00
hexagon hexagon: add missing cpu.h include 2012-04-23 12:57:24 -05:00
ia64 ia64: Add missing RCU idle APIs on idle loop 2012-10-13 05:38:53 +09:00
m32r signal: Define __ARCH_HAS_SA_RESTORER so we know whether to clear sa_restorer 2013-04-05 10:04:14 -07:00
m68k signal: Define __ARCH_HAS_SA_RESTORER so we know whether to clear sa_restorer 2013-04-05 10:04:14 -07:00
microblaze microblaze: Do not select GENERIC_GPIO by default 2012-06-10 00:36:05 +09:00
mips MIPS: Fix poweroff failure when HOTPLUG_CPU configured. 2013-01-17 08:50:42 -08:00
mn10300 signal: Define __ARCH_HAS_SA_RESTORER so we know whether to clear sa_restorer 2013-04-05 10:04:14 -07:00
openrisc
parisc Purge existing TLB entries in set_pte_at and ptep_set_wrprotect 2013-02-28 06:59:05 -08:00
powerpc powerpc: pSeries_lpar_hpte_remove fails from Adjunct partition being performed before the ANDCOND test 2013-04-12 09:38:45 -07:00
s390 signal: Define __ARCH_HAS_SA_RESTORER so we know whether to clear sa_restorer 2013-04-05 10:04:14 -07:00
score score: Add missing RCU idle APIs on idle loop 2012-10-13 05:38:55 +09:00
sh sh: Fix FDPIC binary loader 2013-01-21 11:45:14 -08:00
sparc sparc64: Fix race in TLB batch processing. 2013-05-01 09:41:03 -07:00
tile tile: expect new initramfs name from hypervisor file system 2013-04-05 10:04:14 -07:00
um um: Implement a custom pte_same() function 2012-06-01 15:18:18 +08:00
unicore32 Merge branch 'for-linus' of git://git.linaro.org/people/mszyprowski/linux-dma-mapping 2012-04-04 17:13:43 -07:00
x86 perf/x86: Fix offcore_rsp valid mask for SNB/IVB 2013-04-25 21:19:55 -07:00
xtensa signal: Define __ARCH_HAS_SA_RESTORER so we know whether to clear sa_restorer 2013-04-05 10:04:14 -07:00
.gitignore
Kconfig Merge git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile 2012-03-29 14:49:45 -07:00