linux/include
Nick Piggin 557ed1fa26 remove ZERO_PAGE
The commit b5810039a5 contains the note

  A last caveat: the ZERO_PAGE is now refcounted and managed with rmap
  (and thus mapcounted and count towards shared rss).  These writes to
  the struct page could cause excessive cacheline bouncing on big
  systems.  There are a number of ways this could be addressed if it is
  an issue.

And indeed this cacheline bouncing has shown up on large SGI systems.
There was a situation where an Altix system was essentially livelocked
tearing down ZERO_PAGE pagetables when an HPC app aborted during startup.
This situation can be avoided in userspace, but it does highlight the
potential scalability problem with refcounting ZERO_PAGE, and corner
cases where it can really hurt (we don't want the system to livelock!).

There are several broad ways to fix this problem:
1. add back some special casing to avoid refcounting ZERO_PAGE
2. per-node or per-cpu ZERO_PAGES
3. remove the ZERO_PAGE completely

I will argue for 3. The others should also fix the problem, but they
result in more complex code than does 3, with little or no real benefit
that I can see.

Why? Inserting a ZERO_PAGE for anonymous read faults appears to be a
false optimisation: if an application is performance critical, it would
not be doing many read faults of new memory, or at least it could be
expected to write to that memory soon afterwards. If cache or memory use
is critical, it should not be working with a significant number of
ZERO_PAGEs anyway (a more compact representation of zeroes should be
used).

As a sanity check -- mesuring on my desktop system, there are never many
mappings to the ZERO_PAGE (eg. 2 or 3), thus memory usage here should not
increase much without it.

When running a make -j4 kernel compile on my dual core system, there are
about 1,000 mappings to the ZERO_PAGE created per second, but about 1,000
ZERO_PAGE COW faults per second (less than 1 ZERO_PAGE mapping per second
is torn down without being COWed). So removing ZERO_PAGE will save 1,000
page faults per second when running kbuild, while keeping it only saves
less than 1 page clearing operation per second. 1 page clear is cheaper
than a thousand faults, presumably, so there isn't an obvious loss.

Neither the logical argument nor these basic tests give a guarantee of no
regressions. However, this is a reasonable opportunity to try to remove
the ZERO_PAGE from the pagefault path. If it is found to cause regressions,
we can reintroduce it and just avoid refcounting it.

The /dev/zero ZERO_PAGE usage and TLB tricks also get nuked.  I don't see
much use to them except on benchmarks.  All other users of ZERO_PAGE are
converted just to use ZERO_PAGE(0) for simplicity. We can look at
replacing them all and maybe ripping out ZERO_PAGE completely when we are
more satisfied with this solution.

Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus "snif" Torvalds <torvalds@linux-foundation.org>
2007-10-16 09:42:53 -07:00
..
acpi ACPI: CONFIG_ACPI_SLEEP=n power off regression in 2.6.23-rc8 (NOT in rc7) 2007-09-25 17:58:52 -04:00
asm-alpha Fix Alpha O_CLOEXEC definition 2007-08-09 08:39:22 -07:00
asm-arm Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm 2007-10-15 16:08:50 -07:00
asm-avr32 x86: optimize page faults like all other achitectures and kill notifier cruft 2007-10-16 09:42:50 -07:00
asm-blackfin Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2007-10-15 13:41:39 -07:00
asm-cris remove unused TIF_NOTIFY_RESUME flag 2007-07-31 15:39:38 -07:00
asm-frv frv: missing casts in cmpxchg() 2007-10-14 12:41:51 -07:00
asm-generic Generic Virtual Memmap support for SPARSEMEM 2007-10-16 09:42:51 -07:00
asm-h8300 Binfmt_flat: Add minimum support for the Blackfin relocations 2007-10-03 23:41:43 +08:00
asm-ia64 IA64: SPARSEMEM_VMEMMAP 16K page size support 2007-10-16 09:42:51 -07:00
asm-m32r Binfmt_flat: Add minimum support for the Blackfin relocations 2007-10-03 23:41:43 +08:00
asm-m68k m68k: Export cachectl.h 2007-10-13 09:41:03 -07:00
asm-m68knommu Binfmt_flat: Add minimum support for the Blackfin relocations 2007-10-03 23:41:43 +08:00
asm-mips move a few definitions to au1000_xxs1500.c 2007-10-16 09:42:50 -07:00
asm-parisc [PARISC] Add dummy isa_(bus|virt)_to_(virt|bus) inlines 2007-08-27 00:29:22 -04:00
asm-powerpc ppc64: SPARSEMEM_VMEMMAP support 2007-10-16 09:42:51 -07:00
asm-ppc [POWERPC] Prevent direct inclusion of <asm/rwsem.h>. 2007-09-22 14:49:21 +10:00
asm-s390 x86: optimize page faults like all other achitectures and kill notifier cruft 2007-10-16 09:42:50 -07:00
asm-sh x86: optimize page faults like all other achitectures and kill notifier cruft 2007-10-16 09:42:50 -07:00
asm-sh64 Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh64-2.6 2007-10-13 09:50:26 -07:00
asm-sparc [SPARC32]: Add irqflags.h to sparc32 and use it from generic code. 2007-10-13 21:53:11 -07:00
asm-sparc64 SPARC64: SPARSEMEM_VMEMMAP support 2007-10-16 09:42:51 -07:00
asm-um UML: Fix ELF_CORE_COPY_REGS build botch 2007-09-10 18:58:05 -07:00
asm-v850 Binfmt_flat: Add minimum support for the Blackfin relocations 2007-10-03 23:41:43 +08:00
asm-x86 x86_64: SPARSEMEM_VMEMMAP 2M page size support 2007-10-16 09:42:51 -07:00
asm-xtensa [patch 1/2] Xtensa: enable arbitary tty speed setting ioctls 2007-08-27 13:54:25 -07:00
crypto [CRYPTO] sha: Add header file for SHA definitions 2007-10-10 16:55:50 -07:00
keys [AF_RXRPC]: Provide secure RxRPC sockets for use by userspace and kernel both 2007-04-26 15:48:28 -07:00
linux remove ZERO_PAGE 2007-10-16 09:42:53 -07:00
math-emu Fix <math-emu/soft-fp.h> tpyo 2007-08-18 17:15:17 -07:00
media v4l: copy_to_user() is not a good method name 2007-10-13 09:58:59 -07:00
mtd UBI: kill homegrown endian macros 2007-07-18 16:53:49 +03:00
net [IPV6]: Replace sk_buff ** with sk_buff * in input handlers 2007-10-15 12:50:28 -07:00
pcmcia pcmcia: use DMA_MASK_NONE for the default for all pcmcia devices 2007-10-16 09:42:50 -07:00
rdma IB/cm: Modify interface to send MRAs in response to duplicate messages 2007-10-09 19:59:17 -07:00
rxrpc [AF_RXRPC]: Delete the old RxRPC code. 2007-04-26 15:55:48 -07:00
scsi Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6 2007-10-15 08:19:33 -07:00
sound [ALSA] version 1.0.14 2007-07-20 11:13:35 +02:00
video remove tx3912fb 2007-07-31 15:39:41 -07:00
xen xen: xen/page.h compile fix 2007-07-26 11:35:16 -07:00
Kbuild