lmkd: Skip memory.stat usage when per-app memcgs are not used

Initial change to remove memory.stat usage when per-application memcgs
are disabled was partially merged into AOSP under the following id:
Ib6dd7586d3ef1c64cb04d16e2d2b21fa9c8e6a3a
This change adds the missing parts.

Bug: 110384555
Change-Id: I1265021b1ede0e68efbf80d6430a959eaf46a69a
Merged-In: Ib6dd7586d3ef1c64cb04d16e2d2b21fa9c8e6a3a
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
Suren Baghdasaryan 2018-06-19 18:38:12 -07:00
parent f5b1d14fa8
commit 2f81a77326
1 changed files with 20 additions and 13 deletions

7
lmkd.c
View File

@ -758,6 +758,13 @@ static int memory_stat_parse(struct memory_stat *mem_st, int pid, uid_t uid) {
FILE *fp;
char buf[PATH_MAX];
/*
* Per-application memory.stat files are available only when
* per-application memcgs are enabled.
*/
if (!per_app_memcg)
return -1;
snprintf(buf, sizeof(buf), MEMCG_PROCESS_MEMORY_STAT_PATH, uid, pid);
fp = fopen(buf, "r");