[LTP] [PATCH v3 1/2] API/cgroup: Expose memory_recursiveprot V2 mount opt
Richard Palethorpe
rpalethorpe@suse.com
Tue Feb 22 13:45:46 CET 2022
This changes the effect of trunk nodes' memory.low and memory.min on
their leaf nodes. So we need to change the expectations of some tests.
Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
Suggested-by: Michal Koutný <mkoutny@suse.com>
---
include/tst_cgroup.h | 3 +++
lib/tst_cgroup.c | 13 ++++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/include/tst_cgroup.h b/include/tst_cgroup.h
index d32d62399..b822798e0 100644
--- a/include/tst_cgroup.h
+++ b/include/tst_cgroup.h
@@ -215,4 +215,7 @@ int safe_cg_occursin(const char *file, const int lineno,
const char *const file_name,
const char *const needle);
+int tst_cg_memory_recursiveprot(void)
+ __attribute__ ((warn_unused_result));
+
#endif /* TST_CGROUP_H */
diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c
index dc090b70a..01fa55e5b 100644
--- a/lib/tst_cgroup.c
+++ b/lib/tst_cgroup.c
@@ -76,6 +76,8 @@ struct cgroup_root {
int we_mounted_it:1;
/* cpuset is in compatability mode */
int no_cpuset_prefix:1;
+ /* V2 is mounted with memory_recursive_prot */
+ int memory_recursiveprot:1;
};
/* Controller sub-systems */
@@ -368,7 +370,7 @@ static void cgroup_root_scan(const char *const mnt_type,
const struct cgroup_ctrl *const_ctrl;
struct cgroup_ctrl *ctrl;
uint32_t ctrl_field = 0;
- int no_prefix = 0;
+ int no_prefix = 0, memory_recursiveprot = 0;
char buf[BUFSIZ];
char *tok;
const int mnt_dfd = SAFE_OPEN(mnt_dir, O_PATH | O_DIRECTORY);
@@ -376,6 +378,9 @@ static void cgroup_root_scan(const char *const mnt_type,
if (!strcmp(mnt_type, "cgroup"))
goto v1;
+ for (tok = strtok(mnt_opts, ","); tok; tok = strtok(NULL, ","))
+ memory_recursiveprot |= !strcmp("memory_recursiveprot", tok);
+
SAFE_FILE_READAT(mnt_dfd, "cgroup.controllers", buf, sizeof(buf));
for (tok = strtok(buf, " "); tok; tok = strtok(NULL, " ")) {
@@ -433,6 +438,7 @@ backref:
root->mnt_dir.dir_fd = mnt_dfd;
root->ctrl_field = ctrl_field;
root->no_cpuset_prefix = no_prefix;
+ root->memory_recursiveprot = memory_recursiveprot;
for_each_ctrl(ctrl) {
if (has_ctrl(root->ctrl_field, ctrl))
@@ -1212,3 +1218,8 @@ int safe_cg_occursin(const char *const file, const int lineno,
return !!strstr(buf, needle);
}
+
+int tst_cg_memory_recursiveprot(void)
+{
+ return roots[0].memory_recursiveprot;
+}
--
2.34.1
More information about the ltp
mailing list