* [LTP] [PATCH 2/2] mm/ksm,oom: fix count_numa()
2012-02-20 10:55 [LTP] [PATCH 1/2] mm/lib: change count_numa() behavior Caspar Zhang
@ 2012-02-20 10:55 ` Caspar Zhang
2012-02-20 11:37 ` Caspar Zhang
2012-02-20 13:52 ` Zhouping Liu
2012-02-20 12:21 ` [LTP] [PATCH 3/2] mm: fix possible node missing in write_cpusets Caspar Zhang
` (5 subsequent siblings)
6 siblings, 2 replies; 10+ messages in thread
From: Caspar Zhang @ 2012-02-20 10:55 UTC (permalink / raw)
To: Zhouping Liu, LTP List
[-- Attachment #1: Type: text/plain, Size: 370 bytes --]
This patch makes ksm on oom tests use the new count_numa() function.
Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
---
testcases/kernel/mem/ksm/ksm02.c | 7 ++++---
testcases/kernel/mem/ksm/ksm04.c | 7 ++++---
testcases/kernel/mem/oom/oom02.c | 3 ++-
testcases/kernel/mem/oom/oom04.c | 5 +++--
4 files changed, 13 insertions(+), 9 deletions(-)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-mm-ksm-oom-fix-count_numa.patch --]
[-- Type: text/x-patch; name="0002-mm-ksm-oom-fix-count_numa.patch", Size: 2821 bytes --]
diff --git a/testcases/kernel/mem/ksm/ksm02.c b/testcases/kernel/mem/ksm/ksm02.c
index c7333c0..8f99063 100644
--- a/testcases/kernel/mem/ksm/ksm02.c
+++ b/testcases/kernel/mem/ksm/ksm02.c
@@ -85,15 +85,16 @@ int main(int argc, char *argv[])
int lc;
char *msg;
int size = 128, num = 3, unit = 1;
- unsigned long nnodes = 1;
+ unsigned long nnodes;
unsigned long nmask = 2;
+ long nodes[MAXNODES];
msg = parse_opts(argc, argv, ksm_options, ksm_usage);
if (msg != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
- nnodes = count_numa();
- if (count_numa() <= 1)
+ nnodes = count_numa(nodes);
+ if (nnodes <= 1)
tst_brkm(TCONF, NULL, "required a NUMA system.");
setup();
diff --git a/testcases/kernel/mem/ksm/ksm04.c b/testcases/kernel/mem/ksm/ksm04.c
index ff55c31..feb9502 100644
--- a/testcases/kernel/mem/ksm/ksm04.c
+++ b/testcases/kernel/mem/ksm/ksm04.c
@@ -85,15 +85,16 @@ int main(int argc, char *argv[])
int lc;
char *msg;
int size = 128, num = 3, unit = 1;
- unsigned long nnodes = 1;
+ unsigned long nnodes;
unsigned long nmask = 2;
+ long nodes[MAXNODES];
msg = parse_opts(argc, argv, ksm_options, ksm_usage);
if (msg != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
- nnodes = count_numa();
- if (count_numa() <= 1)
+ nnodes = count_numa(nodes);
+ if (nnodes <= 1)
tst_brkm(TCONF, NULL, "required a NUMA system.");
setup();
diff --git a/testcases/kernel/mem/oom/oom02.c b/testcases/kernel/mem/oom/oom02.c
index 585ffbf..2fa1c9d 100644
--- a/testcases/kernel/mem/oom/oom02.c
+++ b/testcases/kernel/mem/oom/oom02.c
@@ -49,6 +49,7 @@ int main(int argc, char *argv[])
char *msg;
int lc, fd;
unsigned long nnodes = 1;
+ long nodes[MAXNODES];
if ((msg = parse_opts(argc, argv, NULL, NULL)) != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
@@ -57,7 +58,7 @@ int main(int argc, char *argv[])
tst_brkm(TCONF, NULL, "test is not designed for 32-bit system.");
#endif
- nnodes = count_numa();
+ nnodes = count_numa(nodes);
if (nnodes <= 1)
tst_brkm(TCONF, NULL, "required a NUMA system.");
diff --git a/testcases/kernel/mem/oom/oom04.c b/testcases/kernel/mem/oom/oom04.c
index 724b55b..a3dd99f 100644
--- a/testcases/kernel/mem/oom/oom04.c
+++ b/testcases/kernel/mem/oom/oom04.c
@@ -49,6 +49,7 @@ int main(int argc, char *argv[])
char *msg;
int lc, fd;
unsigned long nnodes = 1;
+ long nodes[MAXNODES];
char buf[BUFSIZ], mem[BUFSIZ];
if ((msg = parse_opts(argc, argv, NULL, NULL)) != NULL)
@@ -58,8 +59,8 @@ int main(int argc, char *argv[])
tst_brkm(TCONF, NULL, "test is not designed for 32-bit system.");
#endif
- nnodes = count_numa();
- if (count_numa() <= 1)
+ nnodes = count_numa(nodes);
+ if (nnodes <= 1)
tst_brkm(TCONF, NULL, "required a NUMA system.");
setup();
[-- 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] 10+ messages in thread* Re: [LTP] [PATCH 2/2] mm/ksm,oom: fix count_numa()
2012-02-20 10:55 ` [LTP] [PATCH 2/2] mm/ksm,oom: fix count_numa() Caspar Zhang
@ 2012-02-20 11:37 ` Caspar Zhang
2012-02-20 13:52 ` Zhouping Liu
1 sibling, 0 replies; 10+ messages in thread
From: Caspar Zhang @ 2012-02-20 11:37 UTC (permalink / raw)
To: LTP List
On 02/20/2012 06:55 PM, Caspar Zhang wrote:
> This patch makes ksm on oom tests use the new count_numa() function.
oops, should be s/on/and. I've changed it in my local commit.
Caspar
------------------------------------------------------------------------------
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
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [LTP] [PATCH 2/2] mm/ksm,oom: fix count_numa()
2012-02-20 10:55 ` [LTP] [PATCH 2/2] mm/ksm,oom: fix count_numa() Caspar Zhang
2012-02-20 11:37 ` Caspar Zhang
@ 2012-02-20 13:52 ` Zhouping Liu
1 sibling, 0 replies; 10+ messages in thread
From: Zhouping Liu @ 2012-02-20 13:52 UTC (permalink / raw)
To: Caspar Zhang; +Cc: LTP List
----- Original Message -----
> From: "Caspar Zhang" <caspar@casparzhang.com>
> To: "Zhouping Liu" <zliu@redhat.com>, "LTP List" <ltp-list@lists.sourceforge.net>
> Sent: Monday, February 20, 2012 6:55:01 PM
> Subject: [PATCH 2/2] mm/ksm,oom: fix count_numa()
>
>
> This patch makes ksm on oom tests use the new count_numa() function.
>
> Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
> ---
> testcases/kernel/mem/ksm/ksm02.c | 7 ++++---
> testcases/kernel/mem/ksm/ksm04.c | 7 ++++---
> testcases/kernel/mem/oom/oom02.c | 3 ++-
> testcases/kernel/mem/oom/oom04.c | 5 +++--
> 4 files changed, 13 insertions(+), 9 deletions(-)
>
>
tested in my system, it's good.
thanks,
Zhouping
------------------------------------------------------------------------------
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
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 10+ 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 10:55 ` [LTP] [PATCH 2/2] mm/ksm,oom: fix count_numa() Caspar Zhang
@ 2012-02-20 12:21 ` Caspar Zhang
2012-02-20 12:38 ` [LTP] [PATCH 1/2] mm/lib: change count_numa() behavior Markos Chandras
` (4 subsequent siblings)
6 siblings, 0 replies; 10+ 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] 10+ messages in thread* Re: [LTP] [PATCH 1/2] mm/lib: change count_numa() behavior
2012-02-20 10:55 [LTP] [PATCH 1/2] mm/lib: change count_numa() behavior Caspar Zhang
2012-02-20 10:55 ` [LTP] [PATCH 2/2] mm/ksm,oom: fix count_numa() Caspar Zhang
2012-02-20 12:21 ` [LTP] [PATCH 3/2] mm: fix possible node missing in write_cpusets Caspar Zhang
@ 2012-02-20 12:38 ` Markos Chandras
2012-02-20 13:30 ` Zhouping Liu
` (3 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Markos Chandras @ 2012-02-20 12:38 UTC (permalink / raw)
To: ltp-list
On 02/20/2012 10:55 AM, Caspar Zhang wrote:
>
> this patch fixes two problems.
>
> 1) avoid using functions from numactl package, so compilation would pass
> w/ and w/o numactl development package installed.
>
> 2) count_numa() functions now has a parameter, which stores the array of
> each nodes on the system. This is because some systems doesn't have
> continuous nodes or the node sequence does not start from zero, when we
> want to test specific node, we should make sure the node does exist.
> Thus, an array for node numbers is necessary. Follow-up patches will
> update count_numa() with new parameters accordingly.
>
> Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
> ---
> testcases/kernel/mem/include/mem.h | 2 +-
> testcases/kernel/mem/lib/mem.c | 12 +++++-------
> 2 files changed, 6 insertions(+), 8 deletions(-)
That works for me (same for the other 2 patches of this series)
Tested-by: Markos Chandras <markos.chandras@imgtec.com>
--
markos
------------------------------------------------------------------------------
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
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [LTP] [PATCH 1/2] mm/lib: change count_numa() behavior
2012-02-20 10:55 [LTP] [PATCH 1/2] mm/lib: change count_numa() behavior Caspar Zhang
` (2 preceding siblings ...)
2012-02-20 12:38 ` [LTP] [PATCH 1/2] mm/lib: change count_numa() behavior Markos Chandras
@ 2012-02-20 13:30 ` Zhouping Liu
2012-02-21 3:05 ` [LTP] [PATCH 3/2 v2] mm: fix possible node missing in write_cpusets Caspar Zhang
` (2 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Zhouping Liu @ 2012-02-20 13:30 UTC (permalink / raw)
To: Caspar Zhang; +Cc: LTP List
hi,
>
> this patch fixes two problems.
>
> 1) avoid using functions from numactl package, so compilation would
> pass
> w/ and w/o numactl development package installed.
>
> 2) count_numa() functions now has a parameter, which stores the array
> of
> each nodes on the system. This is because some systems doesn't have
> continuous nodes or the node sequence does not start from zero, when
> we
> want to test specific node, we should make sure the node does exist.
> Thus, an array for node numbers is necessary. Follow-up patches will
> update count_numa() with new parameters accordingly.
>
> Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
> ---
> testcases/kernel/mem/include/mem.h | 2 +-
> testcases/kernel/mem/lib/mem.c | 12 +++++-------
> 2 files changed, 6 insertions(+), 8 deletions(-)
>
It's good for me.
Acked-by: Zhouping Liu <zliu@redhat.com>
Thanks,
Zhouping
------------------------------------------------------------------------------
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
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 10+ messages in thread* [LTP] [PATCH 3/2 v2] 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
` (3 preceding siblings ...)
2012-02-20 13:30 ` Zhouping Liu
@ 2012-02-21 3:05 ` Caspar Zhang
2012-02-21 3:06 ` [LTP] [PATCH 4/2] mem/lib: replace buf with path in correct place Caspar Zhang
2012-02-21 5:28 ` [LTP] [PATCH 1/2] mm/lib: change count_numa() behavior Caspar Zhang
6 siblings, 0 replies; 10+ messages in thread
From: Caspar Zhang @ 2012-02-21 3:05 UTC (permalink / raw)
To: LTP List
[-- Attachment #1: Type: text/plain, Size: 612 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 | 24 +++++++++++++++---------
4 files changed, 21 insertions(+), 19 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: 4198 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..337833a 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'
@@ -628,7 +633,8 @@ void write_cpusets(void)
} else
tst_brkm(TBROK|TERRNO, cleanup, "open %s", buf);
}
- if (write(fd, "1", 1) != 1)
+ snprintf(buf, BUFSIZ, "%ld", nd);
+ if (write(fd, buf, strlen(buf)) != strlen(buf))
tst_brkm(TBROK|TERRNO, cleanup, "write %s", buf);
close(fd);
[-- Attachment #3: Type: text/plain, Size: 381 bytes --]
------------------------------------------------------------------------------
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
[-- 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] 10+ messages in thread* [LTP] [PATCH 4/2] mem/lib: replace buf with path in correct place
2012-02-20 10:55 [LTP] [PATCH 1/2] mm/lib: change count_numa() behavior Caspar Zhang
` (4 preceding siblings ...)
2012-02-21 3:05 ` [LTP] [PATCH 3/2 v2] mm: fix possible node missing in write_cpusets Caspar Zhang
@ 2012-02-21 3:06 ` Caspar Zhang
2012-02-21 5:28 ` [LTP] [PATCH 1/2] mm/lib: change count_numa() behavior Caspar Zhang
6 siblings, 0 replies; 10+ messages in thread
From: Caspar Zhang @ 2012-02-21 3:06 UTC (permalink / raw)
To: LTP List
[-- Attachment #1: Type: text/plain, Size: 336 bytes --]
some `buf` vars are used in mem/lib w/o initialized, in fact the `path`
vars to the files that to be opened/written/closed should be used here.
Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
---
testcases/kernel/mem/lib/mem.c | 53 ++++++++++++++++++++++++----------------
1 files changed, 32 insertions(+), 21 deletions(-)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-mem-lib-replace-buf-with-path-in-correct-place.patch --]
[-- Type: text/x-patch; name="0001-mem-lib-replace-buf-with-path-in-correct-place.patch", Size: 3865 bytes --]
diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
index 337833a..752fe2c 100644
--- a/testcases/kernel/mem/lib/mem.c
+++ b/testcases/kernel/mem/lib/mem.c
@@ -211,22 +211,25 @@ void _verify(char value, int proc, int start, int end, int start2, int end2)
void write_memcg(void)
{
int fd;
- char buf[BUFSIZ], mem[BUFSIZ];
+ char buf[BUFSIZ], mem[BUFSIZ], path[BUFSIZ];
- fd = open(MEMCG_PATH_NEW "/memory.limit_in_bytes", O_WRONLY);
+ snprintf(path, BUFSIZ, "%s%s",
+ MEMCG_PATH_NEW, "/memory.limit_in_bytes");
+ fd = open(path, O_WRONLY);
if (fd == -1)
- tst_brkm(TBROK|TERRNO, cleanup, "open %s", buf);
+ tst_brkm(TBROK|TERRNO, cleanup, "open %s", path);
sprintf(mem, "%ld", TESTMEM);
if (write(fd, mem, strlen(mem)) != strlen(mem))
- tst_brkm(TBROK|TERRNO, cleanup, "write %s", buf);
+ tst_brkm(TBROK|TERRNO, cleanup, "write %s", path);
close(fd);
- fd = open(MEMCG_PATH_NEW "/tasks", O_WRONLY);
+ snprintf(path, BUFSIZ, "%s%s", MEMCG_PATH_NEW, "/tasks");
+ fd = open(path, O_WRONLY);
if (fd == -1)
- tst_brkm(TBROK|TERRNO, cleanup, "open %s", buf);
+ tst_brkm(TBROK|TERRNO, cleanup, "open %s", path);
snprintf(buf, BUFSIZ, "%d", getpid());
if (write(fd, buf, strlen(buf)) != strlen(buf))
- tst_brkm(TBROK|TERRNO, cleanup, "write %s", buf);
+ tst_brkm(TBROK|TERRNO, cleanup, "write %s", path);
close(fd);
}
@@ -612,8 +615,7 @@ void _gather_cpus(char *cpus, long nd)
void write_cpusets(long nd)
{
- char cpus[BUFSIZ] = "";
- char buf[BUFSIZ] = "";
+ char cpus[BUFSIZ], buf[BUFSIZ], path[BUFSIZ];
int fd;
_gather_cpus(cpus, nd);
@@ -624,18 +626,22 @@ void write_cpusets(long nd)
* please see Documentation/cgroups/cpusets.txt from kernel src
* for details
*/
- fd = open(CPATH_NEW "/mems", O_WRONLY);
+ snprintf(path, BUFSIZ, "%s%s", CPATH_NEW, "/mems");
+ fd = open(path, O_WRONLY);
if (fd == -1) {
if (errno == ENOENT) {
- fd = open(CPATH_NEW "/cpuset.mems", O_WRONLY);
+ snprintf(path, BUFSIZ, "%s%s",
+ CPATH_NEW, "/cpuset.mems");
+ fd = open(path, O_WRONLY);
if (fd == -1)
- tst_brkm(TBROK|TERRNO, cleanup, "open %s", buf);
+ tst_brkm(TBROK|TERRNO, cleanup,
+ "open %s", path);
} else
- tst_brkm(TBROK|TERRNO, cleanup, "open %s", buf);
+ tst_brkm(TBROK|TERRNO, cleanup, "open %s", path);
}
snprintf(buf, BUFSIZ, "%ld", nd);
if (write(fd, buf, strlen(buf)) != strlen(buf))
- tst_brkm(TBROK|TERRNO, cleanup, "write %s", buf);
+ tst_brkm(TBROK|TERRNO, cleanup, "write %s", path);
close(fd);
/*
@@ -643,25 +649,30 @@ void write_cpusets(long nd)
* please see Documentation/cgroups/cpusets.txt from kernel src
* for details
*/
- fd = open(CPATH_NEW "/cpus", O_WRONLY);
+ snprintf(path, BUFSIZ, "%s%s", CPATH_NEW, "/cpus");
+ fd = open(path, O_WRONLY);
if (fd == -1) {
if (errno == ENOENT) {
+ snprintf(path, BUFSIZ, "%s%s",
+ CPATH_NEW, "/cpuset.cpus");
fd = open(CPATH_NEW "/cpuset.cpus", O_WRONLY);
if (fd == -1)
- tst_brkm(TBROK|TERRNO, cleanup, "open %s", buf);
+ tst_brkm(TBROK|TERRNO, cleanup,
+ "open %s", path);
} else
- tst_brkm(TBROK|TERRNO, cleanup, "open %s", buf);
+ tst_brkm(TBROK|TERRNO, cleanup, "open %s", path);
}
if (write(fd, cpus, strlen(cpus)) != strlen(cpus))
- tst_brkm(TBROK|TERRNO, cleanup, "write %s", buf);
+ tst_brkm(TBROK|TERRNO, cleanup, "write %s", path);
close(fd);
- fd = open(CPATH_NEW "/tasks", O_WRONLY);
+ snprintf(path, BUFSIZ, "%s%s", CPATH_NEW, "/tasks");
+ fd = open(path, O_WRONLY);
if (fd == -1)
- tst_brkm(TBROK|TERRNO, cleanup, "open %s", buf);
+ tst_brkm(TBROK|TERRNO, cleanup, "open %s", path);
snprintf(buf, BUFSIZ, "%d", getpid());
if (write(fd, buf, strlen(buf)) != strlen(buf))
- tst_brkm(TBROK|TERRNO, cleanup, "write %s", buf);
+ tst_brkm(TBROK|TERRNO, cleanup, "write %s", path);
close(fd);
}
[-- Attachment #3: Type: text/plain, Size: 381 bytes --]
------------------------------------------------------------------------------
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
[-- 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] 10+ messages in thread* Re: [LTP] [PATCH 1/2] mm/lib: change count_numa() behavior
2012-02-20 10:55 [LTP] [PATCH 1/2] mm/lib: change count_numa() behavior Caspar Zhang
` (5 preceding siblings ...)
2012-02-21 3:06 ` [LTP] [PATCH 4/2] mem/lib: replace buf with path in correct place Caspar Zhang
@ 2012-02-21 5:28 ` Caspar Zhang
6 siblings, 0 replies; 10+ messages in thread
From: Caspar Zhang @ 2012-02-21 5:28 UTC (permalink / raw)
To: LTP List
On 02/20/2012 06:55 PM, Caspar Zhang wrote:
>
> this patch fixes two problems.
>
> 1) avoid using functions from numactl package, so compilation would pass
> w/ and w/o numactl development package installed.
>
> 2) count_numa() functions now has a parameter, which stores the array of
> each nodes on the system. This is because some systems doesn't have
> continuous nodes or the node sequence does not start from zero, when we
> want to test specific node, we should make sure the node does exist.
> Thus, an array for node numbers is necessary. Follow-up patches will
> update count_numa() with new parameters accordingly.
>
> Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
> ---
> testcases/kernel/mem/include/mem.h | 2 +-
> testcases/kernel/mem/lib/mem.c | 12 +++++-------
> 2 files changed, 6 insertions(+), 8 deletions(-)
>
FYI. the patch series has been tested on several systems and confirmed
to be working. Thanks for reviewing. Committed.
Thanks,
Caspar
------------------------------------------------------------------------------
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] 10+ messages in thread