hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/mm/vmpressure.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Linux VM pressure
34 *
....@@ -6,10 +7,6 @@
67 *
78 * Based on ideas from Andrew Morton, David Rientjes, KOSAKI Motohiro,
89 * 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.
1310 */
1411
1512 #include <linux/cgroup.h>
....@@ -23,6 +20,8 @@
2320 #include <linux/swap.h>
2421 #include <linux/printk.h>
2522 #include <linux/vmpressure.h>
23
+
24
+#include <trace/hooks/mm.h>
2625
2726 /*
2827 * The window size (vmpressure_win) is the number of scanned pages before
....@@ -243,7 +242,17 @@
243242 void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, bool tree,
244243 unsigned long scanned, unsigned long reclaimed)
245244 {
246
- struct vmpressure *vmpr = memcg_to_vmpressure(memcg);
245
+ struct vmpressure *vmpr;
246
+ bool bypass = false;
247
+
248
+ if (mem_cgroup_disabled())
249
+ return;
250
+
251
+ vmpr = memcg_to_vmpressure(memcg);
252
+
253
+ trace_android_vh_vmpressure(memcg, &bypass);
254
+ if (unlikely(bypass))
255
+ return;
247256
248257 /*
249258 * Here we only want to account pressure that userland is able to
....@@ -283,7 +292,7 @@
283292 enum vmpressure_levels level;
284293
285294 /* For now, no users for root-level efficiency */
286
- if (!memcg || memcg == root_mem_cgroup)
295
+ if (!memcg || mem_cgroup_is_root(memcg))
287296 return;
288297
289298 spin_lock(&vmpr->sr_lock);
....@@ -374,10 +383,8 @@
374383 int ret = 0;
375384
376385 spec_orig = spec = kstrndup(args, MAX_VMPRESSURE_ARGS_LEN, GFP_KERNEL);
377
- if (!spec) {
378
- ret = -ENOMEM;
379
- goto out;
380
- }
386
+ if (!spec)
387
+ return -ENOMEM;
381388
382389 /* Find required level */
383390 token = strsep(&spec, ",");