]> git.karo-electronics.de Git - karo-tx-linux.git/commit
swap: add a simple detector for inappropriate swapin readahead
authorShaohua Li <shli@kernel.org>
Thu, 25 Oct 2012 01:14:53 +0000 (12:14 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 26 Oct 2012 04:05:25 +0000 (15:05 +1100)
commit77dd0a32202bd6d9d92dcb0a01b7414e2dff8511
tree76c56d6cd26481cab4514d2bb1435bd0c3b48f6b
parent2efb6e105967834c5dd158e15904cba361845e33
swap: add a simple detector for inappropriate swapin readahead

The swapin readahead does a blind readahead whether or not the swapin is
sequential.  This is ok for harddisk because large reads have relatively
small costs and if the readahead pages are unneeded they can be reclaimed
easily.  But for SSD devices large reads are more expensive than small
one.  If readahead pages are unneeded, reading them in caused significant
overhead

This patch addes a simple random read detection similar to file mmap
readahead.  If a random read is detected, swapin readahead will be
skipped.  This improves a lot for a swap workload with random IO in a fast
SSD.

I run anonymous mmap write micro benchmark, which will triger swapin/swapout.

runtime changes with patch
randwrite harddisk -38.7%
seqwrite harddisk -1.1%
randwrite SSD -46.9%
seqwrite SSD +0.3%

For both harddisk and SSD, the randwrite swap workload run time is reduced
significantly.  Sequential write swap workload hasn't chanage.

Interestingly, the randwrite harddisk test is improved too.  This might be
because swapin readahead needs to allocate extra memory, which further
tights memory pressure, so more swapout/swapin.

Signed-off-by: Shaohua Li <shli@fusionio.com>
Acked-by: Rik van Riel <riel@redhat.com>
Cc: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/rmap.h
mm/internal.h
mm/memory.c
mm/rmap.c
mm/shmem.c
mm/swap_state.c