summaryrefslogtreecommitdiff
path: root/mm/swap.c
diff options
context:
space:
mode:
authorKairui Song <kasong@tencent.com>2022-10-23 19:25:33 +0300
committerAndrew Morton <akpm@linux-foundation.org>2022-11-09 04:37:22 +0300
commitea0ffd0c08d0fef1f6e93eb07badbeeabf6b43d6 (patch)
tree7c51a3389015d022f9a2b98a2157e2de31216605 /mm/swap.c
parent5033091de814ab4b5623faed2755f3064e19e2d2 (diff)
downloadlinux-ea0ffd0c08d0fef1f6e93eb07badbeeabf6b43d6.tar.xz
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.com Signed-off-by: Kairui Song <kasong@tencent.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/swap.c')
-rw-r--r--mm/swap.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mm/swap.c b/mm/swap.c
index 2f12a2ee1d3a..b9a6817e07ff 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -43,8 +43,9 @@
#define CREATE_TRACE_POINTS
#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;
+const int page_cluster_max = 31;
/* Protecting only lru_rotate.fbatch which requires disabling interrupts */
struct lru_rotate {