* Re: [LTP] [PATCH 3/2] mm: fix possible node missing in write_cpusets
[not found] <bb215812-518c-4d08-971d-7ed628347f4b@zmail13.collab.prod.int.phx2.redhat.com>
@ 2012-02-21 2:44 ` Caspar Zhang
0 siblings, 0 replies; 2+ messages in thread
From: Caspar Zhang @ 2012-02-21 2:44 UTC (permalink / raw)
To: Zhouping Liu; +Cc: LTP list
On 02/20/2012 09:49 PM, Zhouping Liu wrote:
> hi, caspar
>>
>>
>> If a system has noncontinuous nodes, or the node doesn't start from
>> 0,
>> write_cpusets() function may fail because it hard-coded second node
>> as
>> "node1". This patch fixes the function by fetching second node number
>> from the stored array.
>>
>> Tested-by: Caspar Zhang <caspar@casparzhang.com>
>> Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
>> ---
>> testcases/kernel/mem/include/mem.h | 4 ++--
>> testcases/kernel/mem/ksm/ksm02.c | 6 ++----
>> testcases/kernel/mem/ksm/ksm04.c | 6 ++----
>> testcases/kernel/mem/lib/mem.c | 21 +++++++++++++--------
>> 4 files changed, 19 insertions(+), 18 deletions(-)
>>
>>
> inside write_cpusets(),
>> fd = open(CPATH_NEW "/mems", O_WRONLY);
>> if (fd == -1) {
>> if (errno == ENOENT) {
>> fd = open(CPATH_NEW "/cpuset.mems", O_WRONLY);
>> if (fd == -1)
>> tst_brkm(TBROK|TERRNO, cleanup, "open %s", buf);
>> } else
>> tst_brkm(TBROK|TERRNO, cleanup, "open %s", buf);
>> }
>> if (write(fd, "1", 1) != 1)
> you maybe missed here, it should be:
>
> snprintf(buf, BUFSIZ, "%ld", nd);
> if (wirte(fd, buf, strlen(buf)) !=strlen(buf))
you're right.
Thanks,
Caspar
>
>> tst_brkm(TBROK|TERRNO, cleanup, "write %s", buf);
>> close(fd);
>
> others is okay for me.
>
> thanks,
> Zhouping
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 2+ messages in thread
* [LTP] [PATCH 3/2] mm: fix possible node missing in write_cpusets
2012-02-20 10:55 [LTP] [PATCH 1/2] mm/lib: change count_numa() behavior Caspar Zhang
@ 2012-02-20 12:21 ` Caspar Zhang
0 siblings, 0 replies; 2+ messages in thread
From: Caspar Zhang @ 2012-02-20 12:21 UTC (permalink / raw)
To: LTP List
[-- Attachment #1: Type: text/plain, Size: 609 bytes --]
If a system has noncontinuous nodes, or the node doesn't start from 0,
write_cpusets() function may fail because it hard-coded second node as
"node1". This patch fixes the function by fetching second node number
from the stored array.
Tested-by: Caspar Zhang <caspar@casparzhang.com>
Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
---
testcases/kernel/mem/include/mem.h | 4 ++--
testcases/kernel/mem/ksm/ksm02.c | 6 ++----
testcases/kernel/mem/ksm/ksm04.c | 6 ++----
testcases/kernel/mem/lib/mem.c | 21 +++++++++++++--------
4 files changed, 19 insertions(+), 18 deletions(-)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-mm-fix-possible-node-missing-in-write_cpusets.patch --]
[-- Type: text/x-patch; name="0001-mm-fix-possible-node-missing-in-write_cpusets.patch", Size: 3902 bytes --]
diff --git a/testcases/kernel/mem/include/mem.h b/testcases/kernel/mem/include/mem.h
index 4319a90..b40c0bc 100644
--- a/testcases/kernel/mem/include/mem.h
+++ b/testcases/kernel/mem/include/mem.h
@@ -52,8 +52,8 @@ void check_ksm_options(int *size, int *num, int *unit);
void ksm_usage(void);
/* For mm/oom* and mm/ksm* tests*/
-void _gather_cpus(char *cpus);
-void write_cpusets(void);
+void _gather_cpus(char *cpus, long nd);
+void write_cpusets(long nd);
void umount_mem(char *path, char *path_new);
void mount_mem(char *name, char *fs, char *options, char *path, char *path_new);
diff --git a/testcases/kernel/mem/ksm/ksm02.c b/testcases/kernel/mem/ksm/ksm02.c
index 4cd1fab..7bed72b 100644
--- a/testcases/kernel/mem/ksm/ksm02.c
+++ b/testcases/kernel/mem/ksm/ksm02.c
@@ -85,7 +85,6 @@ int main(int argc, char *argv[])
int lc;
char *msg;
int size = 128, num = 3, unit = 1;
- unsigned long nnodes;
unsigned long nmask = 2;
long nodes[MAXNODES];
@@ -93,8 +92,7 @@ int main(int argc, char *argv[])
if (msg != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
- nnodes = count_numa(nodes);
- if (nnodes <= 1)
+ if (count_numa(nodes) <= 1)
tst_brkm(TCONF, NULL, "required a NUMA system.");
setup();
@@ -114,7 +112,7 @@ int main(int argc, char *argv[])
}
create_same_memory(size, num, unit);
- write_cpusets();
+ write_cpusets(nodes[1]);
create_same_memory(size, num, unit);
}
cleanup();
diff --git a/testcases/kernel/mem/ksm/ksm04.c b/testcases/kernel/mem/ksm/ksm04.c
index de76db7..2f97712 100644
--- a/testcases/kernel/mem/ksm/ksm04.c
+++ b/testcases/kernel/mem/ksm/ksm04.c
@@ -85,7 +85,6 @@ int main(int argc, char *argv[])
int lc;
char *msg;
int size = 128, num = 3, unit = 1;
- unsigned long nnodes;
unsigned long nmask = 2;
long nodes[MAXNODES];
@@ -93,8 +92,7 @@ int main(int argc, char *argv[])
if (msg != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
- nnodes = count_numa(nodes);
- if (nnodes <= 1)
+ if (count_numa(nodes) <= 1)
tst_brkm(TCONF, NULL, "required a NUMA system.");
setup();
@@ -116,7 +114,7 @@ int main(int argc, char *argv[])
}
create_same_memory(size, num, unit);
- write_cpusets();
+ write_cpusets(nodes[1]);
create_same_memory(size, num, unit);
}
cleanup();
diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
index 9a1d5f2..104fef7 100644
--- a/testcases/kernel/mem/lib/mem.c
+++ b/testcases/kernel/mem/lib/mem.c
@@ -101,8 +101,14 @@ void oom(int testcase, int mempolicy, int lite)
void testoom(int mempolicy, int lite, int numa)
{
- if (numa && !mempolicy)
- write_cpusets();
+ long nodes[MAXNODES];
+
+ if (numa && !mempolicy) {
+ if (count_numa(nodes) <= 1)
+ tst_brkm(TCONF, cleanup, "required a NUMA system.");
+ /* write cpusets to 2nd node */
+ write_cpusets(nodes[1]);
+ }
tst_resm(TINFO, "start normal OOM testing.");
oom(NORMAL, mempolicy, lite);
@@ -586,7 +592,7 @@ void ksm_usage(void)
/* For mm/oom* and mm/ksm* tests */
-void _gather_cpus(char *cpus)
+void _gather_cpus(char *cpus, long nd)
{
int ncpus = 0;
int i;
@@ -596,8 +602,7 @@ void _gather_cpus(char *cpus)
ncpus++;
for (i = 0; i < ncpus; i++)
- /* FIXME: possible non-existed node1 */
- if (path_exist(PATH_SYS_SYSTEM "/node/node1/cpu%d", i)) {
+ if (path_exist(PATH_SYS_SYSTEM "/node/node%ld/cpu%d", nd, i)) {
sprintf(buf, "%d,", i);
strcat(cpus, buf);
}
@@ -605,14 +610,14 @@ void _gather_cpus(char *cpus)
cpus[strlen(cpus) - 1] = '\0';
}
-void write_cpusets(void)
+void write_cpusets(long nd)
{
char cpus[BUFSIZ] = "";
char buf[BUFSIZ] = "";
int fd;
- _gather_cpus(cpus);
- tst_resm(TINFO, "CPU list for 2nd node is %s.", cpus);
+ _gather_cpus(cpus, nd);
+ tst_resm(TINFO, "CPU list for node%ld is: %s.", nd, cpus);
/*
* try either '/dev/cpuset/mems' or '/dev/cpuset/cpuset.mems'
[-- Attachment #3: Type: text/plain, Size: 377 bytes --]
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
[-- Attachment #4: Type: text/plain, Size: 155 bytes --]
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-02-21 2:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bb215812-518c-4d08-971d-7ed628347f4b@zmail13.collab.prod.int.phx2.redhat.com>
2012-02-21 2:44 ` [LTP] [PATCH 3/2] mm: fix possible node missing in write_cpusets Caspar Zhang
2012-02-20 10:55 [LTP] [PATCH 1/2] mm/lib: change count_numa() behavior Caspar Zhang
2012-02-20 12:21 ` [LTP] [PATCH 3/2] mm: fix possible node missing in write_cpusets Caspar Zhang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.