Subrata Modak wrote:
> Hi Suzuki,
>
> Can you kindly review Vijay´s design and explore ways to collaborate on
> this.
[clip]
>> 2) Vijay can go ahead in writing those tests that he has proposed. You
>> can review his patches then,
I have implemented 3 test cases. I thought I would post them up, to
get review comments. I am continuing with implementing rest of the cases
as well.
I have tested them on x86_64 system with 2 fake NUMA nodes.
The patch will probably break builds in systems that do not have libnuma.
There is a script in testcases/kernel/numa/test.sh that checks if numa
support is available. Do we replicate it over here? I guess the best
approach would be to test for NUMA support in the toplevel Makefile and
pass the result to all other Makefiles.
Vijay
Index: ltp-stripped/testcases/kernel/syscalls/move_pages/Makefile
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ ltp-stripped/testcases/kernel/syscalls/move_pages/Makefile 2008-06-15
19:19:20.000000000 +0530
@@ -0,0 +1,35 @@
+#
+# Copyright (c) International Business Machines Corp., 2001
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+# the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+CFLAGS += -I../../../../include -Wall
+LDLIBS += -L../../../../lib -lltp -lnuma
+
+SRCS = $(wildcard *.c)
+TARGETS = $(patsubst %.c, %, $(wildcard *[0-9].c))
+
+all: $(TARGETS)
+
+move_pages_support.o: move_pages_support.h move_pages_support.c
+
+$(TARGETS): move_pages_support.o
+
+install:
+ @set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+
+clean:
+ rm -f $(TARGETS)
Index: ltp-stripped/testcases/kernel/syscalls/move_pages/move_pages01.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ ltp-stripped/testcases/kernel/syscalls/move_pages/move_pages01.c
2008-06-18 09:38:56.000000000 +0530
@@ -0,0 +1,147 @@
+/*
+ *
+ * Copyright (c) International Business Machines Corp., 2001
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * NAME
+ * move_pages01.c
+ *
+ * DESCRIPTION
+ * Test retrieval of NUMA node
+ *
+ * ALGORITHM
+ * 1. Allocate pages in NUMA nodes A and B.
+ * 2. Use move_pages() to retrieve the NUMA node of the pages.
+ * 3. Check if the NUMA nodes reported are correct.
+ *
+ * USAGE: <for command-line>
+ * move_pages01 [-c n] [-i n] [-I x] [-P x] [-t]
+ * where, -c n : Run n copies concurrently.
+ * -i n : Execute test n times.
+ * -I x : Execute test for x seconds.
+ * -P x : Pause for x seconds between iterations.
+ * -t : Turn on syscall timing.
+ *
+ * History
+ * 05/2008 Vijay Kumar
+ * Initial Version.
+ *
+ * Restrictions
+ * None
+ */
+
+#include <sys/signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <errno.h>
+#include <numa.h>
+
+#include <test.h>
+#include <usctest.h>
+
+#include "move_pages_support.h"
+
+#define TEST_PAGES 2
+#define TEST_NODES TEST_PAGES
+
+void setup(void);
+void cleanup(void);
+
+char *TCID = "move_pages01";
+int TST_TOTAL = 1;
+extern int Tst_count;
+
+int main(int argc, char **argv)
+{
+ int lc; /* loop counter */
+ char *msg; /* message returned from parse_opts */
+
+ /* parse standard options */
+ msg = parse_opts(argc, argv, (option_t *) NULL, NULL);
+ if (msg != NULL) {
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ tst_exit();
+ /* NOTREACHED */
+ }
+
+ setup();
+
+ /* check for looping state if -i option is given */
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+ void *pages[TEST_PAGES] = { 0 };
+ int status[TEST_PAGES];
+ int ret;
+
+ /* reset Tst_count in case we are looping */
+ Tst_count = 0;
+
+ ret = alloc_pages_linear(pages, TEST_PAGES);
+ if (ret == -1)
+ continue;
+
+ ret = numa_move_pages(0, TEST_PAGES, pages, NULL, status, 0);
+ TEST_ERRNO = errno;
+ if (ret != 0) {
+ tst_resm(TFAIL, "retrieving NUMA nodes failed");
+ free_pages(pages, TEST_PAGES);
+ continue;
+ }
+
+ verify_pages_linear(status, TEST_PAGES);
+
+ free_pages(pages, TEST_PAGES);
+ }
+
+ cleanup();
+ /* NOT REACHED */
+
+ return 0;
+}
+
+/*
+ * setup() - performs all ONE TIME setup for this test
+ */
+void
+setup(void)
+{
+ /* capture signals */
+ tst_sig(NOFORK, DEF_HANDLER, cleanup);
+
+ check_numa(TEST_NODES);
+ /* Pause if that option was specified
+ * TEST_PAUSE contains the code to fork the test with the -c option.
+ */
+ TEST_PAUSE;
+}
+
+/*
+ * cleanup() - performs all ONE TIME cleanup for this test
+ */
+void
+cleanup(void)
+{
+ /*
+ * print timing stats if that option was specified.
+ * print errno log if that option was specified.
+ */
+ TEST_CLEANUP;
+
+ /* exit with return code appropriate for results */
+ tst_exit();
+ /*NOTREACHED*/
+}
Index: ltp-stripped/testcases/kernel/syscalls/move_pages/move_pages02.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ ltp-stripped/testcases/kernel/syscalls/move_pages/move_pages02.c
2008-06-18 09:39:26.000000000 +0530
@@ -0,0 +1,157 @@
+/*
+ *
+ * Copyright (c) International Business Machines Corp., 2001
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * NAME
+ * move_pages02.c
+ *
+ * DESCRIPTION
+ * Test movement of pages mapped by a process.
+ *
+ * ALGORITHM
+ * 1. Allocate pages in NUMA node A.
+ * 2. Use move_pages() to move the pages to NUMA node B.
+ * 3. Retrieve the NUMA nodes of the moved pages.
+ * 4. Check if all pages are in node B.
+ *
+ * USAGE: <for command-line>
+ * move_pages02 [-c n] [-i n] [-I x] [-P x] [-t]
+ * where, -c n : Run n copies concurrently.
+ * -i n : Execute test n times.
+ * -I x : Execute test for x seconds.
+ * -P x : Pause for x seconds between iterations.
+ * -t : Turn on syscall timing.
+ *
+ * History
+ * 05/2008 Vijay Kumar
+ * Initial Version.
+ *
+ * Restrictions
+ * None
+ */
+
+#include <sys/signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <linux/mempolicy.h>
+#include <errno.h>
+#include <numa.h>
+
+#include <test.h>
+#include <usctest.h>
+
+#include "move_pages_support.h"
+
+#define TEST_PAGES 2
+#define TEST_NODES 2
+
+void setup(void);
+void cleanup(void);
+
+char *TCID = "move_pages02";
+int TST_TOTAL = 1;
+extern int Tst_count;
+
+int main(int argc, char **argv)
+{
+ unsigned int i;
+ int lc; /* loop counter */
+ char *msg; /* message returned from parse_opts */
+ unsigned int from_node = 0;
+ unsigned int to_node = 1;
+
+ /* parse standard options */
+ msg = parse_opts(argc, argv, (option_t *) NULL, NULL);
+ if (msg != NULL) {
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ tst_exit();
+ /* NOTREACHED */
+ }
+
+ setup();
+
+ /* check for looping state if -i option is given */
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+ void *pages[TEST_PAGES] = { 0 };
+ int nodes[TEST_PAGES];
+ int status[TEST_PAGES];
+ int ret;
+
+ /* reset Tst_count in case we are looping */
+ Tst_count = 0;
+
+ ret = alloc_pages_on_node(pages, TEST_PAGES, from_node);
+ if (ret == -1)
+ continue;
+
+ for (i = 0; i < TEST_PAGES; i++)
+ nodes[i] = to_node;
+
+ ret = numa_move_pages(0, TEST_PAGES, pages, nodes, status,
MPOL_MF_MOVE);
+ TEST_ERRNO = errno;
+ if (ret != 0) {
+ tst_resm(TFAIL, "retrieving NUMA nodes failed");
+ free_pages(pages, TEST_PAGES);
+ continue;
+ }
+
+ verify_pages_on_node(status, TEST_PAGES, to_node);
+
+ free_pages(pages, TEST_PAGES);
+ }
+
+ cleanup();
+ /* NOT REACHED */
+
+ return 0;
+}
+
+/*
+ * setup() - performs all ONE TIME setup for this test
+ */
+void
+setup(void)
+{
+ /* capture signals */
+ tst_sig(NOFORK, DEF_HANDLER, cleanup);
+
+ check_numa(TEST_NODES);
+
+ /* Pause if that option was specified
+ * TEST_PAUSE contains the code to fork the test with the -c option.
+ */
+ TEST_PAUSE;
+}
+
+/*
+ * cleanup() - performs all ONE TIME cleanup for this test at completion
+ */
+void
+cleanup(void)
+{
+ /*
+ * print timing stats if that option was specified.
+ * print errno log if that option was specified.
+ */
+ TEST_CLEANUP;
+
+ /* exit with return code appropriate for results */
+ tst_exit();
+ /*NOTREACHED*/
+}
Index: ltp-stripped/testcases/kernel/syscalls/move_pages/move_pages03.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ ltp-stripped/testcases/kernel/syscalls/move_pages/move_pages03.c
2008-06-18 10:20:10.000000000 +0530
@@ -0,0 +1,207 @@
+/*
+ *
+ * Copyright (c) International Business Machines Corp., 2001
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * NAME
+ * move_pages03.c
+ *
+ * DESCRIPTION
+ * Test movement of pages mapped by a process.
+ *
+ * ALGORITHM
+ * 1. Allocate pages in NUMA node A.
+ * 2. Use move_pages() to move the pages to NUMA node B.
+ * 3. Retrieve the NUMA nodes of the moved pages.
+ * 4. Check if all pages are in node B.
+ *
+ * USAGE: <for command-line>
+ * move_pages03 [-c n] [-i n] [-I x] [-P x] [-t]
+ * where, -c n : Run n copies concurrently.
+ * -i n : Execute test n times.
+ * -I x : Execute test for x seconds.
+ * -P x : Pause for x seconds between iterations.
+ * -t : Turn on syscall timing.
+ *
+ * History
+ * 05/2008 Vijay Kumar
+ * Initial Version.
+ *
+ * Restrictions
+ * None
+ */
+
+#include <linux/mempolicy.h>
+
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <signal.h>
+#include <errno.h>
+#include <numa.h>
+
+#include <test.h>
+#include <usctest.h>
+
+#include "move_pages_support.h"
+
+#define TEST_PAGES 2
+#define TEST_NODES 2
+
+void setup(void);
+void cleanup(void);
+
+char *TCID = "move_pages03";
+int TST_TOTAL = 1;
+extern int Tst_count;
+
+typedef void (*sighandler_t)(int);
+
+/*
+ * child() - touches shared pages, and waits for signal from parent.
+ * @pages: shared pages allocated in parent
+ */
+void child(void **pages)
+{
+ sighandler_t sigret;
+ int i;
+
+ for (i = 0; i < TEST_PAGES; i++) {
+ char *page;
+
+ page = pages[i];
+ page[0] = 0xAA;
+ }
+
+ /* Remove the parent's SIGTERM handler if any. */
+ sigret = signal(SIGTERM, SIG_DFL);
+ if (sigret == SIG_ERR)
+ tst_resm(TBROK, "resetting SIGTERM handler failed");
+
+ /* Wait for SIGTERM. */
+ pause();
+
+ exit(0);
+}
+
+int main(int argc, char **argv)
+{
+ unsigned int i;
+ int lc; /* loop counter */
+ char *msg; /* message returned from parse_opts */
+ unsigned int from_node = 0;
+ unsigned int to_node = 1;
+
+ /* parse standard options */
+ msg = parse_opts(argc, argv, (option_t *) NULL, NULL);
+ if (msg != NULL) {
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ tst_exit();
+ /* NOTREACHED */
+ }
+
+ setup();
+
+ /* check for looping state if -i option is given */
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+ void *pages[TEST_PAGES] = { 0 };
+ int nodes[TEST_PAGES];
+ int status[TEST_PAGES];
+ int ret;
+ pid_t cpid;
+
+ /* reset Tst_count in case we are looping */
+ Tst_count = 0;
+
+ ret = alloc_shared_pages_on_node(pages, TEST_PAGES,
+ from_node);
+ if (ret == -1)
+ continue;
+
+
+ for (i = 0; i < TEST_PAGES; i++) {
+ nodes[i] = to_node;
+ }
+
+ /*
+ * Fork a child process so that the shared pages are
+ * now really shared between two processes.
+ */
+ cpid = fork();
+ if (cpid == -1) {
+ tst_resm(TBROK, "forking child failed");
+ goto err_free_pages;
+ } else if (cpid == 0) {
+ child(pages);
+ }
+
+ ret = numa_move_pages(0, TEST_PAGES, pages, nodes,
+ status, MPOL_MF_MOVE_ALL);
+ TEST_ERRNO = errno;
+ if (ret != 0) {
+ tst_resm(TFAIL, "retrieving NUMA nodes failed");
+ goto err_kill_child;
+ }
+
+ verify_pages_on_node(status, TEST_PAGES, to_node);
+
+ err_kill_child:
+ kill(cpid, SIGCHLD);
+ err_free_pages:
+ free_shared_pages(pages, TEST_PAGES);
+ }
+
+ cleanup();
+ /* NOT REACHED */
+
+ return 0;
+}
+
+/*
+ * setup() - performs all ONE TIME setup for this test
+ */
+void
+setup(void)
+{
+ /* capture signals */
+ tst_sig(FORK, DEF_HANDLER, cleanup);
+
+ check_numa(TEST_NODES);
+
+ /* Pause if that option was specified
+ * TEST_PAUSE contains the code to fork the test with the -c option.
+ */
+ TEST_PAUSE;
+}
+
+/*
+ * cleanup() - performs all ONE TIME cleanup for this test at completion
+ */
+void
+cleanup(void)
+{
+ /*
+ * print timing stats if that option was specified.
+ * print errno log if that option was specified.
+ */
+ TEST_CLEANUP;
+
+ /* exit with return code appropriate for results */
+ tst_exit();
+ /*NOTREACHED*/
+}
Index: ltp-stripped/testcases/kernel/syscalls/move_pages/move_pages_support.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ ltp-stripped/testcases/kernel/syscalls/move_pages/move_pages_support.c
2008-06-18 10:05:38.000000000 +0530
@@ -0,0 +1,275 @@
+#include <sys/mman.h>
+#include <linux/mempolicy.h>
+#include <syscall.h>
+#include <unistd.h>
+#include <numa.h>
+
+#include <test.h>
+#include <usctest.h>
+
+long
+get_page_size()
+{
+ return sysconf(_SC_PAGESIZE);
+}
+
+/*
+ * free_pages() - free an array of pages
+ * @pages: array of page pointers to be freed
+ * @num: no. of pages in the array
+ */
+void
+free_pages(void **pages, unsigned int num)
+{
+ int i;
+ size_t onepage = get_page_size();
+
+ for (i = 0; i < num; i++) {
+ if (pages[i] != NULL) {
+ numa_free(pages[i], onepage);
+ }
+ }
+}
+
+/*
+ * alloc_pages_on_node() - allocate pages on specified NUMA nodes
+ * @pages: array in which the page pointers will be stored
+ * @num: no. of pages to allocate
+ * @nodes: array of NUMA nodes
+ *
+ * A page will be allocated in each node specified by @nodes, and the
+ * page pointers will be stored in @pages array.
+ *
+ * RETURNS:
+ * 0 on success, -1 on allocation failure.
+ */
+int
+alloc_pages_on_nodes(void **pages, unsigned int num, int *nodes)
+{
+ int i;
+ size_t onepage = get_page_size();
+
+ for (i = 0; i < num; i++) {
+ pages[i] = NULL;
+ }
+
+ for (i = 0; i < num; i++) {
+ char *page;
+
+ pages[i] = numa_alloc_onnode(onepage, nodes[i]);
+ if (pages[i] == NULL) {
+ tst_resm(TBROK, "allocation of page on node "
+ "%d failed", nodes[i]);
+ break;
+ }
+
+ /* Touch the page, to force allocation. */
+ page = pages[i];
+ page[0] = i;
+ }
+
+ if (i == num)
+ return 0;
+
+ free_pages(pages, num);
+
+ return -1;
+}
+
+/*
+ * alloc_pages_linear() - allocate pages in each NUMA node
+ * @pages: array in which the page pointers will be stored
+ * @num: no. of pages to allocate
+ *
+ * Pages will be allocated one from each NUMA node, in an interleaved
+ * fashion.
+ *
+ * RETURNS:
+ * 0 on success, -1 on allocation failure.
+ */
+int
+alloc_pages_linear(void **pages, unsigned int num)
+{
+ unsigned int i;
+ unsigned int n;
+ int nodes[num];
+
+ n = 0;
+ for (i = 0; i < num; i++) {
+ nodes[i] = n;
+
+ n++;
+ if (n > numa_max_node())
+ n = 0;
+ }
+
+ return alloc_pages_on_nodes(pages, num, nodes);
+}
+
+/*
+ * alloc_pages_on_node() - allocate pages on specified NUMA node
+ * @pages: array in which the page pointers will be stored
+ * @num: no. of pages to allocate
+ * @node: NUMA node from which to allocate pages
+ *
+ * Pages will be allocated from the NUMA node @node, and the page
+ * pointers will be stored in the @pages array.
+ *
+ * RETURNS:
+ * 0 on success, -1 on allocation failure.
+ */
+int
+alloc_pages_on_node(void **pages, unsigned int num, int node)
+{
+ unsigned int i;
+ int nodes[num];
+
+ for (i = 0; i < num; i++)
+ nodes[i] = node;
+
+ return alloc_pages_on_nodes(pages, num, nodes);
+}
+
+/*
+ * verify_pages_on_nodes() - verify pages are in specified nodes
+ * @status: the NUMA node of each page
+ * @num: the no. of pages
+ * @nodes: the expected NUMA nodes
+ */
+void
+verify_pages_on_nodes(int *status, unsigned int num, int *nodes)
+{
+ unsigned int i;
+
+ for (i = 0; i < num; i++) {
+ if (status[i] != nodes[i]) {
+ tst_resm(TFAIL, "page %d on node %d, "
+ "expected on node %d", i,
+ status[i], nodes[i]);
+ return;
+ }
+ }
+
+ tst_resm(TPASS, "pages are present in expected nodes");
+}
+
+/*
+ * verify_pages_linear() - verify pages are interleaved
+ * @status: the NUMA node of each page
+ * @num: the no. of pages
+ */
+void
+verify_pages_linear(int *status, unsigned int num)
+{
+ unsigned int i;
+ unsigned int n;
+ int nodes[num];
+
+ n = 0;
+ for (i = 0; i < num; i++) {
+ nodes[i] = i;
+
+ n++;
+ if (n > numa_max_node())
+ n = 0;
+ }
+
+ verify_pages_on_nodes(status, num, nodes);
+}
+
+/*
+ * verify_pages_on_node() - verify pages are in specified node
+ * @status: the NUMA node of each page
+ * @num: the no. of pages
+ * @node: the expected NUMA node
+ */
+void
+verify_pages_on_node(int *status, unsigned int num, int node)
+{
+ unsigned int i;
+ int nodes[num];
+
+ for (i = 0; i < num; i++) {
+ nodes[i] = node;
+ }
+
+ verify_pages_on_nodes(status, num, nodes);
+}
+
+/*
+ * alloc_shared_pages_on_node() - allocate shared pages on a NUMA node
+ * @pages: array to store the allocated pages
+ * @num: the no. of pages to allocate
+ * @node: the node in which the pages should be allocated
+ *
+ * RETURNS:
+ * 0 on success, -1 on allocation failure
+ */
+int
+alloc_shared_pages_on_node(void **pages, unsigned int num,
+ int node)
+{
+ char *shared;
+ unsigned int i;
+ int nodes[num];
+ size_t total_size = num * get_page_size();
+
+ shared = mmap(NULL, total_size,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED | MAP_ANONYMOUS, 0, 0);
+ if (shared == MAP_FAILED) {
+ tst_resm(TBROK, "allocation of shared pages failed");
+ return -1;
+ }
+
+ numa_tonode_memory(shared, total_size, node);
+
+ for (i = 0; i < num; i++) {
+ char *page;
+
+ pages[i] = shared;
+ shared += get_page_size();
+
+ nodes[i] = node;
+
+ /* Touch the page to force allocation */
+ page = pages[i];
+ page[0] = i;
+ }
+
+ return 0;
+}
+
+/*
+ * free_shared_pages() - free shared pages
+ * @pages: array of pages to be freed
+ * @num: the no. of pages to free
+ */
+void
+free_shared_pages(void **pages, unsigned int num)
+{
+ int ret;
+
+ ret = munmap(pages[0], num * get_page_size());
+ if (ret == -1)
+ tst_resm(TWARN, "unmapping of shared pages failed");
+}
+
+/*
+ * check_numa() - check if min. no. of NUMA nodes are available
+ * @min_nodes: the minimum required NUMA nodes
+ */
+void
+check_numa(unsigned int min_nodes)
+{
+ if (numa_available() < 0) {
+ tst_resm(TCONF, "NUMA support is not available");
+ tst_exit();
+ }
+
+ if (numa_max_node() < (min_nodes - 1)) {
+ tst_resm(TCONF, "atleast 2 NUMA nodes are required");
+ tst_exit();
+ }
+}
+
Index: ltp-stripped/testcases/kernel/syscalls/move_pages/move_pages_support.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ ltp-stripped/testcases/kernel/syscalls/move_pages/move_pages_support.h
2008-06-18 10:06:54.000000000 +0530
@@ -0,0 +1,17 @@
+long get_page_size();
+
+void free_pages(void **pages, unsigned int num);
+
+int alloc_pages_on_nodes(void **pages, unsigned int num, unsigned int *nodes);
+int alloc_pages_linear(void **pages, unsigned int num);
+int alloc_pages_on_node(void **pages, unsigned int num, unsigned int node);
+
+void verify_pages_on_nodes(int *status, unsigned int num, unsigned int *nodes);
+void verify_pages_linear(int *status, unsigned int num);
+void verify_pages_on_node(int *status, unsigned int num, unsigned int node);
+
+int alloc_shared_pages_on_node(void **pages, unsigned int num,
+ unsigned int node);
+void free_shared_pages(void **pages, unsigned int num);
+
+void check_numa(unsigned int min_nodes);
Index: ltp-stripped/runtest/numa
===================================================================
--- ltp-stripped.orig/runtest/numa 2008-06-18 10:19:33.000000000 +0530
+++ ltp-stripped/runtest/numa 2008-06-18 10:19:57.000000000 +0530
@@ -1 +1,4 @@
Numa-testcases numa01.sh
+move_pages01 move_pages01
+move_pages02 move_pages02
+move_pages03 move_pages03
Index: ltp-stripped/runtest/syscalls
===================================================================
--- ltp-stripped.orig/runtest/syscalls 2008-06-18 10:16:52.000000000 +0530
+++ ltp-stripped/runtest/syscalls 2008-06-18 10:18:59.000000000 +0530
@@ -445,6 +445,10 @@
#mount03 mount03 -D /dev/...
#mount04 mount04 -D /dev/...
+move_pages01 move_pages01
+move_pages02 move_pages02
+move_pages03 move_pages03
+
mprotect01 mprotect01
mprotect02 mprotect02
mprotect03 mprotect03
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list