]>
Commit | Line | Data |
---|---|---|
9a2797cc AM |
1 | ; https://github.com/bobrik/linux/pull/2 |
2 | From 1910e1157eb4b455b877a813f0a1b786dcbf799c Mon Sep 17 00:00:00 2001 | |
3 | From: Ivan Babrou <ibobrik@gmail.com> | |
4 | Date: Tue, 27 Nov 2018 14:37:25 -0800 | |
5 | Subject: [PATCH] xfs: add a sysctl to disable memory reclaim participation | |
6 | ||
7 | XFS may try to flush dirty inodes in reclaim and it slows things down | |
8 | considerably, especially in high page cache and slow disk environment. | |
9 | ||
10 | This sysctl allows to exclude XFS from kswapd and direct reclaim. | |
11 | ||
12 | See: https://marc.info/?t=154345187200003 | |
eca34b5c | 13 | diff --git a/Documentation/admin-guide/xfs.rst b/Documentation/admin-guide/xfs.rst |
9a2797cc | 14 | index 3b9b5c149f322..b33a4822f879c 100644 |
eca34b5c AM |
15 | --- a/Documentation/admin-guide/xfs.rst |
16 | +++ b/Documentation/admin-guide/xfs.rst | |
9a2797cc AM |
17 | @@ -331,6 +331,12 @@ The following sysctls are available for the XFS filesystem: |
18 | is to control the rate at which the allocator moves between | |
19 | allocation groups when allocating extents for new files. | |
20 | ||
21 | + fs.xfs.memory_reclaim (Min: 0 Default: 2 Max: 2) | |
22 | + Set memory reclaim strategy: | |
23 | + 0: no inode reclaim (background reclaim is still enabled) | |
24 | + 1: async inode reclaim of clean inodes only | |
25 | + 2: sync inode reclaim (includes synchronous writes) | |
26 | + | |
27 | Deprecated Sysctls | |
28 | ================== | |
29 | ||
30 | diff --git a/fs/xfs/xfs_globals.c b/fs/xfs/xfs_globals.c | |
31 | index 3e1cc3001bcbf..2927cc2b12b57 100644 | |
32 | --- a/fs/xfs/xfs_globals.c | |
33 | +++ b/fs/xfs/xfs_globals.c | |
34 | @@ -43,6 +43,7 @@ xfs_param_t xfs_params = { | |
35 | .fstrm_timer = { 1, 30*100, 3600*100}, | |
36 | .eofb_timer = { 1, 300, 3600*24}, | |
37 | .cowb_timer = { 1, 1800, 3600*24}, | |
38 | + .memory_reclaim = { 0, 2, 2, }, | |
39 | }; | |
40 | ||
41 | struct xfs_globals xfs_globals = { | |
42 | diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c | |
43 | index 544b5211221cd..54fcf1af7e3f5 100644 | |
44 | --- a/fs/xfs/xfs_icache.c | |
45 | +++ b/fs/xfs/xfs_icache.c | |
46 | @@ -1380,7 +1380,11 @@ xfs_reclaim_inodes_nr( | |
47 | xfs_reclaim_work_queue(mp); | |
48 | xfs_ail_push_all(mp->m_ail); | |
49 | ||
50 | - return xfs_reclaim_inodes_ag(mp, SYNC_TRYLOCK | SYNC_WAIT, &nr_to_scan); | |
51 | + int flags = SYNC_TRYLOCK; | |
52 | + if (xfs_memory_reclaim == XFS_MEMORY_RECLAIM_SYNC) | |
53 | + flags |= SYNC_WAIT; | |
54 | + | |
55 | + return xfs_reclaim_inodes_ag(mp, flags, &nr_to_scan); | |
56 | } | |
57 | ||
58 | /* | |
59 | diff --git a/fs/xfs/xfs_icache.h b/fs/xfs/xfs_icache.h | |
60 | index bff4d85e54984..2547c0d85e5a1 100644 | |
61 | --- a/fs/xfs/xfs_icache.h | |
62 | +++ b/fs/xfs/xfs_icache.h | |
63 | @@ -54,6 +54,12 @@ struct xfs_eofblocks { | |
64 | */ | |
65 | #define XFS_AGITER_INEW_WAIT 0x1 /* wait on new inodes */ | |
66 | ||
67 | +enum { | |
68 | + XFS_MEMORY_RECLAIM_NONE = 0, | |
69 | + XFS_MEMORY_RECLAIM_ASYNC, | |
70 | + XFS_MEMORY_RECLAIM_SYNC, | |
71 | +}; | |
72 | + | |
73 | int xfs_iget(struct xfs_mount *mp, struct xfs_trans *tp, xfs_ino_t ino, | |
74 | uint flags, uint lock_flags, xfs_inode_t **ipp); | |
75 | ||
76 | diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h | |
77 | index dcd1292664b34..3cddbffaa8cb4 100644 | |
78 | --- a/fs/xfs/xfs_linux.h | |
79 | +++ b/fs/xfs/xfs_linux.h | |
80 | @@ -110,6 +110,7 @@ typedef __u32 xfs_nlink_t; | |
81 | #define xfs_fstrm_centisecs xfs_params.fstrm_timer.val | |
82 | #define xfs_eofb_secs xfs_params.eofb_timer.val | |
83 | #define xfs_cowb_secs xfs_params.cowb_timer.val | |
84 | +#define xfs_memory_reclaim xfs_params.memory_reclaim.val | |
85 | ||
86 | #define current_cpu() (raw_smp_processor_id()) | |
87 | #define current_pid() (current->pid) | |
88 | diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c | |
89 | index 0b0282d2f011c..232e3706a0a60 100644 | |
90 | --- a/fs/xfs/xfs_super.c | |
91 | +++ b/fs/xfs/xfs_super.c | |
92 | @@ -1828,6 +1828,8 @@ xfs_fs_nr_cached_objects( | |
93 | /* Paranoia: catch incorrect calls during mount setup or teardown */ | |
94 | if (WARN_ON_ONCE(!sb->s_fs_info)) | |
95 | return 0; | |
96 | + if (xfs_memory_reclaim == XFS_MEMORY_RECLAIM_NONE) | |
97 | + return 0; | |
98 | return xfs_reclaim_inodes_count(XFS_M(sb)); | |
99 | } | |
100 | ||
101 | diff --git a/fs/xfs/xfs_sysctl.c b/fs/xfs/xfs_sysctl.c | |
102 | index afe1f66aaa698..ccf0d1759c215 100644 | |
103 | --- a/fs/xfs/xfs_sysctl.c | |
104 | +++ b/fs/xfs/xfs_sysctl.c | |
105 | @@ -193,6 +193,15 @@ static struct ctl_table xfs_table[] = { | |
106 | .extra1 = &xfs_params.cowb_timer.min, | |
107 | .extra2 = &xfs_params.cowb_timer.max, | |
108 | }, | |
109 | + { | |
110 | + .procname = "memory_reclaim", | |
111 | + .data = &xfs_params.memory_reclaim.val, | |
112 | + .maxlen = sizeof(int), | |
113 | + .mode = 0644, | |
114 | + .proc_handler = proc_dointvec_minmax, | |
115 | + .extra1 = &xfs_params.memory_reclaim.min, | |
116 | + .extra2 = &xfs_params.memory_reclaim.max, | |
117 | + }, | |
118 | /* please keep this the last entry */ | |
119 | #ifdef CONFIG_PROC_FS | |
120 | { | |
121 | diff --git a/fs/xfs/xfs_sysctl.h b/fs/xfs/xfs_sysctl.h | |
122 | index 82afee005140a..eaf3addd486e7 100644 | |
123 | --- a/fs/xfs/xfs_sysctl.h | |
124 | +++ b/fs/xfs/xfs_sysctl.h | |
125 | @@ -49,6 +49,7 @@ typedef struct xfs_param { | |
126 | xfs_sysctl_val_t fstrm_timer; /* Filestream dir-AG assoc'n timeout. */ | |
127 | xfs_sysctl_val_t eofb_timer; /* Interval between eofb scan wakeups */ | |
128 | xfs_sysctl_val_t cowb_timer; /* Interval between cowb scan wakeups */ | |
129 | + xfs_sysctl_val_t memory_reclaim;/* Memory reclaim policy. */ | |
130 | } xfs_param_t; | |
131 | ||
132 | /* | |
133 | @@ -89,6 +90,7 @@ enum { | |
134 | XFS_ROTORSTEP = 20, | |
135 | XFS_INHERIT_NODFRG = 21, | |
136 | XFS_FILESTREAM_TIMER = 22, | |
137 | + XFS_MEMORY_RECLAIM = 23, | |
138 | }; | |
139 | ||
140 | extern xfs_param_t xfs_params; | |
d58c55f2 | 141 |