linux-stable/include/asm-generic
Jeremy Fitzhardinge 1ea0704e0d mm: add a ptep_modify_prot transaction abstraction
This patch adds an API for doing read-modify-write updates to a pte's
protection bits which may race against hardware updates to the pte.
After reading the pte, the hardware may asynchonously set the accessed
or dirty bits on a pte, which would be lost when writing back the
modified pte value.

The existing technique to handle this race is to use
ptep_get_and_clear() atomically fetch the old pte value and clear it
in memory.  This has the effect of marking the pte as non-present,
which will prevent the hardware from updating its state.  When the new
value is written back, the pte will be present again, and the hardware
can resume updating the access/dirty flags.

When running in a virtualized environment, pagetable updates are
relatively expensive, since they generally involve some trap into the
hypervisor.  To mitigate the cost of these updates, we tend to batch
them.

However, because of the atomic nature of ptep_get_and_clear(), it is
inherently non-batchable.  This new interface allows batching by
giving the underlying implementation enough information to open a
transaction between the read and write phases:

ptep_modify_prot_start() returns the current pte value, and puts the
  pte entry into a state where either the hardware will not update the
  pte, or if it does, the updates will be preserved on commit.

ptep_modify_prot_commit() writes back the updated pte, makes sure that
  any hardware updates made since ptep_modify_prot_start() are
  preserved.

ptep_modify_prot_start() and _commit() must be exactly paired, and
used while holding the appropriate pte lock.  They do not protect
against other software updates of the pte in any way.

The current implementations of ptep_modify_prot_start and _commit are
functionally unchanged from before: _start() uses ptep_get_and_clear()
fetch the pte and zero the entry, preventing any hardware updates.
_commit() simply writes the new pte value back knowing that the
hardware has not updated the pte in the meantime.

The only current user of this interface is mprotect

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Acked-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-06-25 15:15:53 +02:00
..
bitops bitops: use __fls for fls64 on 64-bit archs 2008-04-26 19:21:16 +02:00
4level-fixup.h add mm argument to pte/pmd/pud/pgd_free 2008-02-05 09:44:18 -08:00
atomic.h atomic.h: atomic_add_unless as inline. Remove system.h atomic.h circular dependency 2007-05-08 11:15:20 -07:00
audit_change_attr.h [PATCH] fix missing ifdefs in syscall classes hookup for generic targets 2006-09-22 17:48:56 -07:00
audit_dir_write.h [PATCH] fix missing ifdefs in syscall classes hookup for generic targets 2006-09-22 17:48:56 -07:00
audit_read.h [PATCH] audit: more syscall classes added 2006-09-11 13:32:27 -04:00
audit_signal.h [PATCH] add SIGNAL syscall class (v3) 2007-05-11 05:38:25 -04:00
audit_write.h [PATCH] audit: more syscall classes added 2006-09-11 13:32:27 -04:00
bitops.h remove __KERNEL__ tests of unexported headers under asm-generic/ 2008-04-30 08:29:54 -07:00
bug.h debug: move WARN_ON() out of line 2008-01-30 13:32:50 +01:00
cmpxchg-local.h Add cmpxchg_local to asm-generic for per cpu atomic operations 2008-02-07 08:42:30 -08:00
cmpxchg.h Add cmpxchg_local to asm-generic for per cpu atomic operations 2008-02-07 08:42:30 -08:00
cputime.h taskstats scaled time cleanup 2008-02-06 10:41:00 -08:00
device.h Driver core: add dev_archdata to struct device 2006-12-01 14:52:01 -08:00
div64.h rename div64_64 to div64_u64 2008-05-01 08:03:58 -07:00
dma-mapping-broken.h dma-mapping: prevent dma dependent code from linking on !HAS_DMA archs 2007-07-16 09:05:45 -07:00
dma-mapping.h [PATCH] Pass struct dev pointer to dma_cache_sync() 2006-12-07 08:39:41 -08:00
emergency-restart.h
errno-base.h
errno.h
fcntl.h Introduce O_CLOEXEC 2007-07-16 09:05:45 -07:00
futex.h remove __KERNEL__ tests of unexported headers under asm-generic/ 2008-04-30 08:29:54 -07:00
gpio.h gpio: build fixes 2008-05-24 09:56:13 -07:00
ide_iops.h
int-l64.h types: add C99-style constructors to <asm-generic/int-*.h> 2008-05-02 16:18:42 -07:00
int-ll64.h types: add C99-style constructors to <asm-generic/int-*.h> 2008-05-02 16:18:42 -07:00
ioctl.h generalize asm-generic/ioctl.h to allow overriding values 2008-04-29 08:06:24 -07:00
iomap.h generic: add ioremap_wc() interface wrapper 2008-04-24 23:40:47 +02:00
irq_regs.h IRQ: Maintain regs pointer globally rather than passing to IRQ handlers 2006-10-05 15:10:12 +01:00
Kbuild types: create <asm-generic/int-*.h> 2008-05-02 16:18:19 -07:00
Kbuild.asm kvm: provide kvm.h for all architecture: fixes headers_install 2008-04-02 15:28:18 -07:00
kdebug.h move die notifier handling to common code 2007-05-08 11:15:04 -07:00
libata-portmap.h libata-portmap: Remove unused definitions 2007-10-12 14:55:37 -04:00
local.h local_t: architecture independent extension 2007-05-08 11:15:20 -07:00
memory_model.h remove __KERNEL__ tests of unexported headers under asm-generic/ 2008-04-30 08:29:54 -07:00
mm_hooks.h [PATCH] x86: PARAVIRT: add hooks to intercept mm creation and destruction 2007-05-02 19:27:14 +02:00
mman.h [PATCH] Remove final references to deprecated "MAP_ANON" page protection flag 2007-02-11 10:51:17 -08:00
mutex-dec.h asm-generic: remove fastcall 2008-02-08 09:22:31 -08:00
mutex-null.h fix file specification in comments 2006-10-03 23:01:26 +02:00
mutex-xchg.h asm-generic: remove fastcall 2008-02-08 09:22:31 -08:00
page.h remove __KERNEL__ tests of unexported headers under asm-generic/ 2008-04-30 08:29:54 -07:00
pci-dma-compat.h
pci.h
percpu.h percpu: fix DEBUG_PREEMPT per_cpu checking 2008-02-23 12:09:28 -08:00
pgtable-nopmd.h add mm argument to pte/pmd/pud/pgd_free 2008-02-05 09:44:18 -08:00
pgtable-nopud.h add mm argument to pte/pmd/pud/pgd_free 2008-02-05 09:44:18 -08:00
pgtable.h mm: add a ptep_modify_prot transaction abstraction 2008-06-25 15:15:53 +02:00
poll.h Consolidate asm/poll.h 2007-05-11 08:29:34 -07:00
resource.h sched: SCHED_FIFO/SCHED_RR watchdog timer 2008-01-25 21:08:27 +01:00
rtc.h remove __KERNEL__ tests of unexported headers under asm-generic/ 2008-04-30 08:29:54 -07:00
sections.h remove support for un-needed _extratext section 2008-02-06 10:41:01 -08:00
siginfo.h
signal.h Add standard include guard to asm-generic/signal and use compiler.h 2006-04-27 06:57:23 +01:00
statfs.h
termios.h tty: let architectures override the user/kernel macros. 2008-02-08 09:22:24 -08:00
tlb.h asm-generic/tlb.h: remove <linux/quicklist.h> 2008-02-04 16:48:00 +01:00
topology.h asm-generic: add node_to_cpumask_ptr macro 2008-04-19 19:44:58 +02:00
uaccess.h
vmlinux.lds.h Add missing init section definitions 2008-02-19 21:00:18 +01:00
xor.h