* 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 1/2] mm/lib: change count_numa() behavior @ 2012-02-20 10:55 Caspar Zhang 2012-02-20 12:21 ` [LTP] [PATCH 3/2] mm: fix possible node missing in write_cpusets Caspar Zhang 0 siblings, 1 reply; 2+ 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: 772 bytes --] 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(-) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-mm-lib-change-count_numa-behavior.patch --] [-- Type: text/x-patch; name="0001-mm-lib-change-count_numa-behavior.patch", Size: 1212 bytes --] diff --git a/testcases/kernel/mem/include/mem.h b/testcases/kernel/mem/include/mem.h index f86efab..d0d2507 100644 --- a/testcases/kernel/mem/include/mem.h +++ b/testcases/kernel/mem/include/mem.h @@ -58,7 +58,7 @@ void umount_mem(char *path, char *path_new); void mount_mem(char *name, char *fs, char *options, char *path, char *path_new); /* general function */ -long count_numa(void); +long count_numa(long nodes[]); int path_exist(const char *path, ...); long read_meminfo(char *item); void set_sys_tune(char *sys_file, long tune, int check); diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c index 6bfe0c1..c7188c2 100644 --- a/testcases/kernel/mem/lib/mem.c +++ b/testcases/kernel/mem/lib/mem.c @@ -707,16 +707,14 @@ void mount_mem(char *name, char *fs, char *options, char *path, char *path_new) /* general functions */ -long count_numa(void) +long count_numa(long nodes[]) { - int nnodes = 0; - int max_node; - int i; + long nnodes, i; - max_node = numa_max_node(); - for(i = 0; i <= max_node; i++) + nnodes = 0; + for (i = 0; i <= MAXNODES; i++) if(path_exist(PATH_SYS_SYSTEM "/node/node%d", i)) - nnodes++; + nodes[nnodes++] = i; return nnodes; } [-- 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
* [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 a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox