| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Linux VM pressure |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 6 | 7 | * |
|---|
| 7 | 8 | * Based on ideas from Andrew Morton, David Rientjes, KOSAKI Motohiro, |
|---|
| 8 | 9 | * 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 | 10 | */ |
|---|
| 14 | 11 | |
|---|
| 15 | 12 | #include <linux/cgroup.h> |
|---|
| .. | .. |
|---|
| 23 | 20 | #include <linux/swap.h> |
|---|
| 24 | 21 | #include <linux/printk.h> |
|---|
| 25 | 22 | #include <linux/vmpressure.h> |
|---|
| 23 | + |
|---|
| 24 | +#include <trace/hooks/mm.h> |
|---|
| 26 | 25 | |
|---|
| 27 | 26 | /* |
|---|
| 28 | 27 | * The window size (vmpressure_win) is the number of scanned pages before |
|---|
| .. | .. |
|---|
| 243 | 242 | void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, bool tree, |
|---|
| 244 | 243 | unsigned long scanned, unsigned long reclaimed) |
|---|
| 245 | 244 | { |
|---|
| 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; |
|---|
| 247 | 256 | |
|---|
| 248 | 257 | /* |
|---|
| 249 | 258 | * Here we only want to account pressure that userland is able to |
|---|
| .. | .. |
|---|
| 283 | 292 | enum vmpressure_levels level; |
|---|
| 284 | 293 | |
|---|
| 285 | 294 | /* For now, no users for root-level efficiency */ |
|---|
| 286 | | - if (!memcg || memcg == root_mem_cgroup) |
|---|
| 295 | + if (!memcg || mem_cgroup_is_root(memcg)) |
|---|
| 287 | 296 | return; |
|---|
| 288 | 297 | |
|---|
| 289 | 298 | spin_lock(&vmpr->sr_lock); |
|---|
| .. | .. |
|---|
| 374 | 383 | int ret = 0; |
|---|
| 375 | 384 | |
|---|
| 376 | 385 | 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; |
|---|
| 381 | 388 | |
|---|
| 382 | 389 | /* Find required level */ |
|---|
| 383 | 390 | token = strsep(&spec, ","); |
|---|