public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/5] lib/mem: modified _gather_cpus() as _gather_node_cpus()
  2013-03-14 16:21   ` [LTP] [PATCH 0/5] mm/oom: extend the coverage of OOM Zhouping Liu
@ 2013-03-14 16:21 Zhouping Liu
  2013-03-14 16:21 ` [LTP] [PATCH 2/5] mm/oom02: modified 'OOM for NUMA' as 'OOM for mempolicy' Zhouping Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Zhouping Liu @ 2013-03-14 16:21 UTC (permalink / raw)
  To: LTP List

The previous _gather_cpus() tried to collect all the specified
node's cpus, but it didn't pay attention to the offline cpus,
if one cpu in the specified node were offline, it can't write
the cpu number to cgroups/*.cpus, and return -EINVAL.

The patch fixed it, and modified the function name, as the new
name make more sense.

Signed-off-by: Zhouping Liu <zliu@redhat.com>
---
 testcases/kernel/mem/lib/mem.c | 32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
index a827b25..29de64a 100644
--- a/testcases/kernel/mem/lib/mem.c
+++ b/testcases/kernel/mem/lib/mem.c
@@ -481,20 +481,42 @@ void ksm_usage(void)
 
 /* cpuset/memcg */
 
-static void _gather_cpus(char *cpus, long nd)
+static void _gather_node_cpus(char *cpus, long nd)
 {
 	int ncpus = 0;
-	int i;
+	int fd, i;
+	long online;
 	char buf[BUFSIZ];
+	char path[BUFSIZ], path1[BUFSIZ];
 
 	while (path_exist(PATH_SYS_SYSTEM "/cpu/cpu%d", ncpus))
 		ncpus++;
 
-	for (i = 0; i < ncpus; i++)
-		if (path_exist(PATH_SYS_SYSTEM "/node/node%ld/cpu%d", nd, i)) {
+	for (i = 0; i < ncpus; i++) {
+		snprintf(path, BUFSIZ,
+			 PATH_SYS_SYSTEM "/node/node%ld/cpu%d", nd, i);
+		if (path_exist(path, nd, i)) {
+			snprintf(path1, BUFSIZ, "%s/online", path);
+			/*
+			 * No cpu0/online knob, as it can't support to
+			 * on/offline cpu0, so if the 'nd' node contains
+			 * cpu0, it should skip to check cpu0/online's value.
+			 */
+			if (i == 0)
+				goto  next;
+			fd = open(path1, O_RDONLY);
+			if (fd == -1)
+				tst_brkm(TBROK|TERRNO, cleanup,
+					 "open %s", path1);
+			read_file(path1, buf);
+			online = SAFE_STRTOL(cleanup, buf, 0, 1);
+			if (online == 0)
+				continue;
+next:
 			sprintf(buf, "%d,", i);
 			strcat(cpus, buf);
 		}
+	}
 	/* Remove the trailing comma. */
 	cpus[strlen(cpus) - 1] = '\0';
 }
@@ -563,7 +585,7 @@ void write_cpusets(long nd)
 	snprintf(buf, BUFSIZ, "%ld", nd);
 	write_cpuset_files(CPATH_NEW, "mems", buf);
 
-	_gather_cpus(cpus, nd);
+	_gather_node_cpus(cpus, nd);
 	write_cpuset_files(CPATH_NEW, "cpus", cpus);
 
 	snprintf(buf, BUFSIZ, "%d", getpid());
-- 
1.7.11.7


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-03-15 16:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <51428CEA.6030604@redhat.com>
2013-03-15  9:11 ` [LTP] [PATCH 3/5] mm/oom0[3|4]: added 'OOM for CPUSET' and updated 'OOM with MEMCG & numa' Jan Stancek
2013-03-15 15:41   ` Zhouping Liu
2013-03-15 16:06     ` Jan Stancek
2013-03-14 16:21 [LTP] [PATCH 1/5] lib/mem: modified _gather_cpus() as _gather_node_cpus() Zhouping Liu
2013-03-14 16:21 ` [LTP] [PATCH 2/5] mm/oom02: modified 'OOM for NUMA' as 'OOM for mempolicy' Zhouping Liu
2013-03-14 16:21   ` [LTP] [PATCH 0/5] mm/oom: extend the coverage of OOM Zhouping Liu
2013-03-14 16:21     ` [LTP] [PATCH 3/5] mm/oom0[3|4]: added 'OOM for CPUSET' and updated 'OOM with MEMCG & numa' Zhouping Liu
2013-03-14 16:51       ` chrubis
     [not found]         ` <507561236.18941341.1363282016883.JavaMail.root@redhat.com>
2013-03-14 18:32           ` chrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox