提交 ea0ffd0c 编写于 作者: K Kairui Song 提交者: Andrew Morton

swap: add a limit for readahead page-cluster value

Currenty there is no upper limit for /proc/sys/vm/page-cluster, and it's a
bit shift value, so it could result in overflow of the 32-bit integer. 
Add a reasonable upper limit for it, read-in at most 2**31 pages, which is
a large enough value for readahead.

Link: https://lkml.kernel.org/r/20221023162533.81561-1-ryncsn@gmail.comSigned-off-by: NKairui Song <kasong@tencent.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
上级 5033091d
...@@ -74,6 +74,7 @@ static inline void totalram_pages_add(long count) ...@@ -74,6 +74,7 @@ static inline void totalram_pages_add(long count)
extern void * high_memory; extern void * high_memory;
extern int page_cluster; extern int page_cluster;
extern const int page_cluster_max;
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
extern int sysctl_legacy_va_layout; extern int sysctl_legacy_va_layout;
......
...@@ -2125,6 +2125,7 @@ static struct ctl_table vm_table[] = { ...@@ -2125,6 +2125,7 @@ static struct ctl_table vm_table[] = {
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ZERO, .extra1 = SYSCTL_ZERO,
.extra2 = (void *)&page_cluster_max,
}, },
{ {
.procname = "dirtytime_expire_seconds", .procname = "dirtytime_expire_seconds",
......
...@@ -43,8 +43,9 @@ ...@@ -43,8 +43,9 @@
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
#include <trace/events/pagemap.h> #include <trace/events/pagemap.h>
/* How many pages do we try to swap or page in/out together? */ /* How many pages do we try to swap or page in/out together? As a power of 2 */
int page_cluster; int page_cluster;
const int page_cluster_max = 31;
/* Protecting only lru_rotate.fbatch which requires disabling interrupts */ /* Protecting only lru_rotate.fbatch which requires disabling interrupts */
struct lru_rotate { struct lru_rotate {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册