mirror of
https://github.com/torvalds/linux.git
synced 2024-12-29 06:12:08 +00:00
cdc69458a5
The test_memcg_low() testcase in test_memcontrol.c verifies the expected
behavior of groups using the memory.low knob. Part of the testcase
verifies that a group with memory.low that experiences reclaim due to
memory pressure elsewhere in the system, observes memory.events.low events
as a result of that reclaim.
In commit 8a931f8013
("mm: memcontrol: recursive memory.low
protection"), the memory controller was updated to propagate memory.low
and memory.min protection from a parent group to its children via a
configurable memory_recursiveprot mount option. This unfortunately broke
the memcg tests, which asserts that a sibling that experienced reclaim but
had a memory.low value of 0, would not observe any memory.low events.
This patch updates test_memcg_low() to account for the new behavior
introduced by memory_recursiveprot.
So as to make the test resilient to multiple configurations, the patch
also adds a new proc_mount_contains() helper that checks for a string in
/proc/mounts, and is used to toggle behavior based on whether the default
memory_recursiveprot was present.
Link: https://lkml.kernel.org/r/20220423155619.3669555-3-void@manifault.com
Signed-off-by: David Vernet <void@manifault.com>
Acked-by: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
61 lines
2.4 KiB
C
61 lines
2.4 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#include <stdbool.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "../kselftest.h"
|
|
|
|
#define PAGE_SIZE 4096
|
|
|
|
#define MB(x) (x << 20)
|
|
|
|
/*
|
|
* Checks if two given values differ by less than err% of their sum.
|
|
*/
|
|
static inline int values_close(long a, long b, int err)
|
|
{
|
|
return abs(a - b) <= (a + b) / 100 * err;
|
|
}
|
|
|
|
extern int cg_find_unified_root(char *root, size_t len);
|
|
extern char *cg_name(const char *root, const char *name);
|
|
extern char *cg_name_indexed(const char *root, const char *name, int index);
|
|
extern char *cg_control(const char *cgroup, const char *control);
|
|
extern int cg_create(const char *cgroup);
|
|
extern int cg_destroy(const char *cgroup);
|
|
extern int cg_read(const char *cgroup, const char *control,
|
|
char *buf, size_t len);
|
|
extern int cg_read_strcmp(const char *cgroup, const char *control,
|
|
const char *expected);
|
|
extern int cg_read_strstr(const char *cgroup, const char *control,
|
|
const char *needle);
|
|
extern long cg_read_long(const char *cgroup, const char *control);
|
|
long cg_read_key_long(const char *cgroup, const char *control, const char *key);
|
|
extern long cg_read_lc(const char *cgroup, const char *control);
|
|
extern int cg_write(const char *cgroup, const char *control, char *buf);
|
|
extern int cg_run(const char *cgroup,
|
|
int (*fn)(const char *cgroup, void *arg),
|
|
void *arg);
|
|
extern int cg_enter(const char *cgroup, int pid);
|
|
extern int cg_enter_current(const char *cgroup);
|
|
extern int cg_enter_current_thread(const char *cgroup);
|
|
extern int cg_run_nowait(const char *cgroup,
|
|
int (*fn)(const char *cgroup, void *arg),
|
|
void *arg);
|
|
extern int get_temp_fd(void);
|
|
extern int alloc_pagecache(int fd, size_t size);
|
|
extern int alloc_anon(const char *cgroup, void *arg);
|
|
extern int is_swap_enabled(void);
|
|
extern int set_oom_adj_score(int pid, int score);
|
|
extern int cg_wait_for_proc_count(const char *cgroup, int count);
|
|
extern int cg_killall(const char *cgroup);
|
|
int proc_mount_contains(const char *option);
|
|
extern ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, size_t size);
|
|
extern int proc_read_strstr(int pid, bool thread, const char *item, const char *needle);
|
|
extern pid_t clone_into_cgroup(int cgroup_fd);
|
|
extern int clone_reap(pid_t pid, int options);
|
|
extern int clone_into_cgroup_run_wait(const char *cgroup);
|
|
extern int dirfd_open_opath(const char *dir);
|
|
extern int cg_prepare_for_wait(const char *cgroup);
|
|
extern int memcg_prepare_for_wait(const char *cgroup);
|
|
extern int cg_wait_for(int fd);
|