Skip to contentSkip to conversation

cpuset_memory_test.c: Use $TMPDIR as prefix for HUGEPAGE file path

PATCH In review Wei Gao via ltp 3 participants 62 messages Aug 1, 2024 – Apr 1, 2025 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpuset_memory_test.c: Use $TMPDIR as prefix for HUGEPAGE file path

Test case will fail with following error if running operation system which force root path read ONLY.

mkdir: cannot create directory ‘/hugetlb’: Read-only file system

---
 .../cpuset_memory_test/cpuset_memory_test.c      | 11 ++++++++---
 .../cpuset_memory_test/cpuset_memory_testset.sh  | 16 ++++++++--------
 2 files changed, 16 insertions(+), 11 deletions(-)
testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_test.c +8 -3
index 9912d8d6a..73770fd3c 100644
@@ -177,9 +177,14 @@ void mmap_file(int flag_allocated)
 	static int fd_hugepage;
 	int fd_tmp;
 
+	char path[100];
+	char *tmpdir = getenv("TMPDIR");
+
+	sprintf(path, "%s%s", tmpdir, FILE_HUGEPAGE);
+
 	if (!flag_allocated) {
 		if (opt_hugepage) {
-			fd_hugepage = open(FILE_HUGEPAGE,
+			fd_hugepage = open(path,
 					   O_CREAT | O_RDWR, 0755);
 			if (fd_hugepage < 0)
 				err(1, "open hugepage file failed");
@@ -191,7 +196,7 @@ void mmap_file(int flag_allocated)
 			 MAP_SHARED, fd_tmp, 0);
 		if (p == MAP_FAILED) {
 			if (opt_hugepage)
-				unlink(FILE_HUGEPAGE);
+				unlink(path);
 			err(1, "mmap(file) failed");
 		}
 		touch_memory_and_echo_node(p, memsize);
@@ -201,7 +206,7 @@ void mmap_file(int flag_allocated)
 
 		if (opt_hugepage) {
 			close(fd_hugepage);
-			unlink(FILE_HUGEPAGE);
+			unlink(path);
 		}
 	}
 }
testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh +8 -8
index c1e7cea8f..b63425088 100755
@@ -175,8 +175,8 @@ test6()
 		return 0
 	fi
 
-	mkdir /hugetlb
-	mount -t hugetlbfs none /hugetlb
+	mkdir ${TMPDIR}/hugetlb
+	mount -t hugetlbfs none ${TMPDIR}/hugetlb
 
 	save_nr_hugepages=$(cat /proc/sys/vm/nr_hugepages)
 	echo $((2*$nr_mems)) > /proc/sys/vm/nr_hugepages
@@ -184,8 +184,8 @@ test6()
 	cpuset_memory_test --mmap-file --hugepage -s $HUGEPAGESIZE >"$MEMORY_RESULT" &
 	simple_getresult $! "$CPUSET/0"
 
-	umount /hugetlb
-	rmdir /hugetlb
+	umount ${TMPDIR}/hugetlb
+	rmdir ${TMPDIR}/hugetlb
 
 	echo $save_nr_hugepages > /proc/sys/vm/nr_hugepages
 	if [ $(cat /proc/sys/vm/nr_hugepages) -ne $save_nr_hugepages ]; then
@@ -214,8 +214,8 @@ test7()
 		return 0
 	fi
 
-	mkdir /hugetlb
-	mount -t hugetlbfs none /hugetlb
+	mkdir ${TMPDIR}/hugetlb
+	mount -t hugetlbfs none ${TMPDIR}/hugetlb
 
 	save_nr_hugepages=$(cat /proc/sys/vm/nr_hugepages)
 	echo $((2*$nr_mems)) > /proc/sys/vm/nr_hugepages
@@ -223,8 +223,8 @@ test7()
 	cpuset_memory_test --shm --hugepage -s $HUGEPAGESIZE --key=7 >"$MEMORY_RESULT" &
 	simple_getresult $! "$CPUSET/0"
 
-	umount /hugetlb
-	rmdir /hugetlb
+	umount ${TMPDIR}/hugetlb
+	rmdir ${TMPDIR}/hugetlb
 
 	echo $save_nr_hugepages > /proc/sys/vm/nr_hugepages
 	if [ $(cat /proc/sys/vm/nr_hugepages) -ne $save_nr_hugepages ]; then
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Wei,

Quoted 16 lines

Test case will fail with following error if running operation system which force root path read ONLY.

mkdir: cannot create directory ‘/hugetlb’: Read-only file system

---
 .../cpuset_memory_test/cpuset_memory_test.c      | 11 ++++++++---
 .../cpuset_memory_test/cpuset_memory_testset.sh  | 16 ++++++++--------
 2 files changed, 16 insertions(+), 11 deletions(-)
testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_test.c +0 -0
index 9912d8d6a..73770fd3c 100644

testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_test.c void mmap_file(int flag_allocated) · line 183

Quoted 7 lines
testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_test.c +4 -0
@@ -177,9 +177,14 @@ void mmap_file(int flag_allocated)
 	static int fd_hugepage;
 	int fd_tmp;
 
+	char path[100];
+	char *tmpdir = getenv("TMPDIR");
+
+	sprintf(path, "%s%s", tmpdir, FILE_HUGEPAGE);

FYI, we have custom function, thus no need to detect TMPDIR in the test.

Because this is still the legacy API, could you please use tst_tmpdir_path()?

FYI in the new API We had for a long time tst_get_tmpdir() function needed to use free() and was used for snprintf(), but Cyril changed that quite recently:
https://github.com/linux-test-project/ltp/commit/c5d95b6d34e2356bd19e6b646da06f1bce66a024

Since that just use tst_tmpdir_path(), no need to free.

IMHO both legacy API and new API do chdir() to the temporary directory, see lib/tst_tmpdir.c:

    if (chdir(TESTDIR) == -1) {
        tst_resm(TERRNO, "%s: chdir(%s) failed", __func__, TESTDIR);

Therefore unless there is full path needed (e.g. search in /proc/mounts) we could use relative path, e.g. add "./" to the definition:

+++ testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_test.c @@ -58,7 +58,7 @@ static int opt_thread;
static int key_id; /* used with opt_shm */
static unsigned long memsize;

-#define FILE_HUGEPAGE "/hugetlb/hugepagefile"
+#define FILE_HUGEPAGE "./hugetlb/hugepagefile"

#define MMAP_ANON (SCHAR_MAX + 1)
#define MMAP_FILE (SCHAR_MAX + 2)
---

Also, the same definition is in testcases/kernel/controllers/memcg/functional/memcg_process.c, is it affected as well?

FYI Besides that it's always better to use 'n' sprintf functions (e.g. snprintf(), because they restrict the write size (man printf(3): "write at most size bytes")

Quoted 31 lines
testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_test.c +4 -3
+
 	if (!flag_allocated) {
 		if (opt_hugepage) {
-			fd_hugepage = open(FILE_HUGEPAGE,
+			fd_hugepage = open(path,
 					   O_CREAT | O_RDWR, 0755);
 			if (fd_hugepage < 0)
 				err(1, "open hugepage file failed");
@@ -191,7 +196,7 @@ void mmap_file(int flag_allocated)
 			 MAP_SHARED, fd_tmp, 0);
 		if (p == MAP_FAILED) {
 			if (opt_hugepage)
-				unlink(FILE_HUGEPAGE);
+				unlink(path);
 			err(1, "mmap(file) failed");
 		}
 		touch_memory_and_echo_node(p, memsize);
@@ -201,7 +206,7 @@ void mmap_file(int flag_allocated)
 
 		if (opt_hugepage) {
 			close(fd_hugepage);
-			unlink(FILE_HUGEPAGE);
+			unlink(path);
 		}
 	}
 }
testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh +0 -0
index c1e7cea8f..b63425088 100755

testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh test6() · line 178

Quoted 6 lines
testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh +1 -2
@@ -175,8 +175,8 @@ test6()
 		return 0
 	fi
 
-	mkdir /hugetlb
-	mount -t hugetlbfs none /hugetlb
+	mkdir ${TMPDIR}/hugetlb

Could you please use $TMPDIR instead of ${TMPDIR}? (more readable).

testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh test6() · line 179

Quoted 1 line
testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh +1 -0
+	mount -t hugetlbfs none ${TMPDIR}/hugetlb

And here (there are more places).

BTW just ./hugetlb could work, right? Also, in the shell API we are in the directory.

And thanks for pointing these tests, once Cyril's effort for mixing C and shell code is merged, we should adapt these tests to use it.

https://patchwork.ozlabs.org/project/ltp/list/?series=417372&state=*

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw
In reply to Wei Gao via ltp

Hi!

Quoted 4 lines

Test case will fail with following error if running operation system which force root path read ONLY.

mkdir: cannot create directory ‘/hugetlb’: Read-only file system

Can we please stop applying band aids over the mess called cpuset tests and start actually rewriting them into something saner?

I would start by reimplementing the test6 as a separate C testcase so that we can make use of all the infrastructure for hugepages we have in the tst_test.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

PATCH v2 1/1 cpuset02: Reimplementing the test6 of cpuset_memory_testset.sh as a separate C testcase

In reply to Wei Gao via ltp
---
 runtest/mm                                    |   1 +
 .../cpuset_memory_test/cpuset_memory_test.c   |  15 +-
 testcases/kernel/mem/.gitignore               |   1 +
 testcases/kernel/mem/cpuset/cpuset02.c        | 152 ++++++++++++++++++
 4 files changed, 163 insertions(+), 6 deletions(-)
 create mode 100644 testcases/kernel/mem/cpuset/cpuset02.c
runtest/mm +1 -0
index 6a8cd0b9d..845874c41 100644
@@ -75,6 +75,7 @@ ksm06_2 ksm06 -n 8000
 ksm07 ksm07
 
 cpuset01 cpuset01
+cpuset02 cpuset02
 
 oom01 oom01
 oom02 oom02
testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_test.c +9 -6
index 9912d8d6a..4e9e40ea2 100644
@@ -56,10 +56,9 @@ static int opt_check; /* check node when munmap memory (only for mmap_anon()) */
 static int opt_thread;
 
 static int key_id;			/* used with opt_shm */
+static char hugepagefile[100] = "/hugetlb/hugepagefile";
 static unsigned long memsize;
 
-#define FILE_HUGEPAGE	"/hugetlb/hugepagefile"
-
 #define MMAP_ANON	(SCHAR_MAX + 1)
 #define MMAP_FILE	(SCHAR_MAX + 2)
 #define MMAP_LOCK1	(SCHAR_MAX + 3)
@@ -80,6 +79,7 @@ const struct option long_opts[] = {
 	{"thread", 0, NULL, THREAD},
 	{"size", 1, NULL, 's'},
 	{"key", 1, NULL, 'k'},
+	{"hugepage-file", 1, NULL, 'f'},
 	{NULL, 0, NULL, 0},
 };
 
@@ -92,7 +92,7 @@ void process_options(int argc, char *argv[])
 	char *end;
 
 	while (1) {
-		c = getopt_long(argc, argv, "s:k:", long_opts, NULL);
+		c = getopt_long(argc, argv, "s:k:f:", long_opts, NULL);
 		if (c == -1)
 			break;
 
@@ -105,6 +105,9 @@ void process_options(int argc, char *argv[])
 		case 'k':
 			key_id = atoi(optarg);
 			break;
+		case 'f':
+			strncpy(hugepagefile, optarg, sizeof(hugepagefile) - 1);
+			break;
 		case MMAP_ANON:
 			opt_mmap_anon = 1;
 			break;
@@ -179,7 +182,7 @@ void mmap_file(int flag_allocated)
 
 	if (!flag_allocated) {
 		if (opt_hugepage) {
-			fd_hugepage = open(FILE_HUGEPAGE,
+			fd_hugepage = open(hugepagefile,
 					   O_CREAT | O_RDWR, 0755);
 			if (fd_hugepage < 0)
 				err(1, "open hugepage file failed");
@@ -191,7 +194,7 @@ void mmap_file(int flag_allocated)
 			 MAP_SHARED, fd_tmp, 0);
 		if (p == MAP_FAILED) {
 			if (opt_hugepage)
-				unlink(FILE_HUGEPAGE);
+				unlink(hugepagefile);
 			err(1, "mmap(file) failed");
 		}
 		touch_memory_and_echo_node(p, memsize);
@@ -201,7 +204,7 @@ void mmap_file(int flag_allocated)
 
 		if (opt_hugepage) {
 			close(fd_hugepage);
-			unlink(FILE_HUGEPAGE);
+			unlink(hugepagefile);
 		}
 	}
 }
testcases/kernel/mem/.gitignore +1 -0
index c96fe8bfc..f01953b5c 100644
@@ -1,4 +1,5 @@
 /cpuset/cpuset01
+/cpuset/cpuset02
 /hugetlb/hugefallocate/hugefallocate01
 /hugetlb/hugefallocate/hugefallocate02
 /hugetlb/hugefork/hugefork01
testcases/kernel/mem/cpuset/cpuset02.c new file +152 -0

152 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

PATCH v3 1/1 cpuset02: Reimplementing the test6 of cpuset_memory_testset.sh as a separate C testcase

---
 runtest/mm                                    |   1 +
 .../cpuset_memory_test/cpuset_memory_test.c   |  15 +-
 testcases/kernel/mem/.gitignore               |   1 +
 testcases/kernel/mem/cpuset/cpuset02.c        | 147 ++++++++++++++++++
 4 files changed, 158 insertions(+), 6 deletions(-)
 create mode 100644 testcases/kernel/mem/cpuset/cpuset02.c
runtest/mm +1 -0
index 6a8cd0b9d..845874c41 100644
@@ -75,6 +75,7 @@ ksm06_2 ksm06 -n 8000
 ksm07 ksm07
 
 cpuset01 cpuset01
+cpuset02 cpuset02
 
 oom01 oom01
 oom02 oom02
testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_test.c +9 -6
index 9912d8d6a..4e9e40ea2 100644
@@ -56,10 +56,9 @@ static int opt_check; /* check node when munmap memory (only for mmap_anon()) */
 static int opt_thread;
 
 static int key_id;			/* used with opt_shm */
+static char hugepagefile[100] = "/hugetlb/hugepagefile";
 static unsigned long memsize;
 
-#define FILE_HUGEPAGE	"/hugetlb/hugepagefile"
-
 #define MMAP_ANON	(SCHAR_MAX + 1)
 #define MMAP_FILE	(SCHAR_MAX + 2)
 #define MMAP_LOCK1	(SCHAR_MAX + 3)
@@ -80,6 +79,7 @@ const struct option long_opts[] = {
 	{"thread", 0, NULL, THREAD},
 	{"size", 1, NULL, 's'},
 	{"key", 1, NULL, 'k'},
+	{"hugepage-file", 1, NULL, 'f'},
 	{NULL, 0, NULL, 0},
 };
 
@@ -92,7 +92,7 @@ void process_options(int argc, char *argv[])
 	char *end;
 
 	while (1) {
-		c = getopt_long(argc, argv, "s:k:", long_opts, NULL);
+		c = getopt_long(argc, argv, "s:k:f:", long_opts, NULL);
 		if (c == -1)
 			break;
 
@@ -105,6 +105,9 @@ void process_options(int argc, char *argv[])
 		case 'k':
 			key_id = atoi(optarg);
 			break;
+		case 'f':
+			strncpy(hugepagefile, optarg, sizeof(hugepagefile) - 1);
+			break;
 		case MMAP_ANON:
 			opt_mmap_anon = 1;
 			break;
@@ -179,7 +182,7 @@ void mmap_file(int flag_allocated)
 
 	if (!flag_allocated) {
 		if (opt_hugepage) {
-			fd_hugepage = open(FILE_HUGEPAGE,
+			fd_hugepage = open(hugepagefile,
 					   O_CREAT | O_RDWR, 0755);
 			if (fd_hugepage < 0)
 				err(1, "open hugepage file failed");
@@ -191,7 +194,7 @@ void mmap_file(int flag_allocated)
 			 MAP_SHARED, fd_tmp, 0);
 		if (p == MAP_FAILED) {
 			if (opt_hugepage)
-				unlink(FILE_HUGEPAGE);
+				unlink(hugepagefile);
 			err(1, "mmap(file) failed");
 		}
 		touch_memory_and_echo_node(p, memsize);
@@ -201,7 +204,7 @@ void mmap_file(int flag_allocated)
 
 		if (opt_hugepage) {
 			close(fd_hugepage);
-			unlink(FILE_HUGEPAGE);
+			unlink(hugepagefile);
 		}
 	}
 }
testcases/kernel/mem/.gitignore +1 -0
index d88484fa1..0845297cb 100644
@@ -1,4 +1,5 @@
 /cpuset/cpuset01
+/cpuset/cpuset02
 /hugetlb/hugefallocate/hugefallocate01
 /hugetlb/hugefallocate/hugefallocate02
 /hugetlb/hugefork/hugefork01
testcases/kernel/mem/cpuset/cpuset02.c new file +147 -0

147 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

Re: [LTP] [PATCH v3] cpuset02: Reimplementing the test6 of cpuset_memory_testset.sh as a separate C testcase

Hi!

Quoted 16 lines
testcases/kernel/mem/.gitignore +1 -0
index d88484fa1..0845297cb 100644
@@ -1,4 +1,5 @@
 /cpuset/cpuset01
+/cpuset/cpuset02
 /hugetlb/hugefallocate/hugefallocate01
 /hugetlb/hugefallocate/hugefallocate02
 /hugetlb/hugefork/hugefork01
testcases/kernel/mem/cpuset/cpuset02.c new file +0 -0
new file mode 100644
index 000000000..05ed5c791

testcases/kernel/mem/cpuset/cpuset02.c line 10

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +10 -0
@@ -0,0 +1,147 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/*
+ * Copyright (c) 2009 FUJITSU LIMITED  Miao Xie <[email protected]>
+ * Copyright (c) 2023 SUSE LLC <[email protected]>
+ */
+
+/*\
+ * [Description]
+ *
+ * This is reimplementing the test6 of cpuset_memory_testset.sh

This is _WRONG_.

You have to describe what the test does here, not where it came from.

Quoted 31 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +31 -0
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <sys/mount.h>
+#include <limits.h>
+#include <sys/param.h>
+#include <sys/types.h>
+
+#include "tst_test.h"
+
+#if HAVE_NUMA_H
+#include <numa.h>
+#endif
+#if HAVE_NUMAIF_H
+#include <numaif.h>
+#endif
+
+#include "tst_safe_stdio.h"
+#include "mem.h"
+#include "numa_helper.h"
+
+#define MNTPOINT "hugetlbfs/"
+#define CPUSET "cpuset_mnt"
+
+#ifdef HAVE_NUMA_V2
+
+static long hpage_size;
+static int ncpus;
+static int *nodes;
+static int nnodes;

testcases/kernel/mem/cpuset/cpuset02.c line 52

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +10 -0
+
+static void count_cpus_mems(void)
+{
+	while (path_exist(PATH_SYS_SYSTEM "/cpu/cpu%d", ncpus))
+		ncpus++;
+	if (get_allowed_nodes_arr(NH_MEMS | NH_CPUS, &nnodes, &nodes) < 0)
+		tst_brk(TBROK | TERRNO, "get_allowed_nodes_arr");
+	if (nnodes <= 1)
+		tst_brk(TCONF, "requires a NUMA system.");
+}

You must use the tst_get_nodemap() instead which also allows you to specify how much free memory is required for each NUMA node.

Quoted 47 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +47 -0
+static void run_test(void)
+{
+	char path[256];
+	char tmp_path[256];
+
+	snprintf(path, sizeof(path), "./%s/0", CPUSET);
+	if (access(path, F_OK) != 0)
+		SAFE_MKDIR(path, 0777);
+	snprintf(tmp_path, sizeof(tmp_path), "./%s/cpuset.cpus", path);
+	SAFE_FILE_PRINTF(tmp_path, "%s", "0");
+	snprintf(tmp_path, sizeof(tmp_path), "./%s/cpuset.mems", path);
+	SAFE_FILE_PRINTF(tmp_path, "%s", "0");
+	snprintf(tmp_path, sizeof(tmp_path), "./%s/cpuset.sched_load_balance", path);
+	SAFE_FILE_PRINTF(tmp_path, "%s", "0");
+	SAFE_FILE_PRINTF("/proc/sys/vm/nr_hugepages", "%d", 2 * nnodes);
+
+	int pid;
+	char str_hpage_size[20];
+
+	snprintf(str_hpage_size, sizeof(str_hpage_size), "%ld", hpage_size);
+	snprintf(tmp_path, sizeof(tmp_path), "%shugepagefile", MNTPOINT);
+
+	char *argv[10] = {
+		"--mmap-file",
+		"--hugepage",
+		"-s",
+		str_hpage_size,
+		"-f",
+		tmp_path,
+		NULL,
+	};
+
+	int fd = SAFE_OPEN("memory_result", O_WRONLY | O_CREAT | O_TRUNC, 0644);
+
+	SAFE_DUP2(fd, STDOUT_FILENO);
+	pid = tst_run_script("cpuset_memory_test", argv);
+	close(fd);
+
+	sleep(1);
+	snprintf(tmp_path, sizeof(tmp_path), "./%s/tasks", path);
+	SAFE_FILE_PRINTF(tmp_path, "%d", pid);
+	kill(pid, SIGUSR1);
+	sleep(1);
+	kill(pid, SIGUSR1);
+	sleep(1);
+	kill(pid, SIGINT);
+	SAFE_WAITPID(pid, NULL, 0);

testcases/kernel/mem/cpuset/cpuset02.c line 110

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +10 -0
+
+	char node[20];
+	FILE *file;
+
+	file  = SAFE_FOPEN("memory_result", "r");
+
+	if (fgets(node, sizeof(node), file) == NULL)
+		tst_res(TFAIL, "read memory_result failed");
+
+	fclose(file);

The whole point of the rewrite is to get rid of this mess where we propagate the test results in files.

The code that allocates the memory has to be in this test and use proper synchronization between processes, i.e. checkpoints. This would also avoid the need to propagate test results because the forked child could report results directly.

testcases/kernel/mem/cpuset/cpuset02.c line 121

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +10 -0
+	TST_EXP_PASS(strncmp(node, "0", 1));
+}
+
+static void setup(void)
+{
+	count_cpus_mems();
+
+	hpage_size = SAFE_READ_MEMINFO(MEMINFO_HPAGE_SIZE)*1024;
+	SAFE_MKDIR(CPUSET, 0777);
+	SAFE_MOUNT("cpuset", CPUSET, "cgroup", 0, "cpuset");

You have to use the .needs_cgroup_ctrls in tst_test instead.

Quoted 32 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +26 -0
+}
+
+static void cleanup(void)
+{
+	SAFE_UMOUNT(CPUSET);
+}
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.runs_script = 1,
+	.mntpoint = MNTPOINT,
+	.needs_hugetlbfs = 1,
+	.setup = setup,
+	.forks_child = 1,
+	.cleanup = cleanup,
+	.test_all = run_test,
+	.hugepages = {3, TST_NEEDS},
+	.save_restore = (const struct tst_path_val[]) {
+		{"/proc/sys/vm/nr_hugepages", NULL, TST_SR_TBROK},
+		{}
+	},
+};
+
+#else
+TST_TEST_TCONF(NUMA_ERROR_MSG);
+#endif
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

PATCH v4 1/1 cpuset02: Reimplementing the test6 of cpuset_memory_testset.sh as a separate C testcase

In reply to Wei Gao via ltp
---
 lib/tst_cgroup.c                       |   1 +
 runtest/mm                             |   1 +
 testcases/kernel/mem/.gitignore        |   1 +
 testcases/kernel/mem/cpuset/Makefile   |   7 ++
 testcases/kernel/mem/cpuset/cpuset02.c | 140 +++++++++++++++++++++++++
 5 files changed, 150 insertions(+)
 create mode 100644 testcases/kernel/mem/cpuset/cpuset02.c
lib/tst_cgroup.c +1 -0
index 6055015eb..1404116a5 100644
@@ -203,6 +203,7 @@ static const struct cgroup_file cpuset_ctrl_files[] = {
 	{ "cpuset.cpus", "cpuset.cpus", CTRL_CPUSET },
 	{ "cpuset.mems", "cpuset.mems", CTRL_CPUSET },
 	{ "cpuset.memory_migrate", "cpuset.memory_migrate", CTRL_CPUSET },
+	{ "cpuset.sched_load_balance", "cpuset.sched_load_balance", CTRL_CPUSET },
 	{ }
 };
 
runtest/mm +1 -0
index 6a8cd0b9d..845874c41 100644
@@ -75,6 +75,7 @@ ksm06_2 ksm06 -n 8000
 ksm07 ksm07
 
 cpuset01 cpuset01
+cpuset02 cpuset02
 
 oom01 oom01
 oom02 oom02
testcases/kernel/mem/.gitignore +1 -0
index d88484fa1..0845297cb 100644
@@ -1,4 +1,5 @@
 /cpuset/cpuset01
+/cpuset/cpuset02
 /hugetlb/hugefallocate/hugefallocate01
 /hugetlb/hugefallocate/hugefallocate02
 /hugetlb/hugefork/hugefork01
testcases/kernel/mem/cpuset/Makefile +7 -0
index 8e41c0223..366d67ce9 100644
@@ -19,6 +19,13 @@
 
 top_srcdir		?= ../../../..
 
+LTPLIBS = numa
+
 include $(top_srcdir)/include/mk/testcases.mk
 include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk
+
+LDLIBS  += $(NUMA_LIBS)
+LDLIBS  += $(top_srcdir)/testcases/kernel/controllers/cpuset/cpuset_lib/libcpu_set.a
+LTPLDLIBS = -lltpnuma
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/cpuset/cpuset02.c new file +140 -0

140 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw

Re: [LTP] [PATCH v4] cpuset02: Reimplementing the test6 of cpuset_memory_testset.sh as a separate C testcase

Hi Wei, Cyril,

Quoted 1 line

"Reimplementing the test6 of cpuset_memory_testset.sh as a separate C testcase"

This could be followed by removing test6 from cpuset_memory_testset.sh?

The conversion itself from shell test test6 LGTM.

I suppose the reason is that moving code to C improves stability of the test. But this would be nice to mention in the commit message. (Remember "what" versus "why" - often the reason for the change is more important that describing the change.)

Quoted 4 lines

index 8e41c0223..366d67ce9 100644

testcases/kernel/mem/cpuset/Makefile line 28

Quoted 10 lines
testcases/kernel/mem/cpuset/Makefile +5 -0
@@ -19,6 +19,13 @@
 
 top_srcdir		?= ../../../..
 
+LTPLIBS = numa
+
 include $(top_srcdir)/include/mk/testcases.mk
 include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk
+
+LDLIBS  += $(NUMA_LIBS)
+LDLIBS  += $(top_srcdir)/testcases/kernel/controllers/cpuset/cpuset_lib/libcpu_set.a

This is not enough, because there is no build dependency on libcpu_set.a.

Other tests which depends on libcpu_set.a are in the subdirectories (e.g. testcases/kernel/controllers/cpuset/cpuset_hotplug_test/) and they use testcases/kernel/controllers/cpuset/Makefile.inc. Can you somehow use it?

Maybe we should move cpuset_lib code to libs/ directory, when used elsewhere.

That would also help to avoid ugly includes like:

testcases/kernel/mem/cpuset/Makefile line 29

Quoted 1 line
testcases/kernel/mem/cpuset/Makefile +1 -0
+#include "../../controllers/cpuset/cpuset_lib/cpuset.h"

(This could be also improved with CFLAGS += -I../../controllers/cpuset/cpuset_lib/.)

Quoted 9 lines
testcases/kernel/mem/cpuset/Makefile +2 -0
+LTPLDLIBS = -lltpnuma
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/cpuset/cpuset02.c new file +0 -0
new file mode 100644
index 000000000..a62c98b3f

testcases/kernel/mem/cpuset/cpuset02.c line 10

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +10 -0
@@ -0,0 +1,140 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/*
+ * Copyright (c) 2009 FUJITSU LIMITED  Miao Xie <[email protected]>
+ * Copyright (c) 2023 SUSE LLC <[email protected]>
+ */
+
+/*\
+ * [Description]
+ *
+ * This test check cpuset's mems work with hugepage file.

Maybe: Test checks cpuset.mems works with hugepage file.

testcases/kernel/mem/cpuset/cpuset02.c line 11

Quoted 1 line
testcases/kernel/mem/cpuset/cpuset02.c new file +1 -0
+ *

Please remove the blank line above ^.

Quoted 1 line
testcases/kernel/mem/cpuset/cpuset02.c new file +1 -0
+ */

...

testcases/kernel/mem/cpuset/cpuset02.c line 45

Quoted 6 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +6 -0
+static void count_cpus_mems(void)
+{
+	node = tst_get_nodemap(TST_NUMA_MEM, PAGES_ALLOCATED * getpagesize() / 1024);
+	if (node->cnt <= 1)
+		tst_brk(TCONF, "test requires NUMA system");
+}

nit: Function used only once, I would move the code into setup().

Later (separate effort), this function (with size parameter) could be in libs/numa/tst_numa.c, because it's used in many tests, or even added into struct tst_test.

Quoted 2 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +2 -0
+static void run_test(void)
+{

...

testcases/kernel/mem/cpuset/cpuset02.c line 104

Quoted 13 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +13 -0
+	pid = SAFE_FORK();
+	if (!pid) {
+		child();
+	} else {
+		SAFE_CG_PRINTF(cg_cpuset_0, "cgroup.procs", "%d", pid);
+
+		TST_CHECKPOINT_WAKE(0);
+		TST_CHECKPOINT_WAIT(1);
+
+		SAFE_WAITPID(pid, NULL, 0);
+
+		cg_cpuset_0 = tst_cg_group_rm(cg_cpuset_0);
+	}

Very nit: IMHO saving indent would be more readable:

	if (!pid) {
		child();
		return; // or call exit() in child() and no return here.
	}

	SAFE_CG_PRINTF(cg_cpuset_0, "cgroup.procs", "%d", pid);

	TST_CHECKPOINT_WAKE(0);
	TST_CHECKPOINT_WAIT(1);

	SAFE_WAITPID(pid, NULL, 0);

	cg_cpuset_0 = tst_cg_group_rm(cg_cpuset_0);

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#8 lore raw

Re: [LTP] [PATCH v4] cpuset02: Reimplementing the test6 of cpuset_memory_testset.sh as a separate C testcase

Quoted 28 lines · Petr Vorel

Hi Wei, Cyril,

Quoted 1 line

"Reimplementing the test6 of cpuset_memory_testset.sh as a separate C testcase"

This could be followed by removing test6 from cpuset_memory_testset.sh?

The conversion itself from shell test test6 LGTM.

I suppose the reason is that moving code to C improves stability of the test. But this would be nice to mention in the commit message. (Remember "what" versus "why" - often the reason for the change is more important that describing the change.)

Quoted 4 lines

index 8e41c0223..366d67ce9 100644

testcases/kernel/mem/cpuset/Makefile line 28

Quoted 10 lines
testcases/kernel/mem/cpuset/Makefile +5 -0
@@ -19,6 +19,13 @@
 
 top_srcdir		?= ../../../..
 
+LTPLIBS = numa
+
 include $(top_srcdir)/include/mk/testcases.mk
 include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk
+
+LDLIBS  += $(NUMA_LIBS)
+LDLIBS  += $(top_srcdir)/testcases/kernel/controllers/cpuset/cpuset_lib/libcpu_set.a

This is not enough, because there is no build dependency on libcpu_set.a.

Quoted 5 lines

Other tests which depends on libcpu_set.a are in the subdirectories (e.g. testcases/kernel/controllers/cpuset/cpuset_hotplug_test/) and they use testcases/kernel/controllers/cpuset/Makefile.inc. Can you somehow use it?

Maybe we should move cpuset_lib code to libs/ directory, when used elsewhere.

I have created another new patch for move lib code:
https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/

Quoted 80 lines

That would also help to avoid ugly includes like:

testcases/kernel/mem/cpuset/Makefile line 29

Quoted 1 line
testcases/kernel/mem/cpuset/Makefile +1 -0
+#include "../../controllers/cpuset/cpuset_lib/cpuset.h"

(This could be also improved with CFLAGS += -I../../controllers/cpuset/cpuset_lib/.)

Quoted 9 lines
testcases/kernel/mem/cpuset/Makefile +2 -0
+LTPLDLIBS = -lltpnuma
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/cpuset/cpuset02.c new file +0 -0
new file mode 100644
index 000000000..a62c98b3f

testcases/kernel/mem/cpuset/cpuset02.c line 10

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +10 -0
@@ -0,0 +1,140 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/*
+ * Copyright (c) 2009 FUJITSU LIMITED  Miao Xie <[email protected]>
+ * Copyright (c) 2023 SUSE LLC <[email protected]>
+ */
+
+/*\
+ * [Description]
+ *
+ * This test check cpuset's mems work with hugepage file.

Maybe: Test checks cpuset.mems works with hugepage file.

testcases/kernel/mem/cpuset/cpuset02.c line 11

Quoted 1 line
testcases/kernel/mem/cpuset/cpuset02.c new file +1 -0
+ *

Please remove the blank line above ^.

Quoted 1 line
testcases/kernel/mem/cpuset/cpuset02.c new file +1 -0
+ */

...

testcases/kernel/mem/cpuset/cpuset02.c line 45

Quoted 6 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +6 -0
+static void count_cpus_mems(void)
+{
+	node = tst_get_nodemap(TST_NUMA_MEM, PAGES_ALLOCATED * getpagesize() / 1024);
+	if (node->cnt <= 1)
+		tst_brk(TCONF, "test requires NUMA system");
+}

nit: Function used only once, I would move the code into setup().

Later (separate effort), this function (with size parameter) could be in libs/numa/tst_numa.c, because it's used in many tests, or even added into struct tst_test.

Quoted 2 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +2 -0
+static void run_test(void)
+{

...

testcases/kernel/mem/cpuset/cpuset02.c line 104

Quoted 13 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +13 -0
+	pid = SAFE_FORK();
+	if (!pid) {
+		child();
+	} else {
+		SAFE_CG_PRINTF(cg_cpuset_0, "cgroup.procs", "%d", pid);
+
+		TST_CHECKPOINT_WAKE(0);
+		TST_CHECKPOINT_WAIT(1);
+
+		SAFE_WAITPID(pid, NULL, 0);
+
+		cg_cpuset_0 = tst_cg_group_rm(cg_cpuset_0);
+	}

Very nit: IMHO saving indent would be more readable:

	if (!pid) {
		child();
		return; // or call exit() in child() and no return here.
	}

	SAFE_CG_PRINTF(cg_cpuset_0, "cgroup.procs", "%d", pid);

	TST_CHECKPOINT_WAKE(0);
	TST_CHECKPOINT_WAIT(1);

	SAFE_WAITPID(pid, NULL, 0);

	cg_cpuset_0 = tst_cg_group_rm(cg_cpuset_0);

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#10 lore raw

Re: [LTP] [PATCH v4] cpuset02: Reimplementing the test6 of cpuset_memory_testset.sh as a separate C testcase

Quoted 7 lines · Petr Vorel

Hi Wei,

This fails to build.
https://github.com/pevik/ltp/actions/runs/11628250882

Kind regards,
Petr

Hi Cyril / Petr

I have a question before my next patch.

The old cpuset_memory_testset.sh test is focus ONLY on cgroupv1 test, it setup cgroupv1 mnt point on /dev/cpuset, even on cgroupv2 support system.

If i add needs_cgroup_ver = TST_CG_V1 on current v4 patch, this test will be skipped on system which support cgroupv2, since current cgroup framework will detect cgroupv2 mount point and skip test.

If i do not add needs_cgroup_ver = TST_CG_V1 then error will happen since cgroupv2 does not support cpuset.sched_load_balance anymore.

Finally i have to add new flag such as force_cgroup_ver = TST_CG_V1, so the test case can continue create cgroupv1 mnt point to continue cgroupv1 test regardless detect cgroupv2 or not. What's your suggestion? Thanks.

Regards
Gao Wei

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#11 lore raw

Re: [LTP] [PATCH v4] cpuset02: Reimplementing the test6 of cpuset_memory_testset.sh as a separate C testcase

In reply to Petr Vorel
Quoted 7 lines · Petr Vorel

Hi Wei,

This fails to build.
https://github.com/pevik/ltp/actions/runs/11628250882

Kind regards,
Petr

I also make another proposal for cpuset02 test case.
This will force check/create cgroupv1 test regardless current test system support cgroupv2 or not.

https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#12 lore raw

v5 cover cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

In reply to Wei Gao via ltp

Wei Gao (2):
cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code cpuset_memory_testset.sh: Remove test6

 lib/tst_cgroup.c                              |   1 +
 runtest/mm                                    |   1 +
 .../cpuset_memory_testset.sh                  |  37 +----
 testcases/kernel/mem/.gitignore               |   1 +
 testcases/kernel/mem/cpuset/Makefile          |   6 +
 testcases/kernel/mem/cpuset/cpuset02.c        | 142 ++++++++++++++++++
 .../mq_timedreceive/mq_timedreceive01.c       |  80 +++++++---
 7 files changed, 212 insertions(+), 56 deletions(-)
 create mode 100644 testcases/kernel/mem/cpuset/cpuset02.c
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#13 lore raw

PATCH v5 1/2 cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

Base Cyril Hrubis's suggestion [1].
We should stop applying band aids over the mess called cpuset tests and start actually rewriting them into something saner, and start by reimplementing the test6 as a separate C testcase so that we can make use of all the infrastructure for hugepages we have in the tst_test.

[1] https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/

---
 lib/tst_cgroup.c                              |   1 +
 runtest/mm                                    |   1 +
 testcases/kernel/mem/.gitignore               |   1 +
 testcases/kernel/mem/cpuset/Makefile          |   6 +
 testcases/kernel/mem/cpuset/cpuset02.c        | 142 ++++++++++++++++++
 .../mq_timedreceive/mq_timedreceive01.c       |  80 +++++++---
 6 files changed, 210 insertions(+), 21 deletions(-)
 create mode 100644 testcases/kernel/mem/cpuset/cpuset02.c
lib/tst_cgroup.c +1 -0
index 6055015eb..1404116a5 100644
@@ -203,6 +203,7 @@ static const struct cgroup_file cpuset_ctrl_files[] = {
 	{ "cpuset.cpus", "cpuset.cpus", CTRL_CPUSET },
 	{ "cpuset.mems", "cpuset.mems", CTRL_CPUSET },
 	{ "cpuset.memory_migrate", "cpuset.memory_migrate", CTRL_CPUSET },
+	{ "cpuset.sched_load_balance", "cpuset.sched_load_balance", CTRL_CPUSET },
 	{ }
 };
 
runtest/mm +1 -0
index d8e62af81..5af29b0ea 100644
@@ -75,6 +75,7 @@ ksm06_2 ksm06 -n 8000
 ksm07 ksm07
 
 cpuset01 cpuset01
+cpuset02 cpuset02
 
 oom01 oom01
 oom02 oom02
testcases/kernel/mem/.gitignore +1 -0
index 699e022fb..e24e96001 100644
@@ -1,4 +1,5 @@
 /cpuset/cpuset01
+/cpuset/cpuset02
 /hugetlb/hugefallocate/hugefallocate01
 /hugetlb/hugefallocate/hugefallocate02
 /hugetlb/hugefork/hugefork01
testcases/kernel/mem/cpuset/Makefile +6 -0
index 8e41c0223..9311985b1 100644
@@ -19,6 +19,12 @@
 
 top_srcdir		?= ../../../..
 
+LTPLIBS = numa
+
 include $(top_srcdir)/include/mk/testcases.mk
 include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk
+
+LDLIBS  += $(NUMA_LIBS)
+LTPLDLIBS = -lltpnuma
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/cpuset/cpuset02.c new file +142 -0

142 lines not on this page · raw message

testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c +59 -21

104 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#14 lore raw

Re: [LTP] [PATCH v5 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

Hi Wei,

...

Quoted 6 lines
 lib/tst_cgroup.c                              |   1 +
 runtest/mm                                    |   1 +
 testcases/kernel/mem/.gitignore               |   1 +
 testcases/kernel/mem/cpuset/Makefile          |   6 +
 testcases/kernel/mem/cpuset/cpuset02.c        | 142 ++++++++++++++++++
 .../mq_timedreceive/mq_timedreceive01.c       |  80 +++++++---

This is completely unrelated change. Please remove it in the next version.

...

testcases/kernel/mem/cpuset/Makefile line 27

Quoted 11 lines

+++ b/testcases/kernel/mem/cpuset/Makefile

testcases/kernel/mem/cpuset/Makefile +4 -0
@@ -19,6 +19,12 @@
 
 top_srcdir		?= ../../../..
 
+LTPLIBS = numa
+
 include $(top_srcdir)/include/mk/testcases.mk
 include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk
+
+LDLIBS  += $(NUMA_LIBS)

IMHO we don't need LDLIBS += $(NUMA_LIBS) ? It compiles without it because it's added by /testcases/kernel/include/lib.mk due Cyril's change:
6f830ea5c0 ("lib: Replace path_exist() with tst_path_exists()")

testcases/kernel/mem/cpuset/Makefile line 28

Quoted 1 line
testcases/kernel/mem/cpuset/Makefile +1 -0
+LTPLDLIBS = -lltpnuma

This change is related to cpuset02, it should be prefixed with cpuset02:

..

testcases/kernel/mem/cpuset/cpuset02.c line 8

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +9 -0
+++ b/testcases/kernel/mem/cpuset/cpuset02.c
@@ -0,0 +1,142 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/*
+ * Copyright (c) 2009 FUJITSU LIMITED  Miao Xie <[email protected]>
+ * Copyright (c) 2023 SUSE LLC <[email protected]>
+ */
+
+/*\
+ * [Description]

Also please delete [Description] in next version.

Quoted 9 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +9 -0
+ *
+ * Test checks cpuset.mems works with hugepage file.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <sys/mount.h>
+#include <limits.h>
+#include <sys/param.h>

testcases/kernel/mem/cpuset/cpuset02.c line 27

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +10 -0
+#include <sys/types.h>
+#include "tst_test.h"
+
+#ifdef HAVE_NUMA_V2
+#include <numa.h>
+#include <numaif.h>
+#include <errno.h>
+#include "tst_numa.h"
+#include "tst_safe_stdio.h"
+#include "mem.h"

And, please, rebase. Recent Cyril's cleanup removed "mem.h", see:
decd09c5dab6ad1694857116c011e01f8cc65788~..ac1af455d3384f1bbbda994aee42aeb036c27a23

testcases/kernel/mem/cpuset/cpuset02.c line 32

Quoted 5 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +5 -0
+#include "numa_helper.h"
+
+#define MNTPOINT "hugetlbfs/"
+#define HUGE_PAGE_FILE MNTPOINT "hugepagefile"
+#define PAGES_ALLOCATED 16u

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#15 lore raw

PATCH v5 2/2 cpuset_memory_testset.sh: Remove test6

In reply to Wei Gao via ltp
---
 .../cpuset_memory_testset.sh                  | 37 +------------------
 1 file changed, 2 insertions(+), 35 deletions(-)
testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh +2 -35
index c1e7cea8f..fd41dc97a 100755
@@ -162,41 +162,8 @@ check_hugetlbfs()
 
 test6()
 {
-	cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
-	if [ $? -ne 0 ]; then
-		cpuset_log_error $CPUSET_TMP/stderr
-		tst_resm TFAIL "set general group parameter failed."
-		return 1
-	fi
-
-	check_hugetlbfs
-	if [ $? -eq 0 ]; then
-		tst_resm TCONF "This system don't support hugetlbfs"
-		return 0
-	fi
-
-	mkdir /hugetlb
-	mount -t hugetlbfs none /hugetlb
-
-	save_nr_hugepages=$(cat /proc/sys/vm/nr_hugepages)
-	echo $((2*$nr_mems)) > /proc/sys/vm/nr_hugepages
-
-	cpuset_memory_test --mmap-file --hugepage -s $HUGEPAGESIZE >"$MEMORY_RESULT" &
-	simple_getresult $! "$CPUSET/0"
-
-	umount /hugetlb
-	rmdir /hugetlb
-
-	echo $save_nr_hugepages > /proc/sys/vm/nr_hugepages
-	if [ $(cat /proc/sys/vm/nr_hugepages) -ne $save_nr_hugepages ]; then
-		tst_resm TFAIL "can't restore nr_hugepages(nr_hugepages = $save_nr_hugepages)."
-		return 1
-	fi
-
-	if [ "$node" != "0" ]; then
-		tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)."
-		return 1
-	fi
+	tst_resm TINFO "This test is replaced by testcases/kernel/mem/cpuset/cpuset02.c"
+	return 0
 }
 
 test7()
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#16 lore raw

Re: [LTP] [PATCH v5 2/2] cpuset_memory_testset.sh: Remove test6

Hi Wei,

Quoted 4 lines
---
 .../cpuset_memory_testset.sh                  | 37 +------------------
 1 file changed, 2 insertions(+), 35 deletions(-)

You're supposed to remove cpuset_memory_testset.sh entry from runtest/controllers.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#17 lore raw

Re: [LTP] [PATCH v5 2/2] cpuset_memory_testset.sh: Remove test6

Quoted 9 lines · Petr Vorel

Hi Wei,

Quoted 4 lines
---
 .../cpuset_memory_testset.sh                  | 37 +------------------
 1 file changed, 2 insertions(+), 35 deletions(-)

You're supposed to remove cpuset_memory_testset.sh entry from runtest/controllers.

This patch is hack for remove error which happen on our openqa micro test product.

If we need remove full cpuset_memory_testset.sh, i suppose we need convert all sub cases within cpuset_memory_testset.sh to c case.

Quoted 3 lines

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#18 lore raw

v6 cover cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

In reply to Wei Gao via ltp

Wei Gao (2):
cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code cpuset_memory_testset.sh: Remove test6

 lib/tst_cgroup.c                              |   1 +
 runtest/mm                                    |   1 +
 .../cpuset_memory_testset.sh                  |  37 +----
 testcases/kernel/mem/.gitignore               |   1 +
 testcases/kernel/mem/cpuset/Makefile          |   5 +
 testcases/kernel/mem/cpuset/cpuset02.c        | 139 ++++++++++++++++++
 6 files changed, 149 insertions(+), 35 deletions(-)
 create mode 100644 testcases/kernel/mem/cpuset/cpuset02.c
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#19 lore raw

PATCH v6 1/2 cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

---
 lib/tst_cgroup.c                       |   1 +
 runtest/mm                             |   1 +
 testcases/kernel/mem/.gitignore        |   1 +
 testcases/kernel/mem/cpuset/Makefile   |   5 +
 testcases/kernel/mem/cpuset/cpuset02.c | 139 +++++++++++++++++++++++++
 5 files changed, 147 insertions(+)
 create mode 100644 testcases/kernel/mem/cpuset/cpuset02.c
lib/tst_cgroup.c +1 -0
index 73b696c58..545c779e7 100644
@@ -204,6 +204,7 @@ static const struct cgroup_file cpuset_ctrl_files[] = {
 	{ "cpuset.cpus", "cpuset.cpus", CTRL_CPUSET },
 	{ "cpuset.mems", "cpuset.mems", CTRL_CPUSET },
 	{ "cpuset.memory_migrate", "cpuset.memory_migrate", CTRL_CPUSET },
+	{ "cpuset.sched_load_balance", "cpuset.sched_load_balance", CTRL_CPUSET },
 	{ }
 };
 
runtest/mm +1 -0
index d8e62af81..5af29b0ea 100644
@@ -75,6 +75,7 @@ ksm06_2 ksm06 -n 8000
 ksm07 ksm07
 
 cpuset01 cpuset01
+cpuset02 cpuset02
 
 oom01 oom01
 oom02 oom02
testcases/kernel/mem/.gitignore +1 -0
index 699e022fb..e24e96001 100644
@@ -1,4 +1,5 @@
 /cpuset/cpuset01
+/cpuset/cpuset02
 /hugetlb/hugefallocate/hugefallocate01
 /hugetlb/hugefallocate/hugefallocate02
 /hugetlb/hugefork/hugefork01
testcases/kernel/mem/cpuset/Makefile +5 -0
index bac13e02b..7010c7be4 100644
@@ -19,6 +19,11 @@
 
 top_srcdir		?= ../../../..
 
+LTPLIBS = numa
+
 include $(top_srcdir)/include/mk/testcases.mk
 include $(top_srcdir)/testcases/kernel/include/lib.mk
+
+cpuset02: LTPLDLIBS = -lltpnuma
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/cpuset/cpuset02.c new file +139 -0

139 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v6 1/2
#20 lore raw

Re: [LTP] [PATCH v6 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

Hi Wei,

testcases/kernel/mem/cpuset/cpuset02.c line 3

Quoted 6 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +3 -0
@@ -0,0 +1,139 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/*
+ * Copyright (c) 2009 FUJITSU LIMITED  Miao Xie <[email protected]>

nit: You created a completely new test, just based on test6 from shell test. I suggest instead of adding this copyright to add:
Based on test6 from cpuset_memory_testset.sh.

I can change it before merge.

testcases/kernel/mem/cpuset/cpuset02.c line 10

Quoted 7 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +7 -0
+ * Copyright (c) 2023 SUSE LLC <[email protected]>
+ */
+
+/*\
+ * Test checks cpuset.mems works with hugepage file.
+ */
+

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#21 lore raw

Re: [LTP] [PATCH v6 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

In reply to Wei Gao via ltp

Hi!

Quoted 128 lines
lib/tst_cgroup.c +1 -0
index 73b696c58..545c779e7 100644
@@ -204,6 +204,7 @@ static const struct cgroup_file cpuset_ctrl_files[] = {
 	{ "cpuset.cpus", "cpuset.cpus", CTRL_CPUSET },
 	{ "cpuset.mems", "cpuset.mems", CTRL_CPUSET },
 	{ "cpuset.memory_migrate", "cpuset.memory_migrate", CTRL_CPUSET },
+	{ "cpuset.sched_load_balance", "cpuset.sched_load_balance", CTRL_CPUSET },
 	{ }
 };
 
runtest/mm +1 -0
index d8e62af81..5af29b0ea 100644
@@ -75,6 +75,7 @@ ksm06_2 ksm06 -n 8000
 ksm07 ksm07
 
 cpuset01 cpuset01
+cpuset02 cpuset02
 
 oom01 oom01
 oom02 oom02
testcases/kernel/mem/.gitignore +1 -0
index 699e022fb..e24e96001 100644
@@ -1,4 +1,5 @@
 /cpuset/cpuset01
+/cpuset/cpuset02
 /hugetlb/hugefallocate/hugefallocate01
 /hugetlb/hugefallocate/hugefallocate02
 /hugetlb/hugefork/hugefork01
testcases/kernel/mem/cpuset/Makefile +5 -0
index bac13e02b..7010c7be4 100644
@@ -19,6 +19,11 @@
 
 top_srcdir		?= ../../../..
 
+LTPLIBS = numa
+
 include $(top_srcdir)/include/mk/testcases.mk
 include $(top_srcdir)/testcases/kernel/include/lib.mk
+
+cpuset02: LTPLDLIBS = -lltpnuma
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/cpuset/cpuset02.c new file +72 -0
new file mode 100644
index 000000000..f43d8e98a
@@ -0,0 +1,139 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/*
+ * Copyright (c) 2009 FUJITSU LIMITED  Miao Xie <[email protected]>
+ * Copyright (c) 2023 SUSE LLC <[email protected]>
+ */
+
+/*\
+ * Test checks cpuset.mems works with hugepage file.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <sys/mount.h>
+#include <limits.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include "tst_test.h"
+
+#ifdef HAVE_NUMA_V2
+#include <numa.h>
+#include <numaif.h>
+#include <errno.h>
+#include "tst_numa.h"
+#include "tst_safe_stdio.h"
+#include "numa_helper.h"
+
+#define MNTPOINT "hugetlbfs/"
+#define HUGE_PAGE_FILE MNTPOINT "hugepagefile"
+#define PAGES_ALLOCATED 16u
+
+static long hpage_size;
+static struct tst_nodemap *node;
+static struct tst_cg_group *cg_cpuset_0;
+
+static void touch_memory_and_check_node(char *p, int size)
+{
+	int i;
+	int node = -1;
+	long ret;
+	int pagesize = sysconf(_SC_PAGESIZE);
+
+	for (i = 0; i < size; i += pagesize)
+		p[i] = 0xef;
+
+	ret = get_mempolicy(&node, NULL, 0, p, MPOL_F_NODE | MPOL_F_ADDR);
+	if (ret < 0)
+		tst_brk(TBROK | TERRNO, "get_mempolicy() failed");
+
+	if (node == 0)
+		tst_res(TPASS, "check node pass");
+	else
+		tst_res(TFAIL, "check node failed");
+}
+
+static void child(void)
+{
+	char *p;
+	int fd_hugepage;
+
+	TST_CHECKPOINT_WAIT(0);
+
+	fd_hugepage = SAFE_OPEN(HUGE_PAGE_FILE, O_CREAT | O_RDWR, 0755);
+	p = SAFE_MMAP(NULL, hpage_size, PROT_WRITE | PROT_READ,
+				MAP_SHARED, fd_hugepage, 0);
+
+	touch_memory_and_check_node(p, hpage_size);
+
+	SAFE_MUNMAP(p, hpage_size);
+	SAFE_CLOSE(fd_hugepage);
+
+	TST_CHECKPOINT_WAKE(1);
+}

testcases/kernel/mem/cpuset/cpuset02.c line 82

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +10 -0
+
+static void run_test(void)
+{
+	int pid;
+
+	cg_cpuset_0 = tst_cg_group_mk(tst_cg, "0");
+
+	SAFE_CG_PRINT(cg_cpuset_0, "cpuset.cpus", "0");
+	SAFE_CG_PRINT(cg_cpuset_0, "cpuset.mems", "0");
+	SAFE_CG_PRINT(cg_cpuset_0, "cpuset.sched_load_balance", "0");

Here you are locking the process to node0 but that does not necessarily means that the node0 has enough memory or CPUs. You have to choose a node from the nodemap that you got in the setup.

Also if you want to have a node with CPU, so that you can lock the process there, you need to add TST_NUMA_CPU flag to the tst_get_nodemap(). And yes, there are machines that can have node with just memory or just CPU.

However in the touch_memory_and_check_node() we just check a node the memory was allocated on. So I do not think that we need to lock the process on a particular CPU. And I do not think that we need the se the sched_load_balance either.

testcases/kernel/mem/cpuset/cpuset02.c line 84

Quoted 1 line
testcases/kernel/mem/cpuset/cpuset02.c new file +1 -0
+	SAFE_FILE_PRINTF("/proc/sys/vm/nr_hugepages", "%d", 2 * node->cnt);

What is this needed for and why is there the 2*node->cnt useful for? As far as I can tell, we allocate a single page on a given node.

testcases/kernel/mem/cpuset/cpuset02.c line 93

Quoted 8 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +8 -0
+	pid = SAFE_FORK();
+
+	if (!pid) {
+		child();
+		return;
+	}
+
+	SAFE_CG_PRINTF(cg_cpuset_0, "cgroup.procs", "%d", pid);

We can just get rid of all the checkpoints if this is done by the child process before it calls the child() function.

testcases/kernel/mem/cpuset/cpuset02.c line 98

Quoted 4 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +4 -0
+	TST_CHECKPOINT_WAKE(0);
+	TST_CHECKPOINT_WAIT(1);
+
+	SAFE_WAITPID(pid, NULL, 0);

We should not wait processes if we are not interested in their return value. Such children are collected automatically by the test library.

testcases/kernel/mem/cpuset/cpuset02.c line 105

Quoted 6 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +6 -0
+	cg_cpuset_0 = tst_cg_group_rm(cg_cpuset_0);
+}
+
+static void setup(void)
+{
+	node = tst_get_nodemap(TST_NUMA_MEM, PAGES_ALLOCATED * getpagesize() / 1024);

^
Why is this here? The child in the test allocates just a single page.

Quoted 40 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +34 -0
+	if (node->cnt <= 1)
+		tst_brk(TCONF, "test requires NUMA system");
+
+	hpage_size = SAFE_READ_MEMINFO(MEMINFO_HPAGE_SIZE)*1024;
+}
+
+static void cleanup(void)
+{
+	if (cg_cpuset_0)
+		cg_cpuset_0 = tst_cg_group_rm(cg_cpuset_0);
+}
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.runs_script = 1,
+	.mntpoint = MNTPOINT,
+	.needs_hugetlbfs = 1,
+	.setup = setup,
+	.forks_child = 1,
+	.cleanup = cleanup,
+	.test_all = run_test,
+	.hugepages = {3, TST_NEEDS},
+	.needs_checkpoints = 1,
+	.needs_cgroup_ver = TST_CG_V1,
+	.needs_cgroup_ctrls = (const char *const []){ "cpuset", NULL },
+	.save_restore = (const struct tst_path_val[]) {
+		{"/proc/sys/vm/nr_hugepages", NULL, TST_SR_TBROK},
+		{}
+	},
+};
+
+#else
+TST_TEST_TCONF(NUMA_ERROR_MSG);
+#endif
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#22 lore raw

Re: [LTP] [PATCH v6 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

Quoted 149 lines

Hi!

Quoted 128 lines
lib/tst_cgroup.c +1 -0
index 73b696c58..545c779e7 100644
@@ -204,6 +204,7 @@ static const struct cgroup_file cpuset_ctrl_files[] = {
 	{ "cpuset.cpus", "cpuset.cpus", CTRL_CPUSET },
 	{ "cpuset.mems", "cpuset.mems", CTRL_CPUSET },
 	{ "cpuset.memory_migrate", "cpuset.memory_migrate", CTRL_CPUSET },
+	{ "cpuset.sched_load_balance", "cpuset.sched_load_balance", CTRL_CPUSET },
 	{ }
 };
 
runtest/mm +1 -0
index d8e62af81..5af29b0ea 100644
@@ -75,6 +75,7 @@ ksm06_2 ksm06 -n 8000
 ksm07 ksm07
 
 cpuset01 cpuset01
+cpuset02 cpuset02
 
 oom01 oom01
 oom02 oom02
testcases/kernel/mem/.gitignore +1 -0
index 699e022fb..e24e96001 100644
@@ -1,4 +1,5 @@
 /cpuset/cpuset01
+/cpuset/cpuset02
 /hugetlb/hugefallocate/hugefallocate01
 /hugetlb/hugefallocate/hugefallocate02
 /hugetlb/hugefork/hugefork01
testcases/kernel/mem/cpuset/Makefile +5 -0
index bac13e02b..7010c7be4 100644
@@ -19,6 +19,11 @@
 
 top_srcdir		?= ../../../..
 
+LTPLIBS = numa
+
 include $(top_srcdir)/include/mk/testcases.mk
 include $(top_srcdir)/testcases/kernel/include/lib.mk
+
+cpuset02: LTPLDLIBS = -lltpnuma
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/cpuset/cpuset02.c new file +72 -0
new file mode 100644
index 000000000..f43d8e98a
@@ -0,0 +1,139 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/*
+ * Copyright (c) 2009 FUJITSU LIMITED  Miao Xie <[email protected]>
+ * Copyright (c) 2023 SUSE LLC <[email protected]>
+ */
+
+/*\
+ * Test checks cpuset.mems works with hugepage file.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <sys/mount.h>
+#include <limits.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include "tst_test.h"
+
+#ifdef HAVE_NUMA_V2
+#include <numa.h>
+#include <numaif.h>
+#include <errno.h>
+#include "tst_numa.h"
+#include "tst_safe_stdio.h"
+#include "numa_helper.h"
+
+#define MNTPOINT "hugetlbfs/"
+#define HUGE_PAGE_FILE MNTPOINT "hugepagefile"
+#define PAGES_ALLOCATED 16u
+
+static long hpage_size;
+static struct tst_nodemap *node;
+static struct tst_cg_group *cg_cpuset_0;
+
+static void touch_memory_and_check_node(char *p, int size)
+{
+	int i;
+	int node = -1;
+	long ret;
+	int pagesize = sysconf(_SC_PAGESIZE);
+
+	for (i = 0; i < size; i += pagesize)
+		p[i] = 0xef;
+
+	ret = get_mempolicy(&node, NULL, 0, p, MPOL_F_NODE | MPOL_F_ADDR);
+	if (ret < 0)
+		tst_brk(TBROK | TERRNO, "get_mempolicy() failed");
+
+	if (node == 0)
+		tst_res(TPASS, "check node pass");
+	else
+		tst_res(TFAIL, "check node failed");
+}
+
+static void child(void)
+{
+	char *p;
+	int fd_hugepage;
+
+	TST_CHECKPOINT_WAIT(0);
+
+	fd_hugepage = SAFE_OPEN(HUGE_PAGE_FILE, O_CREAT | O_RDWR, 0755);
+	p = SAFE_MMAP(NULL, hpage_size, PROT_WRITE | PROT_READ,
+				MAP_SHARED, fd_hugepage, 0);
+
+	touch_memory_and_check_node(p, hpage_size);
+
+	SAFE_MUNMAP(p, hpage_size);
+	SAFE_CLOSE(fd_hugepage);
+
+	TST_CHECKPOINT_WAKE(1);
+}

testcases/kernel/mem/cpuset/cpuset02.c line 82

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +10 -0
+
+static void run_test(void)
+{
+	int pid;
+
+	cg_cpuset_0 = tst_cg_group_mk(tst_cg, "0");
+
+	SAFE_CG_PRINT(cg_cpuset_0, "cpuset.cpus", "0");
+	SAFE_CG_PRINT(cg_cpuset_0, "cpuset.mems", "0");
+	SAFE_CG_PRINT(cg_cpuset_0, "cpuset.sched_load_balance", "0");

Here you are locking the process to node0 but that does not necessarily means that the node0 has enough memory or CPUs. You have to choose a node from the nodemap that you got in the setup.

Also if you want to have a node with CPU, so that you can lock the process there, you need to add TST_NUMA_CPU flag to the tst_get_nodemap(). And yes, there are machines that can have node with just memory or just CPU.

Quoted 4 lines

However in the touch_memory_and_check_node() we just check a node the memory was allocated on. So I do not think that we need to lock the process on a particular CPU. And I do not think that we need the se the sched_load_balance either.

[ commenting old version, there is v7 already ]

Thanks for catching these. For a record original shell test does not set cpuset.cpus, only cpuset.mems.

Quoted 4 lines

testcases/kernel/mem/cpuset/cpuset02.c line 84

Quoted 1 line
testcases/kernel/mem/cpuset/cpuset02.c new file +1 -0
+	SAFE_FILE_PRINTF("/proc/sys/vm/nr_hugepages", "%d", 2 * node->cnt);

What is this needed for and why is there the 2*node->cnt useful for? As far as I can tell, we allocate a single page on a given node.

For a record, shell test does:

echo $((2*$nr_mems)) > /proc/sys/vm/nr_hugepages

I don't have deep understanding of hugetlbpage and NUMA, but kernel hugetlbpage allows more huge pages in the kernel's huge page pool:
https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt

echo 20 > /proc/sys/vm/nr_hugepages

Kind regards,
Petr

Quoted 71 lines

testcases/kernel/mem/cpuset/cpuset02.c line 93

Quoted 8 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +8 -0
+	pid = SAFE_FORK();
+
+	if (!pid) {
+		child();
+		return;
+	}
+
+	SAFE_CG_PRINTF(cg_cpuset_0, "cgroup.procs", "%d", pid);

We can just get rid of all the checkpoints if this is done by the child process before it calls the child() function.

testcases/kernel/mem/cpuset/cpuset02.c line 98

Quoted 4 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +4 -0
+	TST_CHECKPOINT_WAKE(0);
+	TST_CHECKPOINT_WAIT(1);
+
+	SAFE_WAITPID(pid, NULL, 0);

We should not wait processes if we are not interested in their return value. Such children are collected automatically by the test library.

testcases/kernel/mem/cpuset/cpuset02.c line 105

Quoted 6 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +6 -0
+	cg_cpuset_0 = tst_cg_group_rm(cg_cpuset_0);
+}
+
+static void setup(void)
+{
+	node = tst_get_nodemap(TST_NUMA_MEM, PAGES_ALLOCATED * getpagesize() / 1024);

^
Why is this here? The child in the test allocates just a single page.

Quoted 40 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +34 -0
+	if (node->cnt <= 1)
+		tst_brk(TCONF, "test requires NUMA system");
+
+	hpage_size = SAFE_READ_MEMINFO(MEMINFO_HPAGE_SIZE)*1024;
+}
+
+static void cleanup(void)
+{
+	if (cg_cpuset_0)
+		cg_cpuset_0 = tst_cg_group_rm(cg_cpuset_0);
+}
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.runs_script = 1,
+	.mntpoint = MNTPOINT,
+	.needs_hugetlbfs = 1,
+	.setup = setup,
+	.forks_child = 1,
+	.cleanup = cleanup,
+	.test_all = run_test,
+	.hugepages = {3, TST_NEEDS},
+	.needs_checkpoints = 1,
+	.needs_cgroup_ver = TST_CG_V1,
+	.needs_cgroup_ctrls = (const char *const []){ "cpuset", NULL },
+	.save_restore = (const struct tst_path_val[]) {
+		{"/proc/sys/vm/nr_hugepages", NULL, TST_SR_TBROK},
+		{}
+	},
+};
+
+#else
+TST_TEST_TCONF(NUMA_ERROR_MSG);
+#endif
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#23 lore raw

PATCH v6 2/2 cpuset_memory_testset.sh: Remove test6

In reply to Wei Gao via ltp
---
 .../cpuset_memory_testset.sh                  | 37 +------------------
 1 file changed, 2 insertions(+), 35 deletions(-)
testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh +2 -35
index c1e7cea8f..fd41dc97a 100755
@@ -162,41 +162,8 @@ check_hugetlbfs()
 
 test6()
 {
-	cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
-	if [ $? -ne 0 ]; then
-		cpuset_log_error $CPUSET_TMP/stderr
-		tst_resm TFAIL "set general group parameter failed."
-		return 1
-	fi
-
-	check_hugetlbfs
-	if [ $? -eq 0 ]; then
-		tst_resm TCONF "This system don't support hugetlbfs"
-		return 0
-	fi
-
-	mkdir /hugetlb
-	mount -t hugetlbfs none /hugetlb
-
-	save_nr_hugepages=$(cat /proc/sys/vm/nr_hugepages)
-	echo $((2*$nr_mems)) > /proc/sys/vm/nr_hugepages
-
-	cpuset_memory_test --mmap-file --hugepage -s $HUGEPAGESIZE >"$MEMORY_RESULT" &
-	simple_getresult $! "$CPUSET/0"
-
-	umount /hugetlb
-	rmdir /hugetlb
-
-	echo $save_nr_hugepages > /proc/sys/vm/nr_hugepages
-	if [ $(cat /proc/sys/vm/nr_hugepages) -ne $save_nr_hugepages ]; then
-		tst_resm TFAIL "can't restore nr_hugepages(nr_hugepages = $save_nr_hugepages)."
-		return 1
-	fi
-
-	if [ "$node" != "0" ]; then
-		tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)."
-		return 1
-	fi
+	tst_resm TINFO "This test is replaced by testcases/kernel/mem/cpuset/cpuset02.c"
+	return 0
 }
 
 test7()
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v6 2/2
#24 lore raw

Re: [LTP] [PATCH v6 2/2] cpuset_memory_testset.sh: Remove test6

Hi Wei,

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#25 lore raw

v7 cover cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

In reply to Wei Gao via ltp

Wei Gao (2):
cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code cpuset_memory_testset.sh: Remove test6

 lib/tst_cgroup.c                              |   1 +
 runtest/mm                                    |   1 +
 .../cpuset_memory_testset.sh                  |  37 +----
 testcases/kernel/mem/.gitignore               |   1 +
 testcases/kernel/mem/cpuset/Makefile          |   5 +
 testcases/kernel/mem/cpuset/cpuset02.c        | 132 ++++++++++++++++++
 6 files changed, 142 insertions(+), 35 deletions(-)
 create mode 100644 testcases/kernel/mem/cpuset/cpuset02.c
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#26 lore raw

PATCH v7 1/2 cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

---
 lib/tst_cgroup.c                       |   1 +
 runtest/mm                             |   1 +
 testcases/kernel/mem/.gitignore        |   1 +
 testcases/kernel/mem/cpuset/Makefile   |   5 +
 testcases/kernel/mem/cpuset/cpuset02.c | 132 +++++++++++++++++++++++++
 5 files changed, 140 insertions(+)
 create mode 100644 testcases/kernel/mem/cpuset/cpuset02.c
lib/tst_cgroup.c +1 -0
index 73b696c58..545c779e7 100644
@@ -204,6 +204,7 @@ static const struct cgroup_file cpuset_ctrl_files[] = {
 	{ "cpuset.cpus", "cpuset.cpus", CTRL_CPUSET },
 	{ "cpuset.mems", "cpuset.mems", CTRL_CPUSET },
 	{ "cpuset.memory_migrate", "cpuset.memory_migrate", CTRL_CPUSET },
+	{ "cpuset.sched_load_balance", "cpuset.sched_load_balance", CTRL_CPUSET },
 	{ }
 };
 
runtest/mm +1 -0
index d8e62af81..5af29b0ea 100644
@@ -75,6 +75,7 @@ ksm06_2 ksm06 -n 8000
 ksm07 ksm07
 
 cpuset01 cpuset01
+cpuset02 cpuset02
 
 oom01 oom01
 oom02 oom02
testcases/kernel/mem/.gitignore +1 -0
index 699e022fb..e24e96001 100644
@@ -1,4 +1,5 @@
 /cpuset/cpuset01
+/cpuset/cpuset02
 /hugetlb/hugefallocate/hugefallocate01
 /hugetlb/hugefallocate/hugefallocate02
 /hugetlb/hugefork/hugefork01
testcases/kernel/mem/cpuset/Makefile +5 -0
index bac13e02b..7010c7be4 100644
@@ -19,6 +19,11 @@
 
 top_srcdir		?= ../../../..
 
+LTPLIBS = numa
+
 include $(top_srcdir)/include/mk/testcases.mk
 include $(top_srcdir)/testcases/kernel/include/lib.mk
+
+cpuset02: LTPLDLIBS = -lltpnuma
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/cpuset/cpuset02.c new file +132 -0

132 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#27 lore raw

Re: [LTP] [PATCH v7 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

Hi Wei,

...

testcases/kernel/mem/cpuset/cpuset02.c line 8

Quoted 10 lines

+++ b/testcases/kernel/mem/cpuset/cpuset02.c

testcases/kernel/mem/cpuset/cpuset02.c new file +8 -0
@@ -0,0 +1,132 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/*
+ * Copyright (c) 2025 SUSE LLC <[email protected]>
+ */
+
+/*\
+ * Test checks cpuset.mems works with hugepage file.
+ * Based on test6 from cpuset_memory_testset.sh.

very nit: I would add the author name:

* Based on test6 from cpuset_memory_testset.sh written by Miao Xie.

(We don't need to keep the copyright, but because we likely sooner or later delete cpuset_memory_testset.sh it's nice to give the original author his credit for his original idea.)

testcases/kernel/mem/cpuset/cpuset02.c line 20

Quoted 12 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +12 -0
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <sys/mount.h>
+#include <limits.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include "tst_test.h"
+
+#ifdef HAVE_NUMA_V2
+#include <numa.h>

<numa.h> is not needed, please delete it.

testcases/kernel/mem/cpuset/cpuset02.c line 22

Quoted 2 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +2 -0
+#include <numaif.h>
+#include <errno.h>

<errno.h> is not needed either, please delete it.

testcases/kernel/mem/cpuset/cpuset02.c line 24

Quoted 2 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +2 -0
+#include "tst_numa.h"
+#include "tst_safe_stdio.h"

tst_safe_stdio.h is not needed either, please delete it.

testcases/kernel/mem/cpuset/cpuset02.c line 25

Quoted 1 line
testcases/kernel/mem/cpuset/cpuset02.c new file +1 -0
+#include "numa_helper.h"

numa_helper.h is not needed either, please delete it.

...

testcases/kernel/mem/cpuset/cpuset02.c line 79

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +10 -0
+static void run_test(void)
+{
+	int pid;
+	char node_id_str[256];
+
+	cg_cpuset_0 = tst_cg_group_mk(tst_cg, "0");
+
+	sprintf(node_id_str, "%u", check_node_id);
+	SAFE_CG_PRINT(cg_cpuset_0, "cpuset.mems", node_id_str);
+	SAFE_FILE_PRINTF("/proc/sys/vm/nr_hugepages", "%d", 1);

You changed the /proc/sys/vm/nr_hugepages to 1, because Cyril objected the code in v6:

SAFE_FILE_PRINTF("/proc/sys/vm/nr_hugepages", "%d", 2 * node->cnt);

But as I note there [1], the original shell test did it this way and kernel docs allows more than 1 to allocate. I'm obviously missing something.

[1] https://lore.kernel.org/ltp/20250325133611.GB372417@pevik/

Quoted 9 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +9 -0
+
+	pid = SAFE_FORK();
+
+	if (!pid) {
+		SAFE_CG_PRINTF(cg_cpuset_0, "cgroup.procs", "%d", pid);
+		child();
+		return;
+	}
+

testcases/kernel/mem/cpuset/cpuset02.c line 98

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +10 -0
+	SAFE_WAITPID(pid, NULL, 0);
+
+	cg_cpuset_0 = tst_cg_group_rm(cg_cpuset_0);
+}
+
+static void setup(void)
+{
+	node = tst_get_nodemap(TST_NUMA_MEM, getpagesize() / 1024);
+	if (node->cnt <= 1)
+		tst_brk(TCONF, "test requires NUMA system");

This fails on system with single NUMA memory node. Either it should be compared as:

	if (node->cnt < 1)

or you're checking for 2 NUMA memory nodes (IMHO you want just single ATM.

Also maybe worth to change to "test requires at least one NUMA memory node" as other tests do, you do have check for NUMA itsef anyway in TST_TEST_TCONF(NUMA_ERROR_MSG).

Quoted 17 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +17 -0
+
+	check_node_id = node->map[0];
+
+	hpage_size = SAFE_READ_MEMINFO(MEMINFO_HPAGE_SIZE)*1024;
+}
+
+static void cleanup(void)
+{
+	if (cg_cpuset_0)
+		cg_cpuset_0 = tst_cg_group_rm(cg_cpuset_0);
+}
+
+static struct tst_test test = {
+	.needs_root = 1,
+	.runs_script = 1,
+	.mntpoint = MNTPOINT,
+	.needs_hugetlbfs = 1,

testcases/kernel/mem/cpuset/cpuset02.c line 125

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +10 -0
+	.setup = setup,
+	.forks_child = 1,
+	.cleanup = cleanup,
+	.test_all = run_test,
+	.hugepages = {3, TST_NEEDS},
+	.needs_checkpoints = 1,
+	.needs_cgroup_ver = TST_CG_V1,
+	.needs_cgroup_ctrls = (const char *const []){ "cpuset", NULL },
+	.save_restore = (const struct tst_path_val[]) {
+		{"/proc/sys/vm/nr_hugepages", NULL, TST_SR_TBROK},

Shouldn't here be rather TST_SR_TCONF?

Thanks for the changelog, the rest of the changes LGTM.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#28 lore raw

Re: [LTP] [PATCH v7 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

Quoted 17 lines · Petr Vorel

Hi Wei,

...

testcases/kernel/mem/cpuset/cpuset02.c line 79

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +10 -0
+static void run_test(void)
+{
+	int pid;
+	char node_id_str[256];
+
+	cg_cpuset_0 = tst_cg_group_mk(tst_cg, "0");
+
+	sprintf(node_id_str, "%u", check_node_id);
+	SAFE_CG_PRINT(cg_cpuset_0, "cpuset.mems", node_id_str);
+	SAFE_FILE_PRINTF("/proc/sys/vm/nr_hugepages", "%d", 1);

You changed the /proc/sys/vm/nr_hugepages to 1, because Cyril objected the code in v6:

Quoted 7 lines

SAFE_FILE_PRINTF("/proc/sys/vm/nr_hugepages", "%d", 2 * node->cnt);

But as I note there [1], the original shell test did it this way and kernel docs allows more than 1 to allocate. I'm obviously missing something.

[1] https://lore.kernel.org/ltp/20250325133611.GB372417@pevik/

My understanding from Cyril's comments is no need reserve more hugepages, since this test case ONLY allocate 1 page through mmap.
@Cyril could you help confirm this?

Quoted 3 lines

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#29 lore raw

Re: [LTP] [PATCH v7 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

Quoted 22 lines · Wei Gao via ltp
Quoted 15 lines · Petr Vorel

Hi Wei,

...

testcases/kernel/mem/cpuset/cpuset02.c line 79

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +10 -0
+static void run_test(void)
+{
+   int pid;
+   char node_id_str[256];
+
+   cg_cpuset_0 = tst_cg_group_mk(tst_cg, "0");
+
+   sprintf(node_id_str, "%u", check_node_id);
+   SAFE_CG_PRINT(cg_cpuset_0, "cpuset.mems", node_id_str);
+   SAFE_FILE_PRINTF("/proc/sys/vm/nr_hugepages", "%d", 1);

You changed the /proc/sys/vm/nr_hugepages to 1, because Cyril objected

the code

Quoted 5 lines

in v6:

SAFE_FILE_PRINTF("/proc/sys/vm/nr_hugepages", "%d", 2 * node->cnt);

But as I note there [1], the original shell test did it this way and

Quoted 8 lines

kernel docs

Quoted 4 lines

allows more than 1 to allocate. I'm obviously missing something.

[1] https://lore.kernel.org/ltp/20250325133611.GB372417@pevik/

My understanding from Cyril's comments is no need reserve more hugepages, since
this test case ONLY allocate 1 page through mmap.

It depends on what you wanted there, if only 1 general huge page,
echo 1 > /proc/sys/vm/nr_hugepages will try to reserve 1
from a NUMA node randomly.

But if you prefer to get 1 hugepage from a specified node, we need:
`echo 1 >
/sys/devices/system/node/node%u/hugepages/hugepages-%dkB/nr_hugepages`

However, both ways won't guarantee the reservation will be 100% successful, which is based on the memory fragmentation situations.

To be on the safe side, I would suggest using LTP unified API to reserve:
https://github.com/linux-test-project/ltp/blob/master/doc/old/C-Test-API.asciidoc#134-reserving-hugepages

You could reference usage from:
mem/hugetlb/hugemmap/hugemmap16.c,
syscalls/move_pages/move_pages12.c

Quoted 11 lines

@Cyril could you help confirm this?

Quoted 3 lines

Kind regards,
Petr

--
Mailing list info: https://lists.linux.it/listinfo/ltp

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#30 lore raw

Re: [LTP] [PATCH v7 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

Hi Wei,

Quoted 48 lines · Li Wang
Quoted 22 lines · Wei Gao via ltp
Quoted 15 lines · Petr Vorel

Hi Wei,

...

testcases/kernel/mem/cpuset/cpuset02.c line 79

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +10 -0
+static void run_test(void)
+{
+   int pid;
+   char node_id_str[256];
+
+   cg_cpuset_0 = tst_cg_group_mk(tst_cg, "0");
+
+   sprintf(node_id_str, "%u", check_node_id);
+   SAFE_CG_PRINT(cg_cpuset_0, "cpuset.mems", node_id_str);
+   SAFE_FILE_PRINTF("/proc/sys/vm/nr_hugepages", "%d", 1);

You changed the /proc/sys/vm/nr_hugepages to 1, because Cyril objected

the code

Quoted 5 lines

in v6:

SAFE_FILE_PRINTF("/proc/sys/vm/nr_hugepages", "%d", 2 * node->cnt);

But as I note there [1], the original shell test did it this way and

Quoted 8 lines

kernel docs

Quoted 4 lines

allows more than 1 to allocate. I'm obviously missing something.

[1] https://lore.kernel.org/ltp/20250325133611.GB372417@pevik/

My understanding from Cyril's comments is no need reserve more hugepages, since
this test case ONLY allocate 1 page through mmap.

It depends on what you wanted there, if only 1 general huge page,
echo 1 > /proc/sys/vm/nr_hugepages will try to reserve 1
from a NUMA node randomly.

But if you prefer to get 1 hugepage from a specified node, we need:
`echo 1 >
/sys/devices/system/node/node%u/hugepages/hugepages-%dkB/nr_hugepages`

However, both ways won't guarantee the reservation will be 100% successful, which is based on the memory fragmentation situations.

Quoted 8 lines

To be on the safe side, I would suggest using LTP unified API to reserve:

https://github.com/linux-test-project/ltp/blob/master/doc/old/C-Test-API.asciidoc#134-reserving-hugepages

You could reference usage from:
mem/hugetlb/hugemmap/hugemmap16.c,
syscalls/move_pages/move_pages12.c

I looked through all the code and got your requirements here. The original test6 is echoing '2*$nr_mems' to the whole system to make each node reserve some pages, then doing hugetlbfsfile mapping to verify that the real allocated PAGE was happening on the Cgroup set node.

(But the defect is that '2*$nr_mems' probably does not distribute to each node ideally.
we should resolve this in the new test)

And that could be easy to convert into your C cpuset02 test, just echo at least 1 nr_hugepages in each NUMA node, and binding the child allocating process to the expected CGroup set, then verify that only 1 hupage is really allocated in the correct node.

To show the idea on a two-node system is:

1. Reserve at least 1 hpage on each node and check the value is correct. echo 1 >
/sys/devices/system/node/node0/hugepages/hugepages-%dkB/nr_hugepages
echo 1 >
/sys/devices/system/node/node1/hugepages/hugepages-%dkB/nr_hugepages

2. After folking, bind the child to the cgroup.procs.

3. Do mmap in the child with hugetlbfs file mapping (for allocating the 1 huage page).

4. Touch the memory and verify that only 1 huge page is allocated in the expected node.

Quoted 19 lines
Quoted 4 lines
Quoted 10 lines

@Cyril could you help confirm this?

Quoted 3 lines

Kind regards,
Petr

--
Mailing list info: https://lists.linux.it/listinfo/ltp

--
Regards,
Li Wang

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#31 lore raw

Re: [LTP] [PATCH v7 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

In reply to Li Wang via ltp
Quoted 29 lines · Li Wang
Quoted 27 lines · Wei Gao via ltp
Quoted 15 lines · Petr Vorel

Hi Wei,

...

testcases/kernel/mem/cpuset/cpuset02.c line 79

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +10 -0
+static void run_test(void)
+{
+   int pid;
+   char node_id_str[256];
+
+   cg_cpuset_0 = tst_cg_group_mk(tst_cg, "0");
+
+   sprintf(node_id_str, "%u", check_node_id);
+   SAFE_CG_PRINT(cg_cpuset_0, "cpuset.mems", node_id_str);
+   SAFE_FILE_PRINTF("/proc/sys/vm/nr_hugepages", "%d", 1);

You changed the /proc/sys/vm/nr_hugepages to 1, because Cyril objected

the code

Quoted 5 lines

in v6:

SAFE_FILE_PRINTF("/proc/sys/vm/nr_hugepages", "%d", 2 * node->cnt);

But as I note there [1], the original shell test did it this way and

kernel docs

Quoted 4 lines

allows more than 1 to allocate. I'm obviously missing something.

[1] https://lore.kernel.org/ltp/20250325133611.GB372417@pevik/

Quoted 8 lines
Quoted 3 lines

My understanding from Cyril's comments is no need reserve more hugepages, since
this test case ONLY allocate 1 page through mmap.

It depends on what you wanted there, if only 1 general huge page,
echo 1 > /proc/sys/vm/nr_hugepages will try to reserve 1
from a NUMA node randomly.

Thanks for your valuable information, now i guess i find out why original code using 2 * node->cnt instead of 1, it try to make sure every node have at least reserve some pages.

Quoted 8 lines

But if you prefer to get 1 hugepage from a specified node, we need:
`echo 1 >
/sys/devices/system/node/node%u/hugepages/hugepages-%dkB/nr_hugepages`

However, both ways won't guarantee the reservation will be 100% successful, which is based on the memory fragmentation situations.

Quoted 6 lines

To be on the safe side, I would suggest using LTP unified API to reserve:
https://github.com/linux-test-project/ltp/blob/master/doc/old/C-Test-API.asciidoc#134-reserving-hugepages

You could reference usage from:
mem/hugetlb/hugemmap/hugemmap16.c,
syscalls/move_pages/move_pages12.c

This case is check allocate memory on specific node, so if we set .hugepages = {1, TST_NEEDS}, then 1 page will reserve on NUMA node randomly, that means case still has chance to fail. Also i guess current .hugepages can not support ".hugepages = {2 * node->cnt, TST_NEEDS}" So the easy way is keep v6 implementation like following:
SAFE_FILE_PRINTF("/proc/sys/vm/nr_hugepages", "%d", 2 * node->cnt);

Correct me if any misunderstanding.

Quoted 18 lines
Quoted 14 lines

@Cyril could you help confirm this?

Quoted 3 lines

Kind regards,
Petr

--
Mailing list info: https://lists.linux.it/listinfo/ltp

Signature · 2 lines
Regards,
Li Wang
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#32 lore raw

Re: [LTP] [PATCH v7 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

Quoted 26 lines · Wei Gao
Quoted 4 lines

It depends on what you wanted there, if only 1 general huge page,
echo 1 > /proc/sys/vm/nr_hugepages will try to reserve 1
from a NUMA node randomly.

Thanks for your valuable information, now i guess i find out why original code using 2 * node->cnt instead of 1, it try to make sure every node have at least reserve some pages.

Quoted 6 lines

But if you prefer to get 1 hugepage from a specified node, we need:
`echo 1 >
/sys/devices/system/node/node%u/hugepages/hugepages-%dkB/nr_hugepages`

However, both ways won't guarantee the reservation will be 100%

successful,

Quoted 4 lines

which is based on the memory fragmentation situations.

To be on the safe side, I would suggest using LTP unified API to reserve:

https://github.com/linux-test-project/ltp/blob/master/doc/old/C-Test-API.asciidoc#134-reserving-hugepages

Quoted 4 lines

You could reference usage from:
mem/hugetlb/hugemmap/hugemmap16.c,
syscalls/move_pages/move_pages12.c

Quoted 5 lines

This case is check allocate memory on specific node, so if we set .hugepages = {1, TST_NEEDS},
then 1 page will reserve on NUMA node randomly, that means case still has chance to fail.

Right.

Quoted 7 lines

Also i guess current .hugepages can not support ".hugepages = {2 * node->cnt, TST_NEEDS}"
So the easy way is keep v6 implementation like following:
SAFE_FILE_PRINTF("/proc/sys/vm/nr_hugepages", "%d", 2 * node->cnt);

Correct me if any misunderstanding.

In this case .hugepage may not fit your requirements.

We could directly keep 1 hpage reserved in each node (in setup phase) for the coming allocation.

echo 1 > .../node0/hugepages/hugepages-%dkB/nr_hugepages echo 1 > .../node1/hugepages/hugepages-%dkB/nr_hugepages echo 1 > .../nodeX/hugepages/hugepages-%dkB/nr_hugepages

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#33 lore raw

Re: [LTP] [PATCH v7 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

In reply to Petr Vorel
Quoted 13 lines · Petr Vorel
Quoted 9 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +9 -0
+static struct tst_test test = {
+     .needs_root = 1,
+     .runs_script = 1,
+     .mntpoint = MNTPOINT,
+     .needs_hugetlbfs = 1,
+     .setup = setup,
+     .forks_child = 1,
+     .cleanup = cleanup,
+     .test_all = run_test,
Quoted 2 lines
Quoted 1 line

+ .hugepages = {3, TST_NEEDS},

This line is equal to echo 3 > /proc/sys/vm/nr_hugepages and check the 3 is there.

Quoted 6 lines

testcases/kernel/mem/cpuset/cpuset02.c line 125

Quoted 5 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +5 -0
+     .needs_checkpoints = 1,
+     .needs_cgroup_ver = TST_CG_V1,
+     .needs_cgroup_ctrls = (const char *const []){ "cpuset", NULL },
+     .save_restore = (const struct tst_path_val[]) {
+             {"/proc/sys/vm/nr_hugepages", NULL, TST_SR_TBROK},

If we set .hugepages then this line is redundant, because ltp-lib already saved/restored that nr_hugepages for test.

See line#68 in /lib/tst_hugepage.c

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#34 lore raw

PATCH v7 2/2 cpuset_memory_testset.sh: Remove test6

In reply to Wei Gao via ltp
---
 .../cpuset_memory_testset.sh                  | 37 +------------------
 1 file changed, 2 insertions(+), 35 deletions(-)
testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh +2 -35
index c1e7cea8f..fd41dc97a 100755
@@ -162,41 +162,8 @@ check_hugetlbfs()
 
 test6()
 {
-	cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
-	if [ $? -ne 0 ]; then
-		cpuset_log_error $CPUSET_TMP/stderr
-		tst_resm TFAIL "set general group parameter failed."
-		return 1
-	fi
-
-	check_hugetlbfs
-	if [ $? -eq 0 ]; then
-		tst_resm TCONF "This system don't support hugetlbfs"
-		return 0
-	fi
-
-	mkdir /hugetlb
-	mount -t hugetlbfs none /hugetlb
-
-	save_nr_hugepages=$(cat /proc/sys/vm/nr_hugepages)
-	echo $((2*$nr_mems)) > /proc/sys/vm/nr_hugepages
-
-	cpuset_memory_test --mmap-file --hugepage -s $HUGEPAGESIZE >"$MEMORY_RESULT" &
-	simple_getresult $! "$CPUSET/0"
-
-	umount /hugetlb
-	rmdir /hugetlb
-
-	echo $save_nr_hugepages > /proc/sys/vm/nr_hugepages
-	if [ $(cat /proc/sys/vm/nr_hugepages) -ne $save_nr_hugepages ]; then
-		tst_resm TFAIL "can't restore nr_hugepages(nr_hugepages = $save_nr_hugepages)."
-		return 1
-	fi
-
-	if [ "$node" != "0" ]; then
-		tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)."
-		return 1
-	fi
+	tst_resm TINFO "This test is replaced by testcases/kernel/mem/cpuset/cpuset02.c"
+	return 0
 }
 
 test7()
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#35 lore raw

Re: [LTP] [PATCH v7 2/2] cpuset_memory_testset.sh: Remove test6

Hi Wei,

it's helpful in the commit message to write *the reason* why doing change. There should be a note that C test in the previous commit implemented the test.

Also generally it helps a review process if you add a changelog what changed in the previous version.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#36 lore raw

Re: [LTP] [PATCH v7 2/2] cpuset_memory_testset.sh: Remove test6

Quoted 5 lines · Petr Vorel

Hi Wei,

it's helpful in the commit message to write *the reason* why doing change. There should be a note that C test in the previous commit implemented the test.

Got it, the previous commit change mainly base Cyril v6's feedback.

Quoted 2 lines

Also generally it helps a review process if you add a changelog what changed in the previous version.

Thanks for point this out.

v6: https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/
Changes v6-v7:
* choose a node from the nodemap which get from setup instead of using hardcode node0
* remove unnecessary steps such as locking process into specific node and sched_load_balance
* update allocate memory size to single page
* remove unnecessary checkpoints

Quoted 3 lines

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#37 lore raw

Re: [LTP] [PATCH v7 2/2] cpuset_memory_testset.sh: Remove test6

Hi Petr

Got it, currently the reason for previous commit change is v6's comments from Cyril.

v6:
https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/
Changes v6-v7:
* select node from nodemap which got in setup()
* remove unnecessary step such as locking process to node0 and schedu_load_balance setting
* change allocate memory to single page
* remove checkpoint

Thanks.
Regards
Gao Wei

Quoted 29 lines · Wei Gao
Quoted 3 lines · Petr Vorel

Hi Wei,

it's helpful in the commit message to write *the reason* why doing

change.

Quoted 1 line

There should be a note that C test in the previous commit implemented

the test.

Quoted 1 line

Got it, the previous commit change mainly base Cyril v6's feedback.

Quoted 1 line

Also generally it helps a review process if you add a changelog what

changed in

Quoted 1 line

the previous version.

Thanks for point this out.

v6:
https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/
Changes v6-v7:
* choose a node from the nodemap which get from setup instead of using hardcode node0
* remove unnecessary steps such as locking process into specific node and sched_load_balance
* update allocate memory size to single page
* remove unnecessary checkpoints

Quoted 3 lines

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#38 lore raw

v8 cover cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

In reply to Wei Gao via ltp

Changes v7-v8:
* Update Petr's comments on v7
* Reserve at least 1 page on each node base Li Wang's suggestion
* Change check_node_id from node->map[0] to node->map[node->cnt - 1]

link to v7:
https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/

Wei Gao (2):
cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code cpuset_memory_testset.sh: Remove test6

 lib/tst_cgroup.c                              |   1 +
 runtest/mm                                    |   1 +
 .../cpuset_memory_testset.sh                  |  37 +----
 testcases/kernel/mem/.gitignore               |   1 +
 testcases/kernel/mem/cpuset/Makefile          |   5 +
 testcases/kernel/mem/cpuset/cpuset02.c        | 138 ++++++++++++++++++
 6 files changed, 148 insertions(+), 35 deletions(-)
 create mode 100644 testcases/kernel/mem/cpuset/cpuset02.c
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#39 lore raw

PATCH v8 1/2 cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

---
 lib/tst_cgroup.c                       |   1 +
 runtest/mm                             |   1 +
 testcases/kernel/mem/.gitignore        |   1 +
 testcases/kernel/mem/cpuset/Makefile   |   5 +
 testcases/kernel/mem/cpuset/cpuset02.c | 138 +++++++++++++++++++++++++
 5 files changed, 146 insertions(+)
 create mode 100644 testcases/kernel/mem/cpuset/cpuset02.c
lib/tst_cgroup.c +1 -0
index 73b696c58..545c779e7 100644
@@ -204,6 +204,7 @@ static const struct cgroup_file cpuset_ctrl_files[] = {
 	{ "cpuset.cpus", "cpuset.cpus", CTRL_CPUSET },
 	{ "cpuset.mems", "cpuset.mems", CTRL_CPUSET },
 	{ "cpuset.memory_migrate", "cpuset.memory_migrate", CTRL_CPUSET },
+	{ "cpuset.sched_load_balance", "cpuset.sched_load_balance", CTRL_CPUSET },
 	{ }
 };
 
runtest/mm +1 -0
index d8e62af81..5af29b0ea 100644
@@ -75,6 +75,7 @@ ksm06_2 ksm06 -n 8000
 ksm07 ksm07
 
 cpuset01 cpuset01
+cpuset02 cpuset02
 
 oom01 oom01
 oom02 oom02
testcases/kernel/mem/.gitignore +1 -0
index 699e022fb..e24e96001 100644
@@ -1,4 +1,5 @@
 /cpuset/cpuset01
+/cpuset/cpuset02
 /hugetlb/hugefallocate/hugefallocate01
 /hugetlb/hugefallocate/hugefallocate02
 /hugetlb/hugefork/hugefork01
testcases/kernel/mem/cpuset/Makefile +5 -0
index bac13e02b..7010c7be4 100644
@@ -19,6 +19,11 @@
 
 top_srcdir		?= ../../../..
 
+LTPLIBS = numa
+
 include $(top_srcdir)/include/mk/testcases.mk
 include $(top_srcdir)/testcases/kernel/include/lib.mk
+
+cpuset02: LTPLDLIBS = -lltpnuma
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/cpuset/cpuset02.c new file +138 -0

138 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#40 lore raw

Re: [LTP] [PATCH v8 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

Hi Wei,

Geneally looks good, but some tiny places need improvement. See comments inline.

Quoted 17 lines · Wei Gao
---
 lib/tst_cgroup.c                       |   1 +
 runtest/mm                             |   1 +
 testcases/kernel/mem/.gitignore        |   1 +
 testcases/kernel/mem/cpuset/Makefile   |   5 +
 testcases/kernel/mem/cpuset/cpuset02.c | 138 +++++++++++++++++++++++++
 5 files changed, 146 insertions(+)
 create mode 100644 testcases/kernel/mem/cpuset/cpuset02.c
lib/tst_cgroup.c +0 -0
index 73b696c58..545c779e7 100644

lib/tst_cgroup.c static const struct cgroup_file cpuset_ctrl_files[] = { · line 209

Quoted 6 lines
lib/tst_cgroup.c +1 -0
@@ -204,6 +204,7 @@ static const struct cgroup_file cpuset_ctrl_files[] = {
        { "cpuset.cpus", "cpuset.cpus", CTRL_CPUSET },
        { "cpuset.mems", "cpuset.mems", CTRL_CPUSET },
        { "cpuset.memory_migrate", "cpuset.memory_migrate", CTRL_CPUSET },
+       { "cpuset.sched_load_balance", "cpuset.sched_load_balance",
 CTRL_CPUSET },
 

cpuset.sched_load_balance is useful to enable/disable the scheduler can move tasks between CPUs in the cpuset.

Is there any purpose to add this knob in cpuset02 patch? I didn't see you touch it in the test.

        { }
Quoted 86 lines
lib/tst_cgroup.c +0 -0
 };
runtest/mm +1 -0
index d8e62af81..5af29b0ea 100644
@@ -75,6 +75,7 @@ ksm06_2 ksm06 -n 8000
 ksm07 ksm07
 
 cpuset01 cpuset01
+cpuset02 cpuset02
 
 oom01 oom01
 oom02 oom02
testcases/kernel/mem/.gitignore +1 -0
index 699e022fb..e24e96001 100644
@@ -1,4 +1,5 @@
 /cpuset/cpuset01
+/cpuset/cpuset02
 /hugetlb/hugefallocate/hugefallocate01
 /hugetlb/hugefallocate/hugefallocate02
 /hugetlb/hugefork/hugefork01
testcases/kernel/mem/cpuset/Makefile +5 -0
index bac13e02b..7010c7be4 100644
@@ -19,6 +19,11 @@
 
 top_srcdir             ?= ../../../..
 
+LTPLIBS = numa
+
 include $(top_srcdir)/include/mk/testcases.mk
 include $(top_srcdir)/testcases/kernel/include/lib.mk
+
+cpuset02: LTPLDLIBS = -lltpnuma
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/cpuset/cpuset02.c new file +36 -0
new file mode 100644
index 000000000..26b77f8be
@@ -0,0 +1,138 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/*
+ * Copyright (c) 2025 SUSE LLC <[email protected]>
+ */
+
+/*\
+ * Test checks cpuset.mems works with hugepage file.
+ * Based on test6 from cpuset_memory_testset.sh written by Miao Xie.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <sys/mount.h>
+#include <limits.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include "tst_test.h"
+
+#ifdef HAVE_NUMA_V2
+#include <numaif.h>
+#include "tst_numa.h"
+
+#define MNTPOINT "hugetlbfs/"
+#define HUGE_PAGE_FILE MNTPOINT "hugepagefile"
+
+static long hpage_size;
+static struct tst_nodemap *node;
+static int check_node_id;
+static struct tst_cg_group *cg_cpuset_0;
+
+static void touch_memory_and_check_node(char *p, int size)
+{
+       int i;
+       int node = -1;
+       long ret;
+       int pagesize = sysconf(_SC_PAGESIZE);

testcases/kernel/mem/cpuset/cpuset02.c line 46

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +10 -0
+
+       for (i = 0; i < size; i += pagesize)
+               p[i] = 0xef;
+
+       ret = get_mempolicy(&node, NULL, 0, p, MPOL_F_NODE | MPOL_F_ADDR);
+       if (ret < 0)
+               tst_brk(TBROK | TERRNO, "get_mempolicy() failed");
+
+       if (node == check_node_id)
+               tst_res(TPASS, "check node pass");

I suggest printing the node for detailed info.

    tst_res(TPASS, "1 huge page allocated on node-%d as expected", node);

testcases/kernel/mem/cpuset/cpuset02.c line 48

Quoted 3 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +2 -0
+       else
+               tst_res(TFAIL, "check node failed");
    tst_res(TFAIL, "1 huge page allocated on node-%d unexpected", node);
Quoted 53 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +45 -0
+}
+
+static void child(void)
+{
+       char *p;
+       int fd_hugepage;
+
+       fd_hugepage = SAFE_OPEN(HUGE_PAGE_FILE, O_CREAT | O_RDWR, 0755);
+       p = SAFE_MMAP(NULL, hpage_size, PROT_WRITE | PROT_READ,
+                               MAP_SHARED, fd_hugepage, 0);
+
+       touch_memory_and_check_node(p, hpage_size);
+
+       SAFE_MUNMAP(p, hpage_size);
+       SAFE_CLOSE(fd_hugepage);
+}
+
+static void run_test(void)
+{
+       int pid;
+       char node_id_str[256];
+
+       cg_cpuset_0 = tst_cg_group_mk(tst_cg, "0");
+
+       sprintf(node_id_str, "%u", check_node_id);
+       SAFE_CG_PRINT(cg_cpuset_0, "cpuset.mems", node_id_str);
+
+       pid = SAFE_FORK();
+
+       if (!pid) {
+               SAFE_CG_PRINTF(cg_cpuset_0, "cgroup.procs", "%d", pid);
+               child();
+               return;
+       }
+
+       SAFE_WAITPID(pid, NULL, 0);
+
+       cg_cpuset_0 = tst_cg_group_rm(cg_cpuset_0);
+}
+
+static void setup(void)
+{
+       node = tst_get_nodemap(TST_NUMA_MEM, getpagesize() / 1024);
+       if (node->cnt <= 1)
+               tst_brk(TCONF, "test requires at least 2 NUMA memory

nodes");

testcases/kernel/mem/cpuset/cpuset02.c new file +6 -0
+
+       check_node_id = node->map[node->cnt - 1];
+
+       hpage_size = SAFE_READ_MEMINFO(MEMINFO_HPAGE_SIZE)*1024;
+
+       char path[256];

testcases/kernel/mem/cpuset/cpuset02.c

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +9 -0
+       unsigned int i;
+
+       for (i = 0; i < node->cnt; i++) {
+               unsigned int current_node_id = node->map[i];
+
+               sprintf(path,
+
 "/sys/devices/system/node/node%d/hugepages/hugepages-%ldkB/nr_hugepages",
+                       current_node_id, hpage_size / 1024);
+               SAFE_FILE_PRINTF(path, "%d", 1);

SAFE_ macro will break if fails to set the value. However, the reservation may not
succeed here due to memory fragmentation. So we can just use FILE_PRINTF().

Then, we need an additional check for the target node, if unable to reserve, then TCONF there.

Quoted 6 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +5 -0
+       }
+}
+
+static void cleanup(void)
+{

testcases/kernel/mem/cpuset/cpuset02.c line 120

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +7 -0
+       if (cg_cpuset_0)
+               cg_cpuset_0 = tst_cg_group_rm(cg_cpuset_0);
+}
+
+static struct tst_test test = {
+       .needs_root = 1,
 
 
 
+       .runs_script = 1,

Can we remove this line?

testcases/kernel/mem/cpuset/cpuset02.c line 127

Quoted 11 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +7 -0
+       .mntpoint = MNTPOINT,
+       .needs_hugetlbfs = 1,
+       .setup = setup,
+       .forks_child = 1,
+       .cleanup = cleanup,
+       .test_all = run_test,
 
 
 
+       .needs_checkpoints = 1,

Remove this line?

Quoted 2 lines

+ .needs_cgroup_ver = TST_CG_V1,

The test is also useful to CG_V2, so let's remove this line as well.

Quoted 14 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +10 -1
+       .needs_cgroup_ctrls = (const char *const []){ "cpuset", NULL },
+       .save_restore = (const struct tst_path_val[]) {
+               {"/proc/sys/vm/nr_hugepages", NULL, TST_SR_TCONF},
+               {}
+       },
+};
+
+#else
+TST_TEST_TCONF(NUMA_ERROR_MSG);
+#endif
--

2.35.3

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#41 lore raw

Re: [LTP] [PATCH v8 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

Hi Li

Quoted 4 lines

Hi Wei,

Geneally looks good, but some tiny places need improvement. See comments inline.

Thanks for the review!

Quoted 29 lines · Wei Gao
Quoted 18 lines
---
 lib/tst_cgroup.c                       |   1 +
 runtest/mm                             |   1 +
 testcases/kernel/mem/.gitignore        |   1 +
 testcases/kernel/mem/cpuset/Makefile   |   5 +
 testcases/kernel/mem/cpuset/cpuset02.c | 138 +++++++++++++++++++++++++
 5 files changed, 146 insertions(+)
 create mode 100644 testcases/kernel/mem/cpuset/cpuset02.c
lib/tst_cgroup.c +0 -0
index 73b696c58..545c779e7 100644

lib/tst_cgroup.c static const struct cgroup_file cpuset_ctrl_files[] = { · line 208

Quoted 5 lines
lib/tst_cgroup.c +1 -0
@@ -204,6 +204,7 @@ static const struct cgroup_file cpuset_ctrl_files[] = {
        { "cpuset.cpus", "cpuset.cpus", CTRL_CPUSET },
        { "cpuset.mems", "cpuset.mems", CTRL_CPUSET },
        { "cpuset.memory_migrate", "cpuset.memory_migrate", CTRL_CPUSET },
+       { "cpuset.sched_load_balance", "cpuset.sched_load_balance",
 CTRL_CPUSET },

cpuset.sched_load_balance is useful to enable/disable the scheduler can move tasks between CPUs in the cpuset.

Quoted 2 lines

Is there any purpose to add this knob in cpuset02 patch? I didn't see you touch it in the test.

Wei might had a different reason, but I see all functions in cpuset_memory_testset.sh (including test6 being rewritten to this test) call cpuset_funcs.sh which does 'echo 0 > .../cpuset.sched_load_balance', see:

test6()

{
	...
	cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr

cpuset_set()

{
	...
	local load_balance="$4"
	...
	/bin/echo $load_balance > $path/cpuset.sched_load_balance

I wonder whether it's good or not.

Kind regards,
Petr

Quoted 178 lines
        { }
Quoted 85 lines
lib/tst_cgroup.c +0 -0
 };
 
runtest/mm +1 -0
index d8e62af81..5af29b0ea 100644
@@ -75,6 +75,7 @@ ksm06_2 ksm06 -n 8000
 ksm07 ksm07
 
 cpuset01 cpuset01
+cpuset02 cpuset02
 
 oom01 oom01
 oom02 oom02
testcases/kernel/mem/.gitignore +1 -0
index 699e022fb..e24e96001 100644
@@ -1,4 +1,5 @@
 /cpuset/cpuset01
+/cpuset/cpuset02
 /hugetlb/hugefallocate/hugefallocate01
 /hugetlb/hugefallocate/hugefallocate02
 /hugetlb/hugefork/hugefork01
testcases/kernel/mem/cpuset/Makefile +5 -0
index bac13e02b..7010c7be4 100644
@@ -19,6 +19,11 @@
 
 top_srcdir             ?= ../../../..
 
+LTPLIBS = numa
+
 include $(top_srcdir)/include/mk/testcases.mk
 include $(top_srcdir)/testcases/kernel/include/lib.mk
+
+cpuset02: LTPLDLIBS = -lltpnuma
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/cpuset/cpuset02.c new file +36 -0
new file mode 100644
index 000000000..26b77f8be
@@ -0,0 +1,138 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/*
+ * Copyright (c) 2025 SUSE LLC <[email protected]>
+ */
+
+/*\
+ * Test checks cpuset.mems works with hugepage file.
+ * Based on test6 from cpuset_memory_testset.sh written by Miao Xie.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <sys/mount.h>
+#include <limits.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include "tst_test.h"
+
+#ifdef HAVE_NUMA_V2
+#include <numaif.h>
+#include "tst_numa.h"
+
+#define MNTPOINT "hugetlbfs/"
+#define HUGE_PAGE_FILE MNTPOINT "hugepagefile"
+
+static long hpage_size;
+static struct tst_nodemap *node;
+static int check_node_id;
+static struct tst_cg_group *cg_cpuset_0;
+
+static void touch_memory_and_check_node(char *p, int size)
+{
+       int i;
+       int node = -1;
+       long ret;
+       int pagesize = sysconf(_SC_PAGESIZE);

testcases/kernel/mem/cpuset/cpuset02.c line 46

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +10 -0
+
+       for (i = 0; i < size; i += pagesize)
+               p[i] = 0xef;
+
+       ret = get_mempolicy(&node, NULL, 0, p, MPOL_F_NODE | MPOL_F_ADDR);
+       if (ret < 0)
+               tst_brk(TBROK | TERRNO, "get_mempolicy() failed");
+
+       if (node == check_node_id)
+               tst_res(TPASS, "check node pass");

I suggest printing the node for detailed info.

    tst_res(TPASS, "1 huge page allocated on node-%d as expected", node);

testcases/kernel/mem/cpuset/cpuset02.c line 48

Quoted 2 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +2 -0
+       else
+               tst_res(TFAIL, "check node failed");
    tst_res(TFAIL, "1 huge page allocated on node-%d unexpected", node);
Quoted 52 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +45 -0
+}
+
+static void child(void)
+{
+       char *p;
+       int fd_hugepage;
+
+       fd_hugepage = SAFE_OPEN(HUGE_PAGE_FILE, O_CREAT | O_RDWR, 0755);
+       p = SAFE_MMAP(NULL, hpage_size, PROT_WRITE | PROT_READ,
+                               MAP_SHARED, fd_hugepage, 0);
+
+       touch_memory_and_check_node(p, hpage_size);
+
+       SAFE_MUNMAP(p, hpage_size);
+       SAFE_CLOSE(fd_hugepage);
+}
+
+static void run_test(void)
+{
+       int pid;
+       char node_id_str[256];
+
+       cg_cpuset_0 = tst_cg_group_mk(tst_cg, "0");
+
+       sprintf(node_id_str, "%u", check_node_id);
+       SAFE_CG_PRINT(cg_cpuset_0, "cpuset.mems", node_id_str);
+
+       pid = SAFE_FORK();
+
+       if (!pid) {
+               SAFE_CG_PRINTF(cg_cpuset_0, "cgroup.procs", "%d", pid);
+               child();
+               return;
+       }
+
+       SAFE_WAITPID(pid, NULL, 0);
+
+       cg_cpuset_0 = tst_cg_group_rm(cg_cpuset_0);
+}
+
+static void setup(void)
+{
+       node = tst_get_nodemap(TST_NUMA_MEM, getpagesize() / 1024);
+       if (node->cnt <= 1)
+               tst_brk(TCONF, "test requires at least 2 NUMA memory

nodes");

testcases/kernel/mem/cpuset/cpuset02.c new file +6 -0
+
+       check_node_id = node->map[node->cnt - 1];
+
+       hpage_size = SAFE_READ_MEMINFO(MEMINFO_HPAGE_SIZE)*1024;
+
+       char path[256];

testcases/kernel/mem/cpuset/cpuset02.c

Quoted 10 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +9 -0
+       unsigned int i;
+
+       for (i = 0; i < node->cnt; i++) {
+               unsigned int current_node_id = node->map[i];
+
+               sprintf(path,
+
 "/sys/devices/system/node/node%d/hugepages/hugepages-%ldkB/nr_hugepages",
+                       current_node_id, hpage_size / 1024);
+               SAFE_FILE_PRINTF(path, "%d", 1);

SAFE_ macro will break if fails to set the value. However, the reservation may not
succeed here due to memory fragmentation. So we can just use FILE_PRINTF().

Quoted 2 lines

Then, we need an additional check for the target node, if unable to reserve, then TCONF there.

I suppose we cannot do the reservation via struct tst_test, right? (using e.g. TST_SR_SKIP_RO from include/tst_sys_conf.h). That would require at least to add tst_get_nodemap() to struct tst_test, right?

Quoted 14 lines
Quoted 11 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +11 -0
+       }
+}
+
+static void cleanup(void)
+{
+       if (cg_cpuset_0)
+               cg_cpuset_0 = tst_cg_group_rm(cg_cpuset_0);
+}
+
+static struct tst_test test = {
+       .needs_root = 1,
Quoted 4 lines
Quoted 1 line

+ .runs_script = 1,

Can we remove this line?

+1, definitely not needed here (we don't use shell loader).

Quoted 9 lines
Quoted 6 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +6 -0
+       .mntpoint = MNTPOINT,
+       .needs_hugetlbfs = 1,
+       .setup = setup,
+       .forks_child = 1,
+       .cleanup = cleanup,
+       .test_all = run_test,
Quoted 4 lines
Quoted 1 line

+ .needs_checkpoints = 1,

Remove this line?

+1, Cyril asked for removing checkpoints, this is left.

https://lore.kernel.org/ltp/[email protected]/

Quoted 4 lines
Quoted 1 line

+ .needs_cgroup_ver = TST_CG_V1,

The test is also useful to CG_V2, so let's remove this line as well.

+1. The original shell script required v1. But C API allows to use both.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#42 lore raw

Re: [LTP] [PATCH v8 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

Quoted 55 lines · Petr Vorel

Hi Li

Quoted 4 lines

Hi Wei,

Geneally looks good, but some tiny places need improvement. See comments inline.

Thanks for the review!

Quoted 14 lines · Wei Gao
Quoted 12 lines
---
 lib/tst_cgroup.c                       |   1 +
 runtest/mm                             |   1 +
 testcases/kernel/mem/.gitignore        |   1 +
 testcases/kernel/mem/cpuset/Makefile   |   5 +
 testcases/kernel/mem/cpuset/cpuset02.c | 138 +++++++++++++++++++++++++
 5 files changed, 146 insertions(+)
 create mode 100644 testcases/kernel/mem/cpuset/cpuset02.c
Quoted 5 lines

lib/tst_cgroup.c static const struct cgroup_file

Quoted 5 lines
lib/tst_cgroup.c +0 -0
index 73b696c58..545c779e7 100644
@@ -204,6 +204,7 @@ static const struct cgroup_file

cpuset_ctrl_files[] = {

Quoted 3 lines

lib/tst_cgroup.c static const struct cgroup_file cpuset_ctrl_files[] = {

Quoted 3 lines
lib/tst_cgroup.c +0 -0
        { "cpuset.cpus", "cpuset.cpus", CTRL_CPUSET },
        { "cpuset.mems", "cpuset.mems", CTRL_CPUSET },
        { "cpuset.memory_migrate", "cpuset.memory_migrate",

CTRL_CPUSET },

Quoted 5 lines

lib/tst_cgroup.c static const struct cgroup_file · line 208

Quoted 2 lines
lib/tst_cgroup.c +1 -0
+       { "cpuset.sched_load_balance", "cpuset.sched_load_balance",
 CTRL_CPUSET },

cpuset.sched_load_balance is useful to enable/disable the scheduler can

move

Quoted 4 lines

tasks between CPUs in the cpuset.

Is there any purpose to add this knob in cpuset02 patch? I didn't see you touch it in the test.

Wei might had a different reason, but I see all functions in cpuset_memory_testset.sh (including test6 being rewritten to this test) call
cpuset_funcs.sh which does 'echo 0 > .../cpuset.sched_load_balance', see:

test6()

{
        ...
        cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2>

$CPUSET_TMP/stderr

Quoted 9 lines

cpuset_set()

{
        ...
        local load_balance="$4"
        ...
        /bin/echo $load_balance > $path/cpuset.sched_load_balance

I wonder whether it's good or not.

Ok, I see, it was used to disable the task from moving between CPUs in the cpuset. But to be honest, that's _not_ necessary, because whatever the task is bound to which CPU of the cpuset, it all belongs to that specified
node by limited Cgroup.

So I would drop this knob setting in new C test.

Quoted 187 lines

Kind regards,
Petr

Quoted 83 lines
        { }
Quoted 82 lines
lib/tst_cgroup.c +0 -0
 };
 
runtest/mm +1 -0
index d8e62af81..5af29b0ea 100644
@@ -75,6 +75,7 @@ ksm06_2 ksm06 -n 8000
 ksm07 ksm07
 
 cpuset01 cpuset01
+cpuset02 cpuset02
 
 oom01 oom01
 oom02 oom02
testcases/kernel/mem/.gitignore +1 -0
index 699e022fb..e24e96001 100644
@@ -1,4 +1,5 @@
 /cpuset/cpuset01
+/cpuset/cpuset02
 /hugetlb/hugefallocate/hugefallocate01
 /hugetlb/hugefallocate/hugefallocate02
 /hugetlb/hugefork/hugefork01
testcases/kernel/mem/cpuset/Makefile +5 -0
index bac13e02b..7010c7be4 100644
@@ -19,6 +19,11 @@
 
 top_srcdir             ?= ../../../..
 
+LTPLIBS = numa
+
 include $(top_srcdir)/include/mk/testcases.mk
 include $(top_srcdir)/testcases/kernel/include/lib.mk
+
+cpuset02: LTPLDLIBS = -lltpnuma
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/cpuset/cpuset02.c new file +33 -0
new file mode 100644
index 000000000..26b77f8be
@@ -0,0 +1,138 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/*
+ * Copyright (c) 2025 SUSE LLC <[email protected]>
+ */
+
+/*\
+ * Test checks cpuset.mems works with hugepage file.
+ * Based on test6 from cpuset_memory_testset.sh written by Miao Xie.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <sys/mount.h>
+#include <limits.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include "tst_test.h"
+
+#ifdef HAVE_NUMA_V2
+#include <numaif.h>
+#include "tst_numa.h"
+
+#define MNTPOINT "hugetlbfs/"
+#define HUGE_PAGE_FILE MNTPOINT "hugepagefile"
+
+static long hpage_size;
+static struct tst_nodemap *node;
+static int check_node_id;
+static struct tst_cg_group *cg_cpuset_0;
+
+static void touch_memory_and_check_node(char *p, int size)
+{
+       int i;
Quoted 8 lines

testcases/kernel/mem/cpuset/cpuset02.c

Quoted 8 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +8 -0
+       int node = -1;
+       long ret;
+       int pagesize = sysconf(_SC_PAGESIZE);
+
+       for (i = 0; i < size; i += pagesize)
+               p[i] = 0xef;
+
+       ret = get_mempolicy(&node, NULL, 0, p, MPOL_F_NODE |

MPOL_F_ADDR);

Quoted 19 lines

testcases/kernel/mem/cpuset/cpuset02.c line 46

Quoted 5 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +5 -0
+       if (ret < 0)
+               tst_brk(TBROK | TERRNO, "get_mempolicy() failed");
+
+       if (node == check_node_id)
+               tst_res(TPASS, "check node pass");

I suggest printing the node for detailed info.

    tst_res(TPASS, "1 huge page allocated on node-%d as expected", node);

testcases/kernel/mem/cpuset/cpuset02.c line 48

Quoted 2 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +2 -0
+       else
+               tst_res(TFAIL, "check node failed");
    tst_res(TFAIL, "1 huge page allocated on node-%d unexpected", node);
Quoted 8 lines

testcases/kernel/mem/cpuset/cpuset02.c

Quoted 8 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +8 -0
+}
+
+static void child(void)
+{
+       char *p;
+       int fd_hugepage;
+
+       fd_hugepage = SAFE_OPEN(HUGE_PAGE_FILE, O_CREAT | O_RDWR,

0755);

Quoted 44 lines
Quoted 44 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +37 -0
+       p = SAFE_MMAP(NULL, hpage_size, PROT_WRITE | PROT_READ,
+                               MAP_SHARED, fd_hugepage, 0);
+
+       touch_memory_and_check_node(p, hpage_size);
+
+       SAFE_MUNMAP(p, hpage_size);
+       SAFE_CLOSE(fd_hugepage);
+}
+
+static void run_test(void)
+{
+       int pid;
+       char node_id_str[256];
+
+       cg_cpuset_0 = tst_cg_group_mk(tst_cg, "0");
+
+       sprintf(node_id_str, "%u", check_node_id);
+       SAFE_CG_PRINT(cg_cpuset_0, "cpuset.mems", node_id_str);
+
+       pid = SAFE_FORK();
+
+       if (!pid) {
+               SAFE_CG_PRINTF(cg_cpuset_0, "cgroup.procs", "%d", pid);
+               child();
+               return;
+       }
+
+       SAFE_WAITPID(pid, NULL, 0);
+
+       cg_cpuset_0 = tst_cg_group_rm(cg_cpuset_0);
+}
+
+static void setup(void)
+{
+       node = tst_get_nodemap(TST_NUMA_MEM, getpagesize() / 1024);
+       if (node->cnt <= 1)
+               tst_brk(TCONF, "test requires at least 2 NUMA memory

nodes");

testcases/kernel/mem/cpuset/cpuset02.c new file +6 -0
+
+       check_node_id = node->map[node->cnt - 1];
+
+       hpage_size = SAFE_READ_MEMINFO(MEMINFO_HPAGE_SIZE)*1024;
+
+       char path[256];
Quoted 8 lines

testcases/kernel/mem/cpuset/cpuset02.c line 111

Quoted 8 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +7 -0
+       unsigned int i;
+
+       for (i = 0; i < node->cnt; i++) {
+               unsigned int current_node_id = node->map[i];
+
+               sprintf(path,
+

"/sys/devices/system/node/node%d/hugepages/hugepages-%ldkB/nr_hugepages",

Quoted 5 lines

testcases/kernel/mem/cpuset/cpuset02.c line 108

Quoted 2 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +2 -0
+                       current_node_id, hpage_size / 1024);
+               SAFE_FILE_PRINTF(path, "%d", 1);

SAFE_ macro will break if fails to set the value. However, the

reservation

Quoted 2 lines

may not
succeed here due to memory fragmentation. So we can just use

FILE_PRINTF().

Quoted 8 lines
Quoted 2 lines

Then, we need an additional check for the target node, if unable to reserve, then TCONF there.

I suppose we cannot do the reservation via struct tst_test, right? (using e.g. TST_SR_SKIP_RO from include/tst_sys_conf.h). That would require at least to
add tst_get_nodemap() to struct tst_test, right?

You're right.

Do tst_test.hugepage reservation is not precise to a specified node. We have to request that with dedicated code so far.

Maybe we can add something to the hpage reservation to support that, but I don't see that feature as widely needed in LTP test. It might not valuable to bring more complexity to the code just for this rarely used.

Quoted 51 lines
Quoted 14 lines
Quoted 11 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +11 -0
+       }
+}
+
+static void cleanup(void)
+{
+       if (cg_cpuset_0)
+               cg_cpuset_0 = tst_cg_group_rm(cg_cpuset_0);
+}
+
+static struct tst_test test = {
+       .needs_root = 1,
Quoted 4 lines
Quoted 1 line

+ .runs_script = 1,

Can we remove this line?

+1, definitely not needed here (we don't use shell loader).

Quoted 9 lines
Quoted 6 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +6 -0
+       .mntpoint = MNTPOINT,
+       .needs_hugetlbfs = 1,
+       .setup = setup,
+       .forks_child = 1,
+       .cleanup = cleanup,
+       .test_all = run_test,
Quoted 4 lines
Quoted 1 line

+ .needs_checkpoints = 1,

Remove this line?

+1, Cyril asked for removing checkpoints, this is left.

https://lore.kernel.org/ltp/[email protected]/

Quoted 4 lines
Quoted 1 line

+ .needs_cgroup_ver = TST_CG_V1,

The test is also useful to CG_V2, so let's remove this line as well.

+1. The original shell script required v1. But C API allows to use both.

Kind regards,
Petr

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#43 lore raw

Re: [LTP] [PATCH v8 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

Quoted 6 lines · Li Wang

Ok, I see, it was used to disable the task from moving between CPUs in the cpuset. But to be honest, that's _not_ necessary, because whatever the task is bound to which CPU of the cpuset, it all belongs to that specified
node by limited Cgroup.

One more word, this only applies to test6 (in cpuset_memory_testset.sh), as it only makes use of one cpuset :).

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#44 lore raw

Re: [LTP] [PATCH v8 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

In reply to Li Wang via ltp

Hi Li, Wei,

...

Quoted 7 lines

Ok, I see, it was used to disable the task from moving between CPUs in the cpuset. But to be honest, that's _not_ necessary, because whatever the task is bound to which CPU of the cpuset, it all belongs to that specified
node by limited Cgroup.

So I would drop this knob setting in new C test.

+1. Maybe worth to mention this in the commit message.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#45 lore raw

PATCH v8 2/2 cpuset_memory_testset.sh: Remove test6

In reply to Wei Gao via ltp
---
 .../cpuset_memory_testset.sh                  | 37 +------------------
 1 file changed, 2 insertions(+), 35 deletions(-)
testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh +2 -35
index c1e7cea8f..fd41dc97a 100755
@@ -162,41 +162,8 @@ check_hugetlbfs()
 
 test6()
 {
-	cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
-	if [ $? -ne 0 ]; then
-		cpuset_log_error $CPUSET_TMP/stderr
-		tst_resm TFAIL "set general group parameter failed."
-		return 1
-	fi
-
-	check_hugetlbfs
-	if [ $? -eq 0 ]; then
-		tst_resm TCONF "This system don't support hugetlbfs"
-		return 0
-	fi
-
-	mkdir /hugetlb
-	mount -t hugetlbfs none /hugetlb
-
-	save_nr_hugepages=$(cat /proc/sys/vm/nr_hugepages)
-	echo $((2*$nr_mems)) > /proc/sys/vm/nr_hugepages
-
-	cpuset_memory_test --mmap-file --hugepage -s $HUGEPAGESIZE >"$MEMORY_RESULT" &
-	simple_getresult $! "$CPUSET/0"
-
-	umount /hugetlb
-	rmdir /hugetlb
-
-	echo $save_nr_hugepages > /proc/sys/vm/nr_hugepages
-	if [ $(cat /proc/sys/vm/nr_hugepages) -ne $save_nr_hugepages ]; then
-		tst_resm TFAIL "can't restore nr_hugepages(nr_hugepages = $save_nr_hugepages)."
-		return 1
-	fi
-
-	if [ "$node" != "0" ]; then
-		tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)."
-		return 1
-	fi
+	tst_resm TINFO "This test is replaced by testcases/kernel/mem/cpuset/cpuset02.c"
+	return 0
 }
 
 test7()
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#46 lore raw

v9 cover cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

In reply to Wei Gao via ltp

Changes v8-v9:
* Remove .needs_cgroup_ver = TST_CG_V1, let case support both v1 and v2
* Remove cpuset.sched_load_balance knob
* Update base Li Wang and Petr's improvement suggestions on v8

link to v8:
https://patchwork.ozlabs.org/project/ltp/cover/[email protected]/

Wei Gao (2):
cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code cpuset_memory_testset.sh: Remove test6

 runtest/mm                                    |   1 +
 .../cpuset_memory_testset.sh                  |  37 +----
 testcases/kernel/mem/.gitignore               |   1 +
 testcases/kernel/mem/cpuset/Makefile          |   5 +
 testcases/kernel/mem/cpuset/cpuset02.c        | 140 ++++++++++++++++++
 5 files changed, 149 insertions(+), 35 deletions(-)
 create mode 100644 testcases/kernel/mem/cpuset/cpuset02.c
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#47 lore raw

PATCH v9 1/2 cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

Improvements compare with test6 shell test:
* Remove /bin/echo $load_balance > $path/cpuset.sched_load_balance since test focus on verify huge page is really allocated in the correct node, task no need bind to specific cpuset.
* Directly keep 1 hpage reserved in each node otherwise test case has chance to fail, since echo 1 > /proc/sys/vm/nr_hugepages will try to reserve 1 pages from a NUMA node randomly.

---
 runtest/mm                             |   1 +
 testcases/kernel/mem/.gitignore        |   1 +
 testcases/kernel/mem/cpuset/Makefile   |   5 +
 testcases/kernel/mem/cpuset/cpuset02.c | 140 +++++++++++++++++++++++++
 4 files changed, 147 insertions(+)
 create mode 100644 testcases/kernel/mem/cpuset/cpuset02.c
runtest/mm +1 -0
index d8e62af81..5af29b0ea 100644
@@ -75,6 +75,7 @@ ksm06_2 ksm06 -n 8000
 ksm07 ksm07
 
 cpuset01 cpuset01
+cpuset02 cpuset02
 
 oom01 oom01
 oom02 oom02
testcases/kernel/mem/.gitignore +1 -0
index 699e022fb..e24e96001 100644
@@ -1,4 +1,5 @@
 /cpuset/cpuset01
+/cpuset/cpuset02
 /hugetlb/hugefallocate/hugefallocate01
 /hugetlb/hugefallocate/hugefallocate02
 /hugetlb/hugefork/hugefork01
testcases/kernel/mem/cpuset/Makefile +5 -0
index bac13e02b..7010c7be4 100644
@@ -19,6 +19,11 @@
 
 top_srcdir		?= ../../../..
 
+LTPLIBS = numa
+
 include $(top_srcdir)/include/mk/testcases.mk
 include $(top_srcdir)/testcases/kernel/include/lib.mk
+
+cpuset02: LTPLDLIBS = -lltpnuma
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/cpuset/cpuset02.c new file +140 -0

140 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author Reviewed-by Li Wang on v9 1/2
#48 lore raw

Re: [LTP] [PATCH v9 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

Quoted 8 lines · Wei Gao

Improvements compare with test6 shell test:
* Remove /bin/echo $load_balance > $path/cpuset.sched_load_balance since test focus on verify huge page is really allocated in the correct node, task no need bind to specific cpuset.
* Directly keep 1 hpage reserved in each node otherwise test case has chance to fail, since echo 1 > /proc/sys/vm/nr_hugepages will try to reserve 1 pages from a NUMA node randomly.

Quoted 4 lines

testcases/kernel/mem/cpuset/cpuset02.c line 57

Quoted 11 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +7 -0
+static void child(void)
+{
+       char *p;
+       int fd_hugepage;
+
+       fd_hugepage = SAFE_OPEN(HUGE_PAGE_FILE, O_CREAT | O_RDWR, 0755);
 
 
 
+TST_EXP_PASS_SILENT(system("cat /proc/meminfo"));

This line is for debugging purposes, I guess, and it should be removed in the formal patch.

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#49 lore raw

Re: [LTP] [PATCH v9 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

Quoted 27 lines · Li Wang
Quoted 8 lines · Wei Gao

Improvements compare with test6 shell test:
* Remove /bin/echo $load_balance > $path/cpuset.sched_load_balance since test focus on verify huge page is really allocated in the correct node, task no need bind to specific cpuset.
* Directly keep 1 hpage reserved in each node otherwise test case has chance to fail, since echo 1 > /proc/sys/vm/nr_hugepages will try to reserve 1 pages from a NUMA node randomly.

Quoted 4 lines
Quoted 7 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +6 -0
+static void child(void)
+{
+       char *p;
+       int fd_hugepage;
+
+       fd_hugepage = SAFE_OPEN(HUGE_PAGE_FILE, O_CREAT | O_RDWR, 0755);
Quoted 5 lines
Quoted 2 lines

+TST_EXP_PASS_SILENT(system("cat /proc/meminfo"));

This line is for debugging purposes, I guess, and it should be removed in the formal patch.

Sorry, forget remove this debug line after done different scenario's verification. i will wait for a while, if no more comments receive by end of today i will update another new patch.
Thanks.

Quoted 5 lines
Signature · 3 lines
-- 
Regards,
Li Wang
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#50 lore raw

Re: [LTP] [PATCH v9 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

In reply to Li Wang via ltp
Quoted 27 lines · Wei Gao
Quoted 9 lines

Improvements compare with test6 shell test:
* Remove /bin/echo $load_balance > $path/cpuset.sched_load_balance since test focus on verify huge page is really allocated in the correct node, task no need bind to specific cpuset.
* Directly keep 1 hpage reserved in each node otherwise test case has chance to fail, since echo 1 > /proc/sys/vm/nr_hugepages will try to reserve 1 pages from a NUMA node randomly.

Quoted 3 lines
Quoted 6 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +6 -0
+static void child(void)
+{
+       char *p;
+       int fd_hugepage;
+
+       fd_hugepage = SAFE_OPEN(HUGE_PAGE_FILE, O_CREAT | O_RDWR, 0755);
Quoted 5 lines
Quoted 1 line

+TST_EXP_PASS_SILENT(system("cat /proc/meminfo"));

This line is for debugging purposes, I guess, and it should be removed in the formal patch.

+1

With that changed you can keep my RBT. I hope v10 could be final.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#51 lore raw

Re: [LTP] [PATCH v9 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

In reply to Wei Gao via ltp

Hi Wei, Li, Cyril,

...

testcases/kernel/mem/cpuset/cpuset02.c line 94

Quoted 5 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +5 -0
+static void setup(void)
+{
+	node = tst_get_nodemap(TST_NUMA_MEM, getpagesize() / 1024);
+	if (node->cnt <= 1)
+		tst_brk(TCONF, "test requires at least 2 NUMA memory nodes");

Naive question: why test requires 2 memory nodes? Wouldn't be 1 enough?

Kind regards,
Petr

Quoted 21 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +21 -0
+
+	check_node_id = node->map[node->cnt - 1];
+
+	hpage_size = SAFE_READ_MEMINFO(MEMINFO_HPAGE_SIZE)*1024;
+
+	char path[256];
+	unsigned int i;
+	unsigned int nr_hugepages;
+
+	for (i = 0; i < node->cnt; i++) {
+		unsigned int current_node_id = node->map[i];
+
+		sprintf(path,
+			"/sys/devices/system/node/node%d/hugepages/hugepages-%ldkB/nr_hugepages",
+			current_node_id, hpage_size / 1024);
+		FILE_PRINTF(path, "%d", 1);
+		SAFE_FILE_SCANF(path, "%d", &nr_hugepages);
+		if (nr_hugepages != 1)
+			tst_brk(TCONF, "reserve 1 huge page on node%d failed", current_node_id);
+	}
+}
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#52 lore raw

Re: [LTP] [PATCH v9 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

Quoted 12 lines · Petr Vorel

Hi Wei, Li, Cyril,

...

testcases/kernel/mem/cpuset/cpuset02.c

Quoted 5 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +5 -0
+static void setup(void)
+{
+     node = tst_get_nodemap(TST_NUMA_MEM, getpagesize() / 1024);
+     if (node->cnt <= 1)
+             tst_brk(TCONF, "test requires at least 2 NUMA memory

nodes");

Quoted 2 lines

Naive question: why test requires 2 memory nodes? Wouldn't be 1 enough?

Because test6 verify that hugepage + cpuset works well, so if we only use 1 node for testing, the allocated hugepage will always happen on that node. Then we would lose the chance to find bug that there possibly allocated from other nodes when setting the cpuset.

So this test needs at least two NUMA nodes.

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#53 lore raw

Re: [LTP] [PATCH v9 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

In reply to Petr Vorel
Quoted 9 lines · Petr Vorel

Hi Wei, Li, Cyril,

...

testcases/kernel/mem/cpuset/cpuset02.c line 94

Quoted 5 lines
testcases/kernel/mem/cpuset/cpuset02.c new file +5 -0
+static void setup(void)
+{
+	node = tst_get_nodemap(TST_NUMA_MEM, getpagesize() / 1024);
+	if (node->cnt <= 1)
+		tst_brk(TCONF, "test requires at least 2 NUMA memory nodes");

Naive question: why test requires 2 memory nodes? Wouldn't be 1 enough?

Depend on what test's purpuse, if you need check kernel select correct node, i suppose we need at least 2 nodes. Of course, test case also can support 1 node check.

Quoted 4 lines

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#54 lore raw

PATCH v9 2/2 cpuset_memory_testset.sh: Remove test6

In reply to Wei Gao via ltp
---
 .../cpuset_memory_testset.sh                  | 37 +------------------
 1 file changed, 2 insertions(+), 35 deletions(-)
testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh +2 -35
index c1e7cea8f..fd41dc97a 100755
@@ -162,41 +162,8 @@ check_hugetlbfs()
 
 test6()
 {
-	cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
-	if [ $? -ne 0 ]; then
-		cpuset_log_error $CPUSET_TMP/stderr
-		tst_resm TFAIL "set general group parameter failed."
-		return 1
-	fi
-
-	check_hugetlbfs
-	if [ $? -eq 0 ]; then
-		tst_resm TCONF "This system don't support hugetlbfs"
-		return 0
-	fi
-
-	mkdir /hugetlb
-	mount -t hugetlbfs none /hugetlb
-
-	save_nr_hugepages=$(cat /proc/sys/vm/nr_hugepages)
-	echo $((2*$nr_mems)) > /proc/sys/vm/nr_hugepages
-
-	cpuset_memory_test --mmap-file --hugepage -s $HUGEPAGESIZE >"$MEMORY_RESULT" &
-	simple_getresult $! "$CPUSET/0"
-
-	umount /hugetlb
-	rmdir /hugetlb
-
-	echo $save_nr_hugepages > /proc/sys/vm/nr_hugepages
-	if [ $(cat /proc/sys/vm/nr_hugepages) -ne $save_nr_hugepages ]; then
-		tst_resm TFAIL "can't restore nr_hugepages(nr_hugepages = $save_nr_hugepages)."
-		return 1
-	fi
-
-	if [ "$node" != "0" ]; then
-		tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)."
-		return 1
-	fi
+	tst_resm TINFO "This test is replaced by testcases/kernel/mem/cpuset/cpuset02.c"
+	return 0
 }
 
 test7()
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author Reviewed-by Li Wang on v9 2/2
#55 lore raw

Re: [LTP] [PATCH v9 2/2] cpuset_memory_testset.sh: Remove test6

Quoted 3 lines · Wei Gao via ltp

---

Quoted 69 lines
 .../cpuset_memory_testset.sh                  | 37 +------------------
 1 file changed, 2 insertions(+), 35 deletions(-)

diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh index c1e7cea8f..fd41dc97a 100755
---
a/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh
+++
b/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh

(quoted diff) +0 -1
@@ -162,41 +162,8 @@ check_hugetlbfs()
 
 test6()
 {
-       cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2>

$CPUSET_TMP/stderr

testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh +0 -19
-       if [ $? -ne 0 ]; then
-               cpuset_log_error $CPUSET_TMP/stderr
-               tst_resm TFAIL "set general group parameter failed."
-               return 1
-       fi
-
-       check_hugetlbfs
-       if [ $? -eq 0 ]; then
-               tst_resm TCONF "This system don't support hugetlbfs"
-               return 0
-       fi
-
-       mkdir /hugetlb
-       mount -t hugetlbfs none /hugetlb
-
-       save_nr_hugepages=$(cat /proc/sys/vm/nr_hugepages)
-       echo $((2*$nr_mems)) > /proc/sys/vm/nr_hugepages
-
-       cpuset_memory_test --mmap-file --hugepage -s $HUGEPAGESIZE
Quoted 1 line

"$MEMORY_RESULT" &

testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh +0 -7
-       simple_getresult $! "$CPUSET/0"
-
-       umount /hugetlb
-       rmdir /hugetlb
-
-       echo $save_nr_hugepages > /proc/sys/vm/nr_hugepages
-       if [ $(cat /proc/sys/vm/nr_hugepages) -ne $save_nr_hugepages ];

then
- tst_resm TFAIL "can't restore nr_hugepages(nr_hugepages =
$save_nr_hugepages)."

testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh +0 -5
-               return 1
-       fi
-
-       if [ "$node" != "0" ]; then
-               tst_resm TFAIL "allocate memory on the Node#$node(Expect:

Node#0)."

testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh +1 -2
-               return 1
-       fi
+       tst_resm TINFO "This test is replaced by

testcases/kernel/mem/cpuset/cpuset02.c"
+ return 0
}

test7()
--
2.35.3

--
Mailing list info: https://lists.linux.it/listinfo/ltp

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#56 lore raw

Re: [LTP] [PATCH v9 2/2] cpuset_memory_testset.sh: Remove test6

In reply to Wei Gao via ltp

Hi Wei,

Quoted 41 lines
---
 .../cpuset_memory_testset.sh                  | 37 +------------------
 1 file changed, 2 insertions(+), 35 deletions(-)
testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh +0 -27
index c1e7cea8f..fd41dc97a 100755
@@ -162,41 +162,8 @@ check_hugetlbfs()
 
 test6()
 {
-	cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
-	if [ $? -ne 0 ]; then
-		cpuset_log_error $CPUSET_TMP/stderr
-		tst_resm TFAIL "set general group parameter failed."
-		return 1
-	fi
-
-	check_hugetlbfs
-	if [ $? -eq 0 ]; then
-		tst_resm TCONF "This system don't support hugetlbfs"
-		return 0
-	fi
-
-	mkdir /hugetlb
-	mount -t hugetlbfs none /hugetlb
-
-	save_nr_hugepages=$(cat /proc/sys/vm/nr_hugepages)
-	echo $((2*$nr_mems)) > /proc/sys/vm/nr_hugepages
-
-	cpuset_memory_test --mmap-file --hugepage -s $HUGEPAGESIZE >"$MEMORY_RESULT" &
-	simple_getresult $! "$CPUSET/0"
-
-	umount /hugetlb
-	rmdir /hugetlb
-
-	echo $save_nr_hugepages > /proc/sys/vm/nr_hugepages
-	if [ $(cat /proc/sys/vm/nr_hugepages) -ne $save_nr_hugepages ]; then

testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh check_hugetlbfs() · line 166

Quoted 10 lines
testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh +2 -8
-		tst_resm TFAIL "can't restore nr_hugepages(nr_hugepages = $save_nr_hugepages)."
-		return 1
-	fi
-
-	if [ "$node" != "0" ]; then
-		tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)."
-		return 1
-	fi
+	tst_resm TINFO "This test is replaced by testcases/kernel/mem/cpuset/cpuset02.c"
+	return 0

In new C shell API this would fail because test is not propagating any result. I suppose this will work on old API, but wouldn't be better just remove whole test6(), renumber tests and set TST_TOTAL=17?

Kind regards,
Petr

Quoted 3 lines
testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh +0 -0
 }
 
 test7()
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#57 lore raw

Re: [LTP] [PATCH v9 0/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

In reply to Wei Gao via ltp
Quoted 4 lines

Changes v8-v9:
* Remove .needs_cgroup_ver = TST_CG_V1, let case support both v1 and v2
* Remove cpuset.sched_load_balance knob
* Update base Li Wang and Petr's improvement suggestions on v8

3rd point means:
* removed .runs_script = 1
* .needs_checkpoints = 1,
* SAFE_FILE_PRINTF() => FILE_PRINTF() and SAFE_FILE_SCANF() with TCONF check

Kind regards,
Petr

Quoted 14 lines

link to v8:
https://patchwork.ozlabs.org/project/ltp/cover/[email protected]/

Wei Gao (2):
cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code cpuset_memory_testset.sh: Remove test6

 runtest/mm                                    |   1 +
 .../cpuset_memory_testset.sh                  |  37 +----
 testcases/kernel/mem/.gitignore               |   1 +
 testcases/kernel/mem/cpuset/Makefile          |   5 +
 testcases/kernel/mem/cpuset/cpuset02.c        | 140 ++++++++++++++++++
 5 files changed, 149 insertions(+), 35 deletions(-)
 create mode 100644 testcases/kernel/mem/cpuset/cpuset02.c
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#58 lore raw

v10 cover cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

In reply to Wei Gao via ltp

Changes v9-v10:
* Remove debug line
* Remove whole test6(), renumber tests and set TST_TOTAL=17

link to v9:
https://patchwork.ozlabs.org/project/ltp/cover/[email protected]/

Wei Gao (2):
cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code cpuset_memory_testset.sh: Remove test6

 runtest/mm                                    |   1 +
 .../cpuset_memory_testset.sh                  |  63 ++------
 testcases/kernel/mem/.gitignore               |   1 +
 testcases/kernel/mem/cpuset/Makefile          |   5 +
 testcases/kernel/mem/cpuset/cpuset02.c        | 139 ++++++++++++++++++
 5 files changed, 158 insertions(+), 51 deletions(-)
 create mode 100644 testcases/kernel/mem/cpuset/cpuset02.c
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#59 lore raw

PATCH v10 1/2 cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

Improvements compare with test6 shell test:
* Remove /bin/echo $load_balance > $path/cpuset.sched_load_balance since test focus on verify huge page is really allocated in the correct node, task no need bind to specific cpuset.
* Directly keep 1 hpage reserved in each node otherwise test case has chance to fail, since echo 1 > /proc/sys/vm/nr_hugepages will try to reserve 1 pages from a NUMA node randomly.

---
 runtest/mm                             |   1 +
 testcases/kernel/mem/.gitignore        |   1 +
 testcases/kernel/mem/cpuset/Makefile   |   5 +
 testcases/kernel/mem/cpuset/cpuset02.c | 139 +++++++++++++++++++++++++
 4 files changed, 146 insertions(+)
 create mode 100644 testcases/kernel/mem/cpuset/cpuset02.c
runtest/mm +1 -0
index 871e1f026..5566a7742 100644
@@ -68,6 +68,7 @@ ksm06_2 ksm06 -n 8000
 ksm07 ksm07
 
 cpuset01 cpuset01
+cpuset02 cpuset02
 
 oom01 oom01
 oom02 oom02
testcases/kernel/mem/.gitignore +1 -0
index 699e022fb..e24e96001 100644
@@ -1,4 +1,5 @@
 /cpuset/cpuset01
+/cpuset/cpuset02
 /hugetlb/hugefallocate/hugefallocate01
 /hugetlb/hugefallocate/hugefallocate02
 /hugetlb/hugefork/hugefork01
testcases/kernel/mem/cpuset/Makefile +5 -0
index bac13e02b..7010c7be4 100644
@@ -19,6 +19,11 @@
 
 top_srcdir		?= ../../../..
 
+LTPLIBS = numa
+
 include $(top_srcdir)/include/mk/testcases.mk
 include $(top_srcdir)/testcases/kernel/include/lib.mk
+
+cpuset02: LTPLDLIBS = -lltpnuma
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/cpuset/cpuset02.c new file +139 -0

139 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#60 lore raw

Re: [LTP] [PATCH v10 1/2] cpuset02: Convert the test6 from cpuset_memory_testset.sh to C code

Pushed with minor improvements.

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#61 lore raw

PATCH v10 2/2 cpuset_memory_testset.sh: Remove test6

In reply to Wei Gao via ltp
---
 .../cpuset_memory_testset.sh                  | 63 ++++---------------
 1 file changed, 12 insertions(+), 51 deletions(-)
testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh +12 -51
index c1e7cea8f..e81d22293 100755
@@ -23,7 +23,7 @@
 ################################################################################
 
 export TCID="cpuset_memory"
-export TST_TOTAL=18
+export TST_TOTAL=17
 export TST_COUNT=1
 
 . cpuset_funcs.sh
@@ -181,45 +181,6 @@ test6()
 	save_nr_hugepages=$(cat /proc/sys/vm/nr_hugepages)
 	echo $((2*$nr_mems)) > /proc/sys/vm/nr_hugepages
 
-	cpuset_memory_test --mmap-file --hugepage -s $HUGEPAGESIZE >"$MEMORY_RESULT" &
-	simple_getresult $! "$CPUSET/0"
-
-	umount /hugetlb
-	rmdir /hugetlb
-
-	echo $save_nr_hugepages > /proc/sys/vm/nr_hugepages
-	if [ $(cat /proc/sys/vm/nr_hugepages) -ne $save_nr_hugepages ]; then
-		tst_resm TFAIL "can't restore nr_hugepages(nr_hugepages = $save_nr_hugepages)."
-		return 1
-	fi
-
-	if [ "$node" != "0" ]; then
-		tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)."
-		return 1
-	fi
-}
-
-test7()
-{
-	cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
-	if [ $? -ne 0 ]; then
-		cpuset_log_error $CPUSET_TMP/stderr
-		tst_resm TFAIL "set general group parameter failed."
-		return 1
-	fi
-
-	check_hugetlbfs
-	if [ $? -eq 0 ]; then
-		tst_resm TCONF "This system don't support hugetlbfs"
-		return 0
-	fi
-
-	mkdir /hugetlb
-	mount -t hugetlbfs none /hugetlb
-
-	save_nr_hugepages=$(cat /proc/sys/vm/nr_hugepages)
-	echo $((2*$nr_mems)) > /proc/sys/vm/nr_hugepages
-
 	cpuset_memory_test --shm --hugepage -s $HUGEPAGESIZE --key=7 >"$MEMORY_RESULT" &
 	simple_getresult $! "$CPUSET/0"
 
@@ -238,7 +199,7 @@ test7()
 	fi
 }
 
-test8()
+test7()
 {
 	cpuset_set "$CPUSET/0" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
 	if [ $? -ne 0 ]; then
@@ -255,7 +216,7 @@ test8()
 	fi
 }
 
-test9()
+test8()
 {
 	cpuset_set "$CPUSET/0" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr
 	if [ $? -ne 0 ]; then
@@ -291,7 +252,7 @@ talk2memory_test_for_case_10_11()
 	wait $1
 }
 
-test10()
+test9()
 {
 	cpuset_set "$CPUSET/1" "$cpus_all" "0" "0" 2> $CPUSET_TMP/stderr
 	if [ $? -ne 0 ]; then
@@ -329,7 +290,7 @@ test10()
 	fi
 }
 
-test11()
+test10()
 {
 	cpuset_set "$CPUSET/1" "$cpus_all" "0" "0" 2> $CPUSET_TMP/stderr
 	if [ $? -ne 0 ]; then
@@ -395,7 +356,7 @@ talk2memory_test_for_case_12_13()
 }
 
 
-test12()
+test11()
 {
 	cpuset_set "$CPUSET/0" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr
 	if [ $? -ne 0 ]; then
@@ -423,7 +384,7 @@ test12()
 }
 
 
-test13()
+test12()
 {
 	cpuset_set "$CPUSET/0" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr
 	if [ $? -ne 0 ]; then
@@ -479,7 +440,7 @@ get_the_second()
 	)
 }
 
-test14()
+test13()
 {
 	cpuset_set "$CPUSET/1" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
 	if [ $? -ne 0 ]; then
@@ -527,7 +488,7 @@ test14()
 	fi
 }
 
-test15()
+test14()
 {
 	cpuset_set "$CPUSET/1" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
 	if [ $? -ne 0 ]; then
@@ -583,7 +544,7 @@ test15()
 	fi
 }
 
-test16()
+test15()
 {
 	cpuset_set "$CPUSET/1" "$cpu_of_node0" "0" "0" 2> $CPUSET_TMP/stderr
 	if [ $? -ne 0 ]; then
@@ -650,7 +611,7 @@ test16()
 	fi
 }
 
-test17()
+test16()
 {
 	cpuset_set "$CPUSET/1" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr
 	if [ $? -ne 0 ]; then
@@ -725,7 +686,7 @@ test17()
 	fi
 }
 
-test18()
+test17()
 {
 	cpuset_set "$CPUSET/1" "$cpu_of_node0" "1" "0" 2> $CPUSET_TMP/stderr
 	if [ $? -ne 0 ]; then
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp