blob: 7b91da904dad69ad12646de00c6f534060fd5a33 [file] [log] [blame]
Anton Vorontsov70ddf632013-04-29 15:08:31 -07001/*
2 * Linux VM pressure
3 *
4 * Copyright 2012 Linaro Ltd.
5 * Anton Vorontsov <anton.vorontsov@linaro.org>
6 *
7 * Based on ideas from Andrew Morton, David Rientjes, KOSAKI Motohiro,
8 * Leonid Moiseichuk, Mel Gorman, Minchan Kim and Pekka Enberg.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published
12 * by the Free Software Foundation.
13 */
14
15#include <linux/cgroup.h>
16#include <linux/fs.h>
17#include <linux/log2.h>
18#include <linux/sched.h>
19#include <linux/mm.h>
20#include <linux/vmstat.h>
21#include <linux/eventfd.h>
Tejun Heo1ff6bbf2014-01-28 18:10:37 -050022#include <linux/slab.h>
Anton Vorontsov70ddf632013-04-29 15:08:31 -070023#include <linux/swap.h>
24#include <linux/printk.h>
Vinayak Menon13088ad2015-03-04 16:38:28 +053025#include <linux/notifier.h>
26#include <linux/init.h>
Vinayak Menon58091092015-03-31 11:06:29 +053027#include <linux/module.h>
Anton Vorontsov70ddf632013-04-29 15:08:31 -070028#include <linux/vmpressure.h>
29
30/*
31 * The window size (vmpressure_win) is the number of scanned pages before
32 * we try to analyze scanned/reclaimed ratio. So the window is used as a
33 * rate-limit tunable for the "low" level notification, and also for
34 * averaging the ratio for medium/critical levels. Using small window
35 * sizes can cause lot of false positives, but too big window size will
36 * delay the notifications.
37 *
38 * As the vmscan reclaimer logic works with chunks which are multiple of
39 * SWAP_CLUSTER_MAX, it makes sense to use it for the window size as well.
40 *
41 * TODO: Make the window size depend on machine size, as we do for vmstat
42 * thresholds. Currently we set it to 512 pages (2MB for 4KB pages).
43 */
44static const unsigned long vmpressure_win = SWAP_CLUSTER_MAX * 16;
45
46/*
47 * These thresholds are used when we account memory pressure through
48 * scanned/reclaimed ratio. The current values were chosen empirically. In
49 * essence, they are percents: the higher the value, the more number
50 * unsuccessful reclaims there were.
51 */
52static const unsigned int vmpressure_level_med = 60;
53static const unsigned int vmpressure_level_critical = 95;
54
Vinayak Menon58091092015-03-31 11:06:29 +053055static unsigned long vmpressure_scale_max = 100;
56module_param_named(vmpressure_scale_max, vmpressure_scale_max,
57 ulong, 0644);
58
Vinayak Menon13088ad2015-03-04 16:38:28 +053059static struct vmpressure global_vmpressure;
60static BLOCKING_NOTIFIER_HEAD(vmpressure_notifier);
61
62int vmpressure_notifier_register(struct notifier_block *nb)
63{
64 return blocking_notifier_chain_register(&vmpressure_notifier, nb);
65}
66
67int vmpressure_notifier_unregister(struct notifier_block *nb)
68{
69 return blocking_notifier_chain_unregister(&vmpressure_notifier, nb);
70}
71
72static void vmpressure_notify(unsigned long pressure)
73{
74 blocking_notifier_call_chain(&vmpressure_notifier, pressure, NULL);
75}
76
Anton Vorontsov70ddf632013-04-29 15:08:31 -070077/*
78 * When there are too little pages left to scan, vmpressure() may miss the
79 * critical pressure as number of pages will be less than "window size".
80 * However, in that case the vmscan priority will raise fast as the
81 * reclaimer will try to scan LRUs more deeply.
82 *
83 * The vmscan logic considers these special priorities:
84 *
85 * prio == DEF_PRIORITY (12): reclaimer starts with that value
86 * prio <= DEF_PRIORITY - 2 : kswapd becomes somewhat overwhelmed
87 * prio == 0 : close to OOM, kernel scans every page in an lru
88 *
89 * Any value in this range is acceptable for this tunable (i.e. from 12 to
90 * 0). Current value for the vmpressure_level_critical_prio is chosen
91 * empirically, but the number, in essence, means that we consider
92 * critical level when scanning depth is ~10% of the lru size (vmscan
93 * scans 'lru_size >> prio' pages, so it is actually 12.5%, or one
94 * eights).
95 */
96static const unsigned int vmpressure_level_critical_prio = ilog2(100 / 10);
97
98static struct vmpressure *work_to_vmpressure(struct work_struct *work)
99{
100 return container_of(work, struct vmpressure, work);
101}
102
Vinayak Menon13088ad2015-03-04 16:38:28 +0530103#ifdef CONFIG_MEMCG
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700104static struct vmpressure *vmpressure_parent(struct vmpressure *vmpr)
105{
Tejun Heo182446d2013-08-08 20:11:24 -0400106 struct cgroup_subsys_state *css = vmpressure_to_css(vmpr);
107 struct mem_cgroup *memcg = mem_cgroup_from_css(css);
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700108
109 memcg = parent_mem_cgroup(memcg);
110 if (!memcg)
111 return NULL;
112 return memcg_to_vmpressure(memcg);
113}
Vinayak Menon13088ad2015-03-04 16:38:28 +0530114#else
115static struct vmpressure *vmpressure_parent(struct vmpressure *vmpr)
116{
117 return NULL;
118}
119#endif
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700120
121enum vmpressure_levels {
122 VMPRESSURE_LOW = 0,
123 VMPRESSURE_MEDIUM,
124 VMPRESSURE_CRITICAL,
125 VMPRESSURE_NUM_LEVELS,
126};
127
128static const char * const vmpressure_str_levels[] = {
129 [VMPRESSURE_LOW] = "low",
130 [VMPRESSURE_MEDIUM] = "medium",
131 [VMPRESSURE_CRITICAL] = "critical",
132};
133
134static enum vmpressure_levels vmpressure_level(unsigned long pressure)
135{
136 if (pressure >= vmpressure_level_critical)
137 return VMPRESSURE_CRITICAL;
138 else if (pressure >= vmpressure_level_med)
139 return VMPRESSURE_MEDIUM;
140 return VMPRESSURE_LOW;
141}
142
Vinayak Menon13088ad2015-03-04 16:38:28 +0530143static unsigned long vmpressure_calc_pressure(unsigned long scanned,
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700144 unsigned long reclaimed)
145{
146 unsigned long scale = scanned + reclaimed;
Vinayak Menon58d1dbb2017-02-24 14:59:39 -0800147 unsigned long pressure = 0;
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700148
149 /*
Vinayak Menon58d1dbb2017-02-24 14:59:39 -0800150 * reclaimed can be greater than scanned in cases
151 * like THP, where the scanned is 1 and reclaimed
152 * could be 512
153 */
154 if (reclaimed >= scanned)
155 goto out;
156 /*
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700157 * We calculate the ratio (in percents) of how many pages were
158 * scanned vs. reclaimed in a given time frame (window). Note that
159 * time is in VM reclaimer's "ticks", i.e. number of pages
160 * scanned. This makes it possible to set desired reaction time
161 * and serves as a ratelimit.
162 */
163 pressure = scale - (reclaimed * scale / scanned);
164 pressure = pressure * 100 / scale;
165
Vinayak Menon58d1dbb2017-02-24 14:59:39 -0800166out:
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700167 pr_debug("%s: %3lu (s: %lu r: %lu)\n", __func__, pressure,
168 scanned, reclaimed);
169
Vinayak Menon13088ad2015-03-04 16:38:28 +0530170 return pressure;
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700171}
172
Vinayak Menon58091092015-03-31 11:06:29 +0530173static unsigned long vmpressure_account_stall(unsigned long pressure,
174 unsigned long stall, unsigned long scanned)
175{
176 unsigned long scale =
177 ((vmpressure_scale_max - pressure) * stall) / scanned;
178
179 return pressure + scale;
180}
181
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700182struct vmpressure_event {
183 struct eventfd_ctx *efd;
184 enum vmpressure_levels level;
185 struct list_head node;
186};
187
188static bool vmpressure_event(struct vmpressure *vmpr,
Johannes Weiner8e8ae642016-01-14 15:21:32 -0800189 enum vmpressure_levels level)
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700190{
191 struct vmpressure_event *ev;
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700192 bool signalled = false;
193
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700194 mutex_lock(&vmpr->events_lock);
195
196 list_for_each_entry(ev, &vmpr->events, node) {
197 if (level >= ev->level) {
198 eventfd_signal(ev->efd, 1);
199 signalled = true;
200 }
201 }
202
203 mutex_unlock(&vmpr->events_lock);
204
205 return signalled;
206}
207
208static void vmpressure_work_fn(struct work_struct *work)
209{
210 struct vmpressure *vmpr = work_to_vmpressure(work);
211 unsigned long scanned;
212 unsigned long reclaimed;
Vinayak Menon13088ad2015-03-04 16:38:28 +0530213 unsigned long pressure;
Johannes Weiner8e8ae642016-01-14 15:21:32 -0800214 enum vmpressure_levels level;
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700215
Andrew Morton91b57192014-12-02 15:59:28 -0800216 spin_lock(&vmpr->sr_lock);
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700217 /*
218 * Several contexts might be calling vmpressure(), so it is
219 * possible that the work was rescheduled again before the old
220 * work context cleared the counters. In that case we will run
221 * just after the old work returns, but then scanned might be zero
222 * here. No need for any locks here since we don't care if
223 * vmpr->reclaimed is in sync.
224 */
Johannes Weiner8e8ae642016-01-14 15:21:32 -0800225 scanned = vmpr->tree_scanned;
Andrew Morton91b57192014-12-02 15:59:28 -0800226 if (!scanned) {
227 spin_unlock(&vmpr->sr_lock);
228 return;
229 }
230
Johannes Weiner8e8ae642016-01-14 15:21:32 -0800231 reclaimed = vmpr->tree_reclaimed;
232 vmpr->tree_scanned = 0;
233 vmpr->tree_reclaimed = 0;
Michal Hocko22f20202013-07-31 13:53:48 -0700234 spin_unlock(&vmpr->sr_lock);
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700235
Vinayak Menon13088ad2015-03-04 16:38:28 +0530236 pressure = vmpressure_calc_pressure(scanned, reclaimed);
237 level = vmpressure_level(pressure);
Johannes Weiner8e8ae642016-01-14 15:21:32 -0800238
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700239 do {
Johannes Weiner8e8ae642016-01-14 15:21:32 -0800240 if (vmpressure_event(vmpr, level))
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700241 break;
242 /*
243 * If not handled, propagate the event upward into the
244 * hierarchy.
245 */
246 } while ((vmpr = vmpressure_parent(vmpr)));
247}
248
Vinayak Menon13088ad2015-03-04 16:38:28 +0530249#ifdef CONFIG_MEMCG
250static void vmpressure_memcg(gfp_t gfp, struct mem_cgroup *memcg, bool tree,
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700251 unsigned long scanned, unsigned long reclaimed)
252{
253 struct vmpressure *vmpr = memcg_to_vmpressure(memcg);
254
255 /*
256 * Here we only want to account pressure that userland is able to
257 * help us with. For example, suppose that DMA zone is under
258 * pressure; if we notify userland about that kind of pressure,
259 * then it will be mostly a waste as it will trigger unnecessary
260 * freeing of memory by userland (since userland is more likely to
261 * have HIGHMEM/MOVABLE pages instead of the DMA fallback). That
262 * is why we include only movable, highmem and FS/IO pages.
263 * Indirect reclaim (kswapd) sets sc->gfp_mask to GFP_KERNEL, so
264 * we account it too.
265 */
266 if (!(gfp & (__GFP_HIGHMEM | __GFP_MOVABLE | __GFP_IO | __GFP_FS)))
267 return;
268
269 /*
270 * If we got here with no pages scanned, then that is an indicator
271 * that reclaimer was unable to find any shrinkable LRUs at the
272 * current scanning depth. But it does not mean that we should
273 * report the critical pressure, yet. If the scanning priority
274 * (scanning depth) goes too high (deep), we will be notified
275 * through vmpressure_prio(). But so far, keep calm.
276 */
277 if (!scanned)
278 return;
279
Johannes Weiner8e8ae642016-01-14 15:21:32 -0800280 if (tree) {
281 spin_lock(&vmpr->sr_lock);
Vladimir Davydov3c1da7b2016-02-02 16:57:49 -0800282 scanned = vmpr->tree_scanned += scanned;
Johannes Weiner8e8ae642016-01-14 15:21:32 -0800283 vmpr->tree_reclaimed += reclaimed;
Johannes Weiner8e8ae642016-01-14 15:21:32 -0800284 spin_unlock(&vmpr->sr_lock);
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700285
Johannes Weiner8e8ae642016-01-14 15:21:32 -0800286 if (scanned < vmpressure_win)
287 return;
288 schedule_work(&vmpr->work);
289 } else {
290 enum vmpressure_levels level;
Vinayak Menon13088ad2015-03-04 16:38:28 +0530291 unsigned long pressure;
Johannes Weiner8e8ae642016-01-14 15:21:32 -0800292
293 /* For now, no users for root-level efficiency */
Hugh Dickins686739f2016-01-14 15:21:37 -0800294 if (!memcg || memcg == root_mem_cgroup)
Johannes Weiner8e8ae642016-01-14 15:21:32 -0800295 return;
296
297 spin_lock(&vmpr->sr_lock);
298 scanned = vmpr->scanned += scanned;
299 reclaimed = vmpr->reclaimed += reclaimed;
300 if (scanned < vmpressure_win) {
301 spin_unlock(&vmpr->sr_lock);
302 return;
303 }
304 vmpr->scanned = vmpr->reclaimed = 0;
305 spin_unlock(&vmpr->sr_lock);
306
Vinayak Menon13088ad2015-03-04 16:38:28 +0530307 pressure = vmpressure_calc_pressure(scanned, reclaimed);
308 level = vmpressure_level(pressure);
Johannes Weiner8e8ae642016-01-14 15:21:32 -0800309
310 if (level > VMPRESSURE_LOW) {
311 /*
312 * Let the socket buffer allocator know that
313 * we are having trouble reclaiming LRU pages.
314 *
315 * For hysteresis keep the pressure state
316 * asserted for a second in which subsequent
317 * pressure events can occur.
318 */
319 memcg->socket_pressure = jiffies + HZ;
320 }
321 }
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700322}
Vinayak Menon13088ad2015-03-04 16:38:28 +0530323#else
324static void vmpressure_memcg(gfp_t gfp, struct mem_cgroup *memcg, bool tree,
325 unsigned long scanned, unsigned long reclaimed) { }
326#endif
327
328static void vmpressure_global(gfp_t gfp, unsigned long scanned,
329 unsigned long reclaimed)
330{
331 struct vmpressure *vmpr = &global_vmpressure;
332 unsigned long pressure;
Vinayak Menon58091092015-03-31 11:06:29 +0530333 unsigned long stall;
Vinayak Menon13088ad2015-03-04 16:38:28 +0530334
335 if (!(gfp & (__GFP_HIGHMEM | __GFP_MOVABLE | __GFP_IO | __GFP_FS)))
336 return;
337
338 if (!scanned)
339 return;
340
341 spin_lock(&vmpr->sr_lock);
342 vmpr->scanned += scanned;
343 vmpr->reclaimed += reclaimed;
Vinayak Menon58091092015-03-31 11:06:29 +0530344
345 if (!current_is_kswapd())
346 vmpr->stall += scanned;
347
348 stall = vmpr->stall;
Vinayak Menon13088ad2015-03-04 16:38:28 +0530349 scanned = vmpr->scanned;
350 reclaimed = vmpr->reclaimed;
351 spin_unlock(&vmpr->sr_lock);
352
353 if (scanned < vmpressure_win)
354 return;
355
356 spin_lock(&vmpr->sr_lock);
357 vmpr->scanned = 0;
358 vmpr->reclaimed = 0;
Vinayak Menon58091092015-03-31 11:06:29 +0530359 vmpr->stall = 0;
Vinayak Menon13088ad2015-03-04 16:38:28 +0530360 spin_unlock(&vmpr->sr_lock);
361
362 pressure = vmpressure_calc_pressure(scanned, reclaimed);
Vinayak Menon58091092015-03-31 11:06:29 +0530363 pressure = vmpressure_account_stall(pressure, stall, scanned);
Vinayak Menon13088ad2015-03-04 16:38:28 +0530364 vmpressure_notify(pressure);
365}
366
367/**
368 * vmpressure() - Account memory pressure through scanned/reclaimed ratio
369 * @gfp: reclaimer's gfp mask
370 * @memcg: cgroup memory controller handle
371 * @tree: legacy subtree mode
372 * @scanned: number of pages scanned
373 * @reclaimed: number of pages reclaimed
374 *
375 * This function should be called from the vmscan reclaim path to account
376 * "instantaneous" memory pressure (scanned/reclaimed ratio). The raw
377 * pressure index is then further refined and averaged over time.
378 *
379 * If @tree is set, vmpressure is in traditional userspace reporting
380 * mode: @memcg is considered the pressure root and userspace is
381 * notified of the entire subtree's reclaim efficiency.
382 *
383 * If @tree is not set, reclaim efficiency is recorded for @memcg, and
384 * only in-kernel users are notified.
385 *
386 * This function does not return any value.
387 */
388void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, bool tree,
389 unsigned long scanned, unsigned long reclaimed)
390{
391 if (!memcg)
392 vmpressure_global(gfp, scanned, reclaimed);
393
394 if (IS_ENABLED(CONFIG_MEMCG))
395 vmpressure_memcg(gfp, memcg, tree, scanned, reclaimed);
396}
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700397
398/**
399 * vmpressure_prio() - Account memory pressure through reclaimer priority level
400 * @gfp: reclaimer's gfp mask
401 * @memcg: cgroup memory controller handle
402 * @prio: reclaimer's priority
403 *
404 * This function should be called from the reclaim path every time when
405 * the vmscan's reclaiming priority (scanning depth) changes.
406 *
407 * This function does not return any value.
408 */
409void vmpressure_prio(gfp_t gfp, struct mem_cgroup *memcg, int prio)
410{
411 /*
412 * We only use prio for accounting critical level. For more info
413 * see comment for vmpressure_level_critical_prio variable above.
414 */
415 if (prio > vmpressure_level_critical_prio)
416 return;
417
418 /*
419 * OK, the prio is below the threshold, updating vmpressure
420 * information before shrinker dives into long shrinking of long
421 * range vmscan. Passing scanned = vmpressure_win, reclaimed = 0
422 * to the vmpressure() basically means that we signal 'critical'
423 * level.
424 */
Johannes Weiner8e8ae642016-01-14 15:21:32 -0800425 vmpressure(gfp, memcg, true, vmpressure_win, 0);
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700426}
427
428/**
429 * vmpressure_register_event() - Bind vmpressure notifications to an eventfd
Tejun Heo59b6f872013-11-22 18:20:43 -0500430 * @memcg: memcg that is interested in vmpressure notifications
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700431 * @eventfd: eventfd context to link notifications with
432 * @args: event arguments (used to set up a pressure level threshold)
433 *
434 * This function associates eventfd context with the vmpressure
435 * infrastructure, so that the notifications will be delivered to the
436 * @eventfd. The @args parameter is a string that denotes pressure level
437 * threshold (one of vmpressure_str_levels, i.e. "low", "medium", or
438 * "critical").
439 *
Tejun Heo347c4a82013-11-22 18:20:43 -0500440 * To be used as memcg event method.
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700441 */
Tejun Heo59b6f872013-11-22 18:20:43 -0500442int vmpressure_register_event(struct mem_cgroup *memcg,
Tejun Heo347c4a82013-11-22 18:20:43 -0500443 struct eventfd_ctx *eventfd, const char *args)
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700444{
Tejun Heo59b6f872013-11-22 18:20:43 -0500445 struct vmpressure *vmpr = memcg_to_vmpressure(memcg);
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700446 struct vmpressure_event *ev;
447 int level;
448
449 for (level = 0; level < VMPRESSURE_NUM_LEVELS; level++) {
450 if (!strcmp(vmpressure_str_levels[level], args))
451 break;
452 }
453
454 if (level >= VMPRESSURE_NUM_LEVELS)
455 return -EINVAL;
456
457 ev = kzalloc(sizeof(*ev), GFP_KERNEL);
458 if (!ev)
459 return -ENOMEM;
460
461 ev->efd = eventfd;
462 ev->level = level;
463
464 mutex_lock(&vmpr->events_lock);
465 list_add(&ev->node, &vmpr->events);
466 mutex_unlock(&vmpr->events_lock);
467
468 return 0;
469}
470
471/**
472 * vmpressure_unregister_event() - Unbind eventfd from vmpressure
Tejun Heo59b6f872013-11-22 18:20:43 -0500473 * @memcg: memcg handle
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700474 * @eventfd: eventfd context that was used to link vmpressure with the @cg
475 *
476 * This function does internal manipulations to detach the @eventfd from
477 * the vmpressure notifications, and then frees internal resources
478 * associated with the @eventfd (but the @eventfd itself is not freed).
479 *
Tejun Heo347c4a82013-11-22 18:20:43 -0500480 * To be used as memcg event method.
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700481 */
Tejun Heo59b6f872013-11-22 18:20:43 -0500482void vmpressure_unregister_event(struct mem_cgroup *memcg,
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700483 struct eventfd_ctx *eventfd)
484{
Tejun Heo59b6f872013-11-22 18:20:43 -0500485 struct vmpressure *vmpr = memcg_to_vmpressure(memcg);
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700486 struct vmpressure_event *ev;
487
488 mutex_lock(&vmpr->events_lock);
489 list_for_each_entry(ev, &vmpr->events, node) {
490 if (ev->efd != eventfd)
491 continue;
492 list_del(&ev->node);
493 kfree(ev);
494 break;
495 }
496 mutex_unlock(&vmpr->events_lock);
497}
498
499/**
500 * vmpressure_init() - Initialize vmpressure control structure
501 * @vmpr: Structure to be initialized
502 *
503 * This function should be called on every allocated vmpressure structure
504 * before any usage.
505 */
506void vmpressure_init(struct vmpressure *vmpr)
507{
Michal Hocko22f20202013-07-31 13:53:48 -0700508 spin_lock_init(&vmpr->sr_lock);
Anton Vorontsov70ddf632013-04-29 15:08:31 -0700509 mutex_init(&vmpr->events_lock);
510 INIT_LIST_HEAD(&vmpr->events);
511 INIT_WORK(&vmpr->work, vmpressure_work_fn);
512}
Michal Hocko33cb8762013-07-31 13:53:51 -0700513
514/**
515 * vmpressure_cleanup() - shuts down vmpressure control structure
516 * @vmpr: Structure to be cleaned up
517 *
518 * This function should be called before the structure in which it is
519 * embedded is cleaned up.
520 */
521void vmpressure_cleanup(struct vmpressure *vmpr)
522{
523 /*
524 * Make sure there is no pending work before eventfd infrastructure
525 * goes away.
526 */
527 flush_work(&vmpr->work);
528}
Vinayak Menon13088ad2015-03-04 16:38:28 +0530529
530static int vmpressure_global_init(void)
531{
532 vmpressure_init(&global_vmpressure);
533 return 0;
534}
535late_initcall(vmpressure_global_init);