From: Richard Palethorpe via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Cc: "Michal Koutný" <mkoutny@suse.com>,
"Richard Palethorpe" <rpalethorpe@suse.com>
Subject: [LTP] [PATCH v3 1/2] API/cgroup: Expose memory_recursiveprot V2 mount opt
Date: Tue, 22 Feb 2022 12:45:46 +0000 [thread overview]
Message-ID: <20220222124547.14396-2-rpalethorpe@suse.com> (raw)
In-Reply-To: <20220222124547.14396-1-rpalethorpe@suse.com>
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2022-02-22 12:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-22 12:45 [LTP] [PATCH v3 0/2] memcontrol04 Richard Palethorpe via ltp
2022-02-22 12:45 ` Richard Palethorpe via ltp [this message]
2022-02-22 14:53 ` [LTP] [PATCH v3 1/2] API/cgroup: Expose memory_recursiveprot V2 mount opt Michal Koutný via ltp
2022-02-28 9:22 ` Richard Palethorpe
2022-03-01 3:28 ` Li Wang
2022-02-22 12:45 ` [LTP] [PATCH v3 2/2] memcontrol04: Copy from kselftest Richard Palethorpe via ltp
2022-02-22 14:45 ` Michal Koutný via ltp
2022-03-01 4:14 ` Li Wang
2022-03-01 3:55 ` Li Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220222124547.14396-2-rpalethorpe@suse.com \
--to=ltp@lists.linux.it \
--cc=mkoutny@suse.com \
--cc=rpalethorpe@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox