|
9 | 9 | #include <stdio.h>
|
10 | 10 | #include <stdlib.h>
|
11 | 11 | #include <sys/mount.h>
|
| 12 | +#include <fcntl.h> |
| 13 | +#include <unistd.h> |
12 | 14 |
|
13 | 15 | #include "tst_test.h"
|
14 | 16 | #include "tst_safe_macros.h"
|
|
17 | 19 | #include "tst_device.h"
|
18 | 20 |
|
19 | 21 | static enum tst_cgroup_ver tst_cg_ver;
|
| 22 | +static int clone_children; |
20 | 23 |
|
21 | 24 | static int tst_cgroup_check(const char *cgroup)
|
22 | 25 | {
|
@@ -88,6 +91,7 @@ static void tst_cgroup1_mount(const char *name, const char *option,
|
88 | 91 | */
|
89 | 92 | if (strcmp(option, "cpuset") == 0) {
|
90 | 93 | sprintf(knob_path, "%s/cgroup.clone_children", mnt_path);
|
| 94 | + SAFE_FILE_SCANF(knob_path, "%d", &clone_children); |
91 | 95 | SAFE_FILE_PRINTF(knob_path, "%d", 1);
|
92 | 96 | }
|
93 | 97 | out:
|
@@ -123,6 +127,7 @@ static void tst_cgroupN_umount(const char *mnt_path, const char *new_path)
|
123 | 127 | FILE *fp;
|
124 | 128 | int fd;
|
125 | 129 | char s_new[BUFSIZ], s[BUFSIZ], value[BUFSIZ];
|
| 130 | + char knob_path[PATH_MAX]; |
126 | 131 |
|
127 | 132 | if (!tst_is_mounted(mnt_path))
|
128 | 133 | return;
|
@@ -151,6 +156,13 @@ static void tst_cgroupN_umount(const char *mnt_path, const char *new_path)
|
151 | 156 | != (ssize_t)strlen(value) - 1)
|
152 | 157 | tst_res(TWARN | TERRNO, "write %s", s);
|
153 | 158 | }
|
| 159 | + if (tst_cg_ver & TST_CGROUP_V1) { |
| 160 | + sprintf(knob_path, "%s/cpuset.cpus", mnt_path); |
| 161 | + if (!access(knob_path, F_OK)) { |
| 162 | + sprintf(knob_path, "%s/cgroup.clone_children", mnt_path); |
| 163 | + SAFE_FILE_PRINTF(knob_path, "%d", clone_children); |
| 164 | + } |
| 165 | + } |
154 | 166 | if (fd != -1)
|
155 | 167 | close(fd);
|
156 | 168 | if (fp != NULL)
|
|
0 commit comments