]> git.pld-linux.org Git - packages/kernel.git/blob - xfs-reclaim-hack.patch
- rel 1
[packages/kernel.git] / xfs-reclaim-hack.patch
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
13 ---
14  Documentation/filesystems/xfs.txt | 6 ++++++
15  fs/xfs/xfs_globals.c              | 1 +
16  fs/xfs/xfs_icache.c               | 6 +++++-
17  fs/xfs/xfs_icache.h               | 6 ++++++
18  fs/xfs/xfs_linux.h                | 1 +
19  fs/xfs/xfs_super.c                | 3 +++
20  fs/xfs/xfs_sysctl.c               | 9 +++++++++
21  fs/xfs/xfs_sysctl.h               | 2 ++
22  kernel/sysctl_binary.c            | 1 +
23  9 files changed, 34 insertions(+), 1 deletion(-)
24
25 diff --git a/Documentation/filesystems/xfs.txt b/Documentation/filesystems/xfs.txt
26 index 3b9b5c149f322..b33a4822f879c 100644
27 --- a/Documentation/filesystems/xfs.txt
28 +++ b/Documentation/filesystems/xfs.txt
29 @@ -331,6 +331,12 @@ The following sysctls are available for the XFS filesystem:
30         is to control the rate at which the allocator moves between
31         allocation groups when allocating extents for new files.
32  
33 +  fs.xfs.memory_reclaim                (Min: 0  Default: 2  Max: 2)
34 +       Set memory reclaim strategy:
35 +       0: no inode reclaim (background reclaim is still enabled)
36 +       1: async inode reclaim of clean inodes only
37 +       2: sync inode reclaim (includes synchronous writes)
38 +
39  Deprecated Sysctls
40  ==================
41  
42 diff --git a/fs/xfs/xfs_globals.c b/fs/xfs/xfs_globals.c
43 index 3e1cc3001bcbf..2927cc2b12b57 100644
44 --- a/fs/xfs/xfs_globals.c
45 +++ b/fs/xfs/xfs_globals.c
46 @@ -43,6 +43,7 @@ xfs_param_t xfs_params = {
47         .fstrm_timer    = {     1,              30*100,         3600*100},
48         .eofb_timer     = {     1,              300,            3600*24},
49         .cowb_timer     = {     1,              1800,           3600*24},
50 +       .memory_reclaim = {     0,              2,              2,      },
51  };
52  
53  struct xfs_globals xfs_globals = {
54 diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
55 index 544b5211221cd..54fcf1af7e3f5 100644
56 --- a/fs/xfs/xfs_icache.c
57 +++ b/fs/xfs/xfs_icache.c
58 @@ -1380,7 +1380,11 @@ xfs_reclaim_inodes_nr(
59         xfs_reclaim_work_queue(mp);
60         xfs_ail_push_all(mp->m_ail);
61  
62 -       return xfs_reclaim_inodes_ag(mp, SYNC_TRYLOCK | SYNC_WAIT, &nr_to_scan);
63 +       int flags = SYNC_TRYLOCK;
64 +       if (xfs_memory_reclaim == XFS_MEMORY_RECLAIM_SYNC)
65 +               flags |= SYNC_WAIT;
66 +
67 +       return xfs_reclaim_inodes_ag(mp, flags, &nr_to_scan);
68  }
69  
70  /*
71 diff --git a/fs/xfs/xfs_icache.h b/fs/xfs/xfs_icache.h
72 index bff4d85e54984..2547c0d85e5a1 100644
73 --- a/fs/xfs/xfs_icache.h
74 +++ b/fs/xfs/xfs_icache.h
75 @@ -54,6 +54,12 @@ struct xfs_eofblocks {
76   */
77  #define XFS_AGITER_INEW_WAIT   0x1     /* wait on new inodes */
78  
79 +enum {
80 +       XFS_MEMORY_RECLAIM_NONE = 0,
81 +       XFS_MEMORY_RECLAIM_ASYNC,
82 +       XFS_MEMORY_RECLAIM_SYNC,
83 +};
84 +
85  int xfs_iget(struct xfs_mount *mp, struct xfs_trans *tp, xfs_ino_t ino,
86              uint flags, uint lock_flags, xfs_inode_t **ipp);
87  
88 diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
89 index dcd1292664b34..3cddbffaa8cb4 100644
90 --- a/fs/xfs/xfs_linux.h
91 +++ b/fs/xfs/xfs_linux.h
92 @@ -110,6 +110,7 @@ typedef __u32                       xfs_nlink_t;
93  #define xfs_fstrm_centisecs    xfs_params.fstrm_timer.val
94  #define xfs_eofb_secs          xfs_params.eofb_timer.val
95  #define xfs_cowb_secs          xfs_params.cowb_timer.val
96 +#define xfs_memory_reclaim     xfs_params.memory_reclaim.val
97  
98  #define current_cpu()          (raw_smp_processor_id())
99  #define current_pid()          (current->pid)
100 diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
101 index 0b0282d2f011c..232e3706a0a60 100644
102 --- a/fs/xfs/xfs_super.c
103 +++ b/fs/xfs/xfs_super.c
104 @@ -1828,6 +1828,8 @@ xfs_fs_nr_cached_objects(
105         /* Paranoia: catch incorrect calls during mount setup or teardown */
106         if (WARN_ON_ONCE(!sb->s_fs_info))
107                 return 0;
108 +       if (xfs_memory_reclaim == XFS_MEMORY_RECLAIM_NONE)
109 +               return 0;
110         return xfs_reclaim_inodes_count(XFS_M(sb));
111  }
112  
113 diff --git a/fs/xfs/xfs_sysctl.c b/fs/xfs/xfs_sysctl.c
114 index afe1f66aaa698..ccf0d1759c215 100644
115 --- a/fs/xfs/xfs_sysctl.c
116 +++ b/fs/xfs/xfs_sysctl.c
117 @@ -193,6 +193,15 @@ static struct ctl_table xfs_table[] = {
118                 .extra1         = &xfs_params.cowb_timer.min,
119                 .extra2         = &xfs_params.cowb_timer.max,
120         },
121 +       {
122 +               .procname       = "memory_reclaim",
123 +               .data           = &xfs_params.memory_reclaim.val,
124 +               .maxlen         = sizeof(int),
125 +               .mode           = 0644,
126 +               .proc_handler   = proc_dointvec_minmax,
127 +               .extra1         = &xfs_params.memory_reclaim.min,
128 +               .extra2         = &xfs_params.memory_reclaim.max,
129 +       },
130         /* please keep this the last entry */
131  #ifdef CONFIG_PROC_FS
132         {
133 diff --git a/fs/xfs/xfs_sysctl.h b/fs/xfs/xfs_sysctl.h
134 index 82afee005140a..eaf3addd486e7 100644
135 --- a/fs/xfs/xfs_sysctl.h
136 +++ b/fs/xfs/xfs_sysctl.h
137 @@ -49,6 +49,7 @@ typedef struct xfs_param {
138         xfs_sysctl_val_t fstrm_timer;   /* Filestream dir-AG assoc'n timeout. */
139         xfs_sysctl_val_t eofb_timer;    /* Interval between eofb scan wakeups */
140         xfs_sysctl_val_t cowb_timer;    /* Interval between cowb scan wakeups */
141 +       xfs_sysctl_val_t memory_reclaim;/* Memory reclaim policy. */
142  } xfs_param_t;
143  
144  /*
145 @@ -89,6 +90,7 @@ enum {
146         XFS_ROTORSTEP = 20,
147         XFS_INHERIT_NODFRG = 21,
148         XFS_FILESTREAM_TIMER = 22,
149 +       XFS_MEMORY_RECLAIM = 23,
150  };
151  
152  extern xfs_param_t     xfs_params;
153 diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
154 index e8c0dab4fd653..ec2f2c52e3ab5 100644
155 --- a/kernel/sysctl_binary.c
156 +++ b/kernel/sysctl_binary.c
157 @@ -778,6 +778,7 @@ static const struct bin_table bin_fs_xfs_table[] = {
158         { CTL_INT,      XFS_INHERIT_NODFRG,     "inherit_nodefrag" },
159         { CTL_INT,      XFS_FILESTREAM_TIMER,   "filestream_centisecs" },
160         { CTL_INT,      XFS_STATS_CLEAR,        "stats_clear" },
161 +       { CTL_INT,      XFS_MEMORY_RECLAIM,     "memory_reclaim" },
162         {}
163  };
164  
This page took 0.126795 seconds and 3 git commands to generate.