提交 2e38a0f2 编写于 作者: X Xiaoguang Wang 提交者: Shile Zhang

alinux: mm: add proc interface to control context readahead

For some workloads whose io activities are mostly random, context
readahead feature can introduce unnecessary io read operations, which
will impact app's performance. Context readahead's algorithm is
straightforward and not that smart.

This patch adds "/proc/sys/vm/enable_context_readahead" to control
whether to disable or enable this feature. Currently we enable context
readahead default, user can echo 0 to /proc/sys/vm/enable_context_readahead
to disable context readahead.

We also have tested mongodb's performance in 'random point select' case,
With context readahead enabled:
  mongodb eps 12409
With context readahead disabled:
  mongodb eps 14443
About 16% performance improvement.
Signed-off-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Reviewed-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
上级 db153a10
......@@ -65,6 +65,7 @@ Currently, these files are in /proc/sys/vm:
- vfs_cache_pressure
- watermark_scale_factor
- zone_reclaim_mode
- enable_context_readahead
==============================================================
......@@ -910,4 +911,20 @@ Allowing regular swap effectively restricts allocations to the local
node unless explicitly overridden by memory policies or cpuset
configurations.
==============================================================
enable_context_readahead:
Specific workloads whose io activities are mostly random, context readahead
feature may introduce unnecessary io read operations, which will impact app's
performance.
Default it is enabled.
To disable context readahead:
echo 0 > /proc/sys/vm/enable_context_readahead
To enable context readahead again:
echo 1 > /proc/sys/vm/enable_context_readahead
============ End of Document =================================
......@@ -262,6 +262,8 @@ extern struct ctl_table epoll_table[];
extern struct ctl_table firmware_config_table[];
#endif
extern int sysctl_enable_context_readahead;
#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
int sysctl_legacy_va_layout;
#endif
......@@ -1666,6 +1668,15 @@ static struct ctl_table vm_table[] = {
.extra2 = (void *)&mmap_rnd_compat_bits_max,
},
#endif
{
.procname = "enable_context_readahead",
.data = &sysctl_enable_context_readahead,
.maxlen = sizeof(sysctl_enable_context_readahead),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = &zero,
.extra2 = &one,
},
{ }
};
......
......@@ -24,6 +24,9 @@
#include "internal.h"
/* enable context readahead default */
int sysctl_enable_context_readahead = 1;
/*
* Initialise a struct file's readahead state. Assumes that the caller has
* memset *ra to zero.
......@@ -458,8 +461,11 @@ ondemand_readahead(struct address_space *mapping,
* Query the page cache and look for the traces(cached history pages)
* that a sequential stream would leave behind.
*/
if (try_context_readahead(mapping, ra, offset, req_size, max_pages))
goto readit;
if (sysctl_enable_context_readahead) {
if (try_context_readahead(mapping, ra, offset, req_size,
max_pages))
goto readit;
}
/*
* standalone, small random read
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册