int main(int argc, char **argv) { char *msg; msg = parse_opts(argc, argv, NULL, NULL); if (msg != NULL) { tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); } setup(); #if HAVE_NUMA_MOVE_PAGES unsigned int i; int lc; unsigned int from_node; unsigned int to_node; int ret; ret = get_allowed_nodes(NH_MEMS, 1, &from_node); if (ret < 0) tst_brkm(TBROK | TERRNO, cleanup, "get_allowed_nodes: %d", ret); /* 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]; /* 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; to_node = numa_max_node() + 1; 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 == -1 && errno == ENODEV) tst_resm(TPASS, "move_pages failed with " "ENODEV as expected"); else tst_resm(TFAIL, "move pages did not fail " "with ENODEV"); free_pages(pages, TEST_PAGES); } #else tst_resm(TCONF, "move_pages support not found."); #endif cleanup(); tst_exit(); }
int main(int argc, char **argv) { 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(); #if HAVE_NUMA_MOVE_PAGES unsigned int i; int lc; /* loop counter */ unsigned int from_node = 0; unsigned int to_node = 1; /* 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, ULONG_MAX, pages, nodes, status, MPOL_MF_MOVE); TEST_ERRNO = errno; if (ret == -1 && errno == E2BIG) tst_resm(TPASS, "move_pages failed with " "E2BIG as expected"); else tst_resm(TFAIL, "move pages did not fail " "with E2BIG"); free_pages(pages, TEST_PAGES); } #else tst_resm(TCONF, "move_pages support not found."); #endif cleanup(); /* NOT REACHED */ return 0; }
int main(int argc, char **argv) { tst_parse_opts(argc, argv, NULL, NULL); setup(); #if HAVE_NUMA_MOVE_PAGES unsigned int i; int lc; unsigned int from_node; unsigned int to_node; int ret; ret = get_allowed_nodes(NH_MEMS, 2, &from_node, &to_node); if (ret < 0) tst_brkm(TBROK | TERRNO, cleanup, "get_allowed_nodes: %d", ret); /* 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]; /* 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); if (ret != 0) { tst_resm(TFAIL|TERRNO, "move_pages failed"); free_pages(pages, TEST_PAGES); continue; } for (i = 0; i < TEST_PAGES; i++) *((char *)pages[i]) = 0xAA; verify_pages_on_node(pages, status, TEST_PAGES, to_node); free_pages(pages, TEST_PAGES); } #else tst_resm(TCONF, "move_pages support not found."); #endif cleanup(); tst_exit(); }
int main(int argc, char **argv) { char *msg; msg = parse_opts(argc, argv, NULL, NULL); if (msg != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); setup(); #if HAVE_NUMA_MOVE_PAGES unsigned int i; int lc; unsigned int from_node; int ret; ret = get_allowed_nodes(NH_MEMS, 1, &from_node); if (ret < 0) tst_brkm(TBROK | TERRNO, cleanup, "get_allowed_nodes: %d", ret); /* 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]; /* 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] = from_node; ret = numa_move_pages(0, TEST_PAGES, pages, nodes, status, MPOL_MF_MOVE); TEST_ERRNO = errno; /* * commit e78bbfa8262424417a29349a8064a535053912b9 * Author: Brice Goglin <*****@*****.**> * Date: Sat Oct 18 20:27:15 2008 -0700 * mm: stop returning -ENOENT from sys_move_pages() if nothing got migrated */ if ((tst_kvercmp(2, 6, 28)) >= 0) { if (ret == 0) tst_resm(TPASS, "move_pages succeeded"); else tst_resm(TFAIL | TERRNO, "move_pages"); } else { if (ret == -1 && errno == ENOENT) tst_resm(TPASS, "move_pages failed with " "ENOENT as expected"); else tst_resm(TFAIL | TERRNO, "move_pages"); } free_pages(pages, TEST_PAGES); } #else tst_resm(TCONF, "move_pages support not found."); #endif cleanup(); tst_exit(); }
int main(int argc, char **argv) { const char *msg; msg = parse_opts(argc, argv, NULL, NULL); if (msg != NULL) { tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); } setup(); #if HAVE_NUMA_MOVE_PAGES unsigned int i; int lc; unsigned int from_node; unsigned int to_node; int ret; ret = get_allowed_nodes(NH_MEMS, 2, &from_node, &to_node); if (ret < 0) tst_brkm(TBROK | TERRNO, cleanup, "get_allowed_nodes: %d", ret); /* check for looping state if -i option is given */ for (lc = 0; TEST_LOOPING(lc); lc++) { void *pages[N_TEST_PAGES] = { 0 }; int nodes[N_TEST_PAGES]; int status[N_TEST_PAGES]; pid_t cpid; sem_t *sem; /* reset tst_count in case we are looping */ tst_count = 0; ret = alloc_shared_pages_on_node(pages + SHARED_PAGE, N_SHARED_PAGES, from_node); if (ret == -1) continue; ret = alloc_pages_on_node(pages + UNSHARED_PAGE, N_UNSHARED_PAGES, from_node); if (ret == -1) goto err_free_shared; for (i = 0; i < N_TEST_PAGES; i++) { nodes[i] = to_node; } sem = alloc_sem(MAX_SEMS); if (sem == NULL) { goto err_free_unshared; } /* * 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_sem; } else if (cpid == 0) { child(pages, sem); } /* Wait for child to setup and signal. */ if (sem_wait(&sem[SEM_CHILD_SETUP]) == -1) tst_resm(TWARN | TERRNO, "error wait semaphore"); ret = numa_move_pages(0, N_TEST_PAGES, pages, nodes, status, MPOL_MF_MOVE); if (ret == -1) { tst_resm(TFAIL | TERRNO, "move_pages unexpectedly failed"); goto err_kill_child; } if (status[SHARED_PAGE] == -EACCES) tst_resm(TPASS, "status[%d] set to expected -EACCES", SHARED_PAGE); else tst_resm(TFAIL, "status[%d] is %d", SHARED_PAGE, status[SHARED_PAGE]); err_kill_child: /* Test done. Ask child to terminate. */ if (sem_post(&sem[SEM_PARENT_TEST]) == -1) tst_resm(TWARN | TERRNO, "error post semaphore"); /* Read the status, no zombies! */ wait(NULL); err_free_sem: free_sem(sem, MAX_SEMS); err_free_unshared: free_pages(pages + UNSHARED_PAGE, N_UNSHARED_PAGES); err_free_shared: free_shared_pages(pages + SHARED_PAGE, N_SHARED_PAGES); } #else tst_resm(TCONF, "move_pages support not found."); #endif cleanup(); tst_exit(); }
int main(int argc, char **argv) { tst_parse_opts(argc, argv, NULL, NULL); setup(); #if HAVE_NUMA_MOVE_PAGES unsigned int i; int lc; unsigned int from_node; unsigned int to_node; int ret, exp_status; if ((tst_kvercmp(4, 3, 0)) >= 0) exp_status = -EFAULT; else exp_status = -ENOENT; ret = get_allowed_nodes(NH_MEMS, 2, &from_node, &to_node); if (ret < 0) tst_brkm(TBROK | TERRNO, cleanup, "get_allowed_nodes: %d", ret); /* 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]; unsigned long onepage = get_page_size(); /* reset tst_count in case we are looping */ tst_count = 0; ret = alloc_pages_on_node(pages, TOUCHED_PAGES, from_node); if (ret == -1) continue; /* Allocate page and do not touch it. */ pages[UNTOUCHED_PAGE] = numa_alloc_onnode(onepage, from_node); if (pages[UNTOUCHED_PAGE] == NULL) { tst_resm(TBROK, "failed allocating page on node %d", from_node); goto err_free_pages; } for (i = 0; i < TEST_PAGES; i++) nodes[i] = to_node; ret = numa_move_pages(0, TEST_PAGES, pages, nodes, status, MPOL_MF_MOVE); if (ret == -1) { tst_resm(TFAIL | TERRNO, "move_pages unexpectedly failed"); goto err_free_pages; } if (status[UNTOUCHED_PAGE] == exp_status) { tst_resm(TPASS, "status[%d] has expected value", UNTOUCHED_PAGE); } else { tst_resm(TFAIL, "status[%d] is %s, expected %s", UNTOUCHED_PAGE, tst_strerrno(-status[UNTOUCHED_PAGE]), tst_strerrno(-exp_status)); } err_free_pages: /* This is capable of freeing both the touched and * untouched pages. */ free_pages(pages, TEST_PAGES); } #else tst_resm(TCONF, "move_pages support not found."); #endif cleanup(); tst_exit(); }
int main(int argc, char **argv) { char *msg; /* message returned from parse_opts */ /* parse standard options */ msg = parse_opts(argc, argv, NULL, NULL); if (msg != NULL) { tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); } setup(); #if HAVE_NUMA_MOVE_PAGES unsigned int i; int lc; /* loop counter */ unsigned int from_node; unsigned int to_node; int ret; ret = get_allowed_nodes(NH_MEMS, 2, &from_node, &to_node); if (ret < 0) tst_brkm(TBROK|TERRNO, cleanup, "get_allowed_nodes: %d", ret); /* 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]; /* 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; } for (i = 0; i < TEST_PAGES; i++) *((char *)pages[i]) = 0xAA; verify_pages_on_node(pages, status, TEST_PAGES, to_node); free_pages(pages, TEST_PAGES); } #else tst_resm(TCONF, "move_pages support not found."); #endif cleanup(); tst_exit(); }
int main(int argc, char **argv) { char *msg; /* message returned from parse_opts */ /* parse standard options */ msg = parse_opts(argc, argv, NULL, NULL); if (msg != NULL) { tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); } setup(); #if HAVE_NUMA_MOVE_PAGES unsigned int i; int lc; /* loop counter */ unsigned int from_node; unsigned int to_node; int ret; ret = get_allowed_nodes(NH_MEMS, 2, &from_node, &to_node); if (ret < 0) tst_brkm(TBROK|TERRNO, cleanup, "get_allowed_nodes: %d", ret); /* 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]; unsigned long onepage = get_page_size(); /* reset Tst_count in case we are looping */ Tst_count = 0; ret = alloc_pages_on_node(pages, TOUCHED_PAGES, from_node); if (ret == -1) continue; /* Allocate page and do not touch it. */ pages[UNTOUCHED_PAGE] = numa_alloc_onnode(onepage, from_node); if (pages[UNTOUCHED_PAGE] == NULL) { tst_resm(TBROK, "failed allocating page on node %d", from_node); goto err_free_pages; } 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 == -1) { tst_resm(TFAIL | TERRNO, "move_pages unexpectedly failed"); goto err_free_pages; } if (status[UNTOUCHED_PAGE] == -ENOENT) tst_resm(TPASS, "status[%d] set to expected -ENOENT", UNTOUCHED_PAGE); else tst_resm(TFAIL, "status[%d] is %d", UNTOUCHED_PAGE, status[UNTOUCHED_PAGE]); err_free_pages: /* This is capable of freeing both the touched and * untouched pages. */ free_pages(pages, TEST_PAGES); } #else tst_resm(TCONF, "move_pages support not found."); #endif cleanup(); tst_exit(); }