diff --git a/kernel/pager.c b/kernel/pager.c index d997f208..2fc1a725 100644 --- a/kernel/pager.c +++ b/kernel/pager.c @@ -96,7 +96,7 @@ struct swapinfo { struct arealist swap_area; struct arealist mlock_area; struct mlockcntnr mlock_container; -#define UDATA_BUFSIZE (8*1024) +#define UDATA_BUFSIZE PAGE_SIZE char *swapfname; char *udata_buf; /* To read-store data from Linux to user space */ @@ -295,7 +295,7 @@ static int pager_open(struct swapinfo *si, char *fname, int flag, int mode) { int fd; - strcpy(si->udata_buf, fname); + copy_to_user(si->udata_buf, fname, strlen(fname) + 1); fd = linux_open(si->udata_buf, flag, mode); return fd; } @@ -303,22 +303,69 @@ pager_open(struct swapinfo *si, char *fname, int flag, int mode) static int pager_unlink(struct swapinfo *si, char *fname) { - strcpy(si->udata_buf, fname); + copy_to_user(si->udata_buf, fname, strlen(fname) + 1); return linux_unlink(si->udata_buf); } +static int +pager_copy_from_user(void * dst, void * from, size_t size, struct process_vm *vm) +{ + int ret; + void *virt; + unsigned long psize; + unsigned long rphys; + int faulted = 0; + + if (size > PAGE_SIZE) { + ret = -EFAULT; + return ret; + } + +retry_lookup: + /* remember page */ + ret = ihk_mc_pt_virt_to_phys_size(vm->address_space->page_table, + dst, &rphys, &psize); + + if (ret) { + uint64_t reason = PF_POPULATE | PF_WRITE | PF_USER; + void *addr= (void *)(((unsigned long)dst)& PAGE_MASK); + + if (faulted) { + ret = -EFAULT; + return ret; + } + + ret = page_fault_process_vm(vm, addr, reason); + if (ret) { + ret = -EFAULT; + return ret; + } + + faulted = 1; + goto retry_lookup; + } + + virt = phys_to_virt(rphys); + + ret = copy_from_user(virt, from, size); + + + return ret; +} + static ssize_t -pager_read(struct swapinfo *si, int fd, void *start, size_t size) +pager_read(struct swapinfo *si, int fd, void *start, size_t size,struct process_vm *vm) { ssize_t off, sz, rs; - kprintf("pager_read: %lx (%lx)\n", start, size); for (off = 0; off < size; off += sz) { sz = size - off; sz = (sz > UDATA_BUFSIZE) ? UDATA_BUFSIZE : sz; rs = linux_read(fd, si->udata_buf, sz); if (rs != sz) return rs; - copy_to_user(start + off, si->udata_buf, sz); + + rs = pager_copy_from_user(start + off, si->udata_buf, sz, vm); + if (rs != 0) return rs; } return off; } @@ -354,23 +401,26 @@ mlocklist_req(unsigned long start, unsigned long end, struct addrpair *addr, int static int mlocklist_morereq(struct swapinfo *si, unsigned long *start) { - struct areaent *ent = si->mlock_area.tail; + struct areaent went,*ent = si->mlock_area.tail; + copy_from_user(&went, ent, sizeof(struct areaent)); dkprintf("mlocklist_morereq: start = %ld and = %ld\n", - ent->pair[ent->count].start, ent->pair[ent->count].end); - if (ent->pair[ent->count].start != (unsigned long) -1) { + went.pair[went.count].start, went.pair[went.count].end); + if (went.pair[went.count].start != (unsigned long) -1) { return 0; } - *start = ent->pair[ent->count].end; + *start = went.pair[went.count].end; return 1; } static int arealist_alloc(struct swapinfo *si, struct arealist *areap) { + struct areaent went; areap->head = areap->tail = myalloc(si, sizeof(struct areaent)); if (areap->head == NULL) return -ENOMEM; - memset(areap->head, 0, sizeof(struct areaent)); + memset(&went, 0, sizeof(struct areaent)); + copy_to_user(areap->head, &went, sizeof(struct areaent)); return 0; } @@ -402,7 +452,7 @@ arealist_free(struct arealist *area) static int arealist_get(struct swapinfo *si, struct addrpair **pair, struct arealist *area) { - struct areaent *tmp; + struct areaent *tmp,wtmp; struct areaent *tail = area->tail; if (tail->count < MLOCKADDRS_SIZE - 1) { /* at least two entries are needed */ if (pair) *pair = &tail->pair[tail->count]; @@ -412,8 +462,10 @@ arealist_get(struct swapinfo *si, struct addrpair **pair, struct arealist *area) if (tmp == NULL) { return -1; } - memset(tmp, 0, sizeof(struct areaent)); - area->tail->next = tmp; + memset(&wtmp, 0, sizeof(struct areaent)); + copy_to_user(tmp, &wtmp, sizeof(struct areaent)); + copy_to_user(&(area->tail->next), &tmp, sizeof(struct areaent *)); + area->tail = tmp; if (pair) *pair = area->tail->pair; return MLOCKADDRS_SIZE; @@ -422,7 +474,10 @@ arealist_get(struct swapinfo *si, struct addrpair **pair, struct arealist *area) static void arealist_update(int cnt, struct arealist *area) { - area->tail->count += cnt; + int i; + copy_from_user(&i, &(area->tail->count), sizeof(int)); + i += cnt; + copy_to_user(&(area->tail->count), &i, sizeof(int)); area->count += cnt; } @@ -431,11 +486,13 @@ arealist_add(struct swapinfo *si, unsigned long start, unsigned long end, unsigned long flag, struct arealist *area) { int cc; - struct addrpair *addr; + struct addrpair *addr,waddr; cc = arealist_get(si, &addr, area); if (cc < 0) return -1; - addr->start = start; addr->end = end; addr->flag = flag; + waddr.start = start; waddr.end = end; waddr.flag = flag; + copy_to_user(addr, &waddr, sizeof(struct addrpair)); + arealist_update(1, area); return 0; } @@ -444,27 +501,31 @@ static int arealist_preparewrite(struct arealist *areap, struct swap_areainfo *info, ssize_t off, struct process_vm *vm, int flag) { - struct areaent *ent; + struct areaent *ent,went; int count = 0; ssize_t totsz = 0; + unsigned long pos; struct page_table *pt = vm->address_space->page_table; for (ent = areap->head; ent != NULL; ent = ent->next) { int i; - for (i = 0; i < ent->count; i++, count++) { - ssize_t sz = ent->pair[i].end - ent->pair[i].start; - info[count].start = ent->pair[i].start; - info[count].end = ent->pair[i].end; - info[count].flag = ent->pair[i].flag; + copy_from_user(&went, ent, sizeof(struct areaent)); + for (i = 0; i < went.count; i++, count++) { + ssize_t sz = went.pair[i].end - went.pair[i].start; + copy_to_user(&(info[count].start), &(went.pair[i].start), sizeof(unsigned long)); + copy_to_user(&(info[count].end), &(went.pair[i].end), sizeof(unsigned long)); + copy_to_user(&(info[count].flag), &(went.pair[i].flag), sizeof(unsigned long)); if (flag) { /* position in file */ - info[count].pos = off + totsz; + + pos = off + totsz; } else { /* physical memory */ if (ihk_mc_pt_virt_to_phys(pt, (void*) ent->pair[i].start, - &info[count].pos)) { + &pos)) { kprintf("Cannot get phys\n"); } } + copy_to_user(&(info[count].pos), &pos, sizeof(unsigned long)); totsz += sz; } } @@ -489,6 +550,7 @@ arealist_print(char *msg, struct arealist *areap, int count) for (ent = areap->head; ent != NULL; ent = ent->next) { int i; for (i = 0; i < ent->count; i++) { + kprintf("\t%p -- %p\n", (void*) ent->pair[i].start, (void*) ent->pair[i].end); } @@ -608,13 +670,13 @@ do_pagein(int flag) extern int ihk_mc_pt_print_pte(struct page_table *pt, void *virt); sz = si->swap_info[i].end - si->swap_info[i].start; dkprintf("pagein: %016lx:%016lx sz(%lx)\n", si->swap_info[i].start, si->swap_info[i].end, sz); - rs = pager_read(si, fd, (void*) si->swap_info[i].start, sz); + rs = pager_read(si, fd, (void*) si->swap_info[i].start, sz, vm); if (rs != sz) goto err; // ihk_mc_pt_print_pte(vm->address_space->page_table, (void*) si->swap_info[i].start); } linux_close(fd); print_region("after pagin", vm); - kprintf("do_pagein: done, currss(%lx)\n", vm->currss); + dkprintf("do_pagein: done, currss(%lx)\n", vm->currss); vm->swapinfo = NULL; kfree(si->swapfname); kfree(si); @@ -679,7 +741,8 @@ do_pageout(char *fname, void *buf, size_t size, int flag) goto err; } - fd = linux_open(fname, O_RDWR|O_CREAT|O_TRUNC, 0600); + copy_to_user(si->udata_buf, si->swapfname, strlen(si->swapfname) + 1); + fd = linux_open(si->udata_buf, O_RDWR|O_CREAT|O_TRUNC, 0600); if (fd < 0) { ekprintf("do_pageout: Cannot open/create file: %s\n", fname); cc = fd; @@ -752,10 +815,10 @@ do_pageout(char *fname, void *buf, size_t size, int flag) /* preparing page store */ si->swphdr = myalloc(si, sizeof(struct swap_header)); - strncpy(si->swphdr->magic, MCKERNEL_SWAP, SWAP_HLEN); - strncpy(si->swphdr->version, MCKERNEL_SWAP_VERSION, SWAP_HLEN); - si->swphdr->count_sarea = si->swap_area.count; - si->swphdr->count_marea = si->mlock_area.count; + copy_to_user(&(si->swphdr->magic), MCKERNEL_SWAP, SWAP_HLEN); + copy_to_user(&(si->swphdr->version), MCKERNEL_SWAP_VERSION, SWAP_HLEN); + copy_to_user(&(si->swphdr->count_sarea), &(si->swap_area.count), sizeof(unsigned int)); + copy_to_user(&(si->swphdr->count_marea), &(si->mlock_area.count), sizeof(unsigned int)); if ((cc = pager_write(fd, si->swphdr, sizeof(struct swap_header))) != sizeof(struct swap_header)) { if (cc >= 0) @@ -779,8 +842,10 @@ do_pageout(char *fname, void *buf, size_t size, int flag) if ((cc = arealist_write(fd, si->mlock_info, si->mlock_area.count)) < 0) goto err; /* now pages are stored */ for (i = 0; i < si->swap_area.count; i++) { - sz = si->swap_info[i].end - si->swap_info[i].start; - if ((cc = pager_write(fd, (void*) si->swap_info[i].start, sz)) != sz) { + struct swap_areainfo sw_info; + copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo)); + sz = sw_info.end - sw_info.start; + if ((cc = pager_write(fd, (void*) sw_info.start, sz)) != sz) { if (cc >= 0) cc = -EIO; goto err; @@ -792,10 +857,12 @@ do_pageout(char *fname, void *buf, size_t size, int flag) } kprintf("removing physical memory\n"); for (i = 0; i < si->swap_area.count; i++) { + struct swap_areainfo sw_info; + copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo)); cc = ihk_mc_pt_free_range(vm->address_space->page_table, vm, - (void*) si->swap_info[i].start, - (void*) si->swap_info[i].end, NULL); + (void*) sw_info.start, + (void*) sw_info.end, NULL); if (cc < 0) { kprintf("ihk_mc_pt_clear_range returns: %d\n", cc); } @@ -811,8 +878,10 @@ do_pageout(char *fname, void *buf, size_t size, int flag) * except TEXT, STACK, readonly pages, are not invalid. */ for (i = 0; i < si->swap_area.count; i++) { - sz = si->swap_info[i].end - si->swap_info[i].start; - cc = linux_munmap((void*) si->swap_info[i].start, sz, 0); + struct swap_areainfo sw_info; + copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo)); + sz = sw_info.end - sw_info.start; + cc = linux_munmap((void*) sw_info.start, sz, 0); if (cc < 0) { kprintf("do_pageout: Cannot munmap: %lx len(%lx)\n", si->swap_info[i].start, sz); diff --git a/test/qlmpi/qlmpi_testsuite/ReadMe b/test/qlmpi/qlmpi_testsuite/ReadMe new file mode 100644 index 00000000..e9e0bd04 --- /dev/null +++ b/test/qlmpi/qlmpi_testsuite/ReadMe @@ -0,0 +1,32 @@ +qlmpiのテストについて +1.テスト準備 +1.1 テストケースファイル +  mckernel/test/qlmpi/qlmpi_testsuite/test_cases/*.txt + MASTER マスターノードのマシン名もしくはIPアドレス + SLAVE スレーブノードのマシン名もしくはIPアドレス +1.2 ホストファイル + 以下のホストファイルを環境に合わせて修正します。 + mckernel/test/qlmpi/qlmpi_testsuite/hostfile* + +1.2 テストプログラムのコンパイル + 以下のファイルの内容を見て、適宜修正します。修正後makeします。 +  mckernel/test/qlmpi/qlmpi_testsuite/Makefile + +1.3 configファイル + user_space/swapout/config + MCMOD_DIR mckernelのディレクトリ + START ql_mpiexec_startのパスqlmpiテスト用 + FINALIZE ql_mpiexec_finalizeのパスqlmpiテスト用 + USR_PRG_A qlmpiテスト用プログラムのパス + USR_PRG_B qlmpiテスト用プログラムのパス + USR_PRG_C qlmpiテスト用プログラムのパス + USR_PRG_IRREG qlmpiテスト用プログラムのパス + +2.テスト + 以下のファイルを実行します。 +  mckernel/test/qlmpi/qlmpi_testsuite/go_ql_test.sh + + 実行結果は以下のディレクトリに格納されます。 + mckernel/test/qlmpi/qlmpi_testsuite/result + +以上 diff --git a/test/user_space/ReadMe b/test/user_space/ReadMe new file mode 100644 index 00000000..09681c3f --- /dev/null +++ b/test/user_space/ReadMe @@ -0,0 +1,91 @@ +User spaceテストについて +1.テストの準備 +1.1 パッチファイル + テストは、修正部分にkprintfをパッチで追加し確認を行います。 + パッチファイルは以下のディレクトリに格納しています。 + mckernel/test/user_space/patch/ + 以下にテストとパッチの対応を示します。 + + パッチファイル名 対象システムコール テストID + syscall.patch perf_event_open perf_001-perf_008 + syscall.patch futex futes_001-futex_011 + syscall.patch process_vm_readv pvr_001-pvr_033 + syscall.patch process_vm_writev pvw_001-pvw_031 + syscall.patch move_pages mpo_001-mp_012 + pager_copy_from.patch swapout so_001-so_006 + pager_copy_to_01.patch swapout so_007-so_013 + pager_copy_to_02.patch swapout so_014-so_022 + なし swapout so_023-so_025 + qlmpilib.patch swapout so_026 + +1.2 パッチの適用 + mckernelディレクトリで以下コマンドを実行してパッチを当ててください。 + パッチ実行後ビルドしてください。 + + patch -p1 < ./test/user_space/patch/XXXX.patch + (XXXX.patchはパッチファイル名) + + +1.3 その他プログラムのコンパイル + (1)user_space/swapoutディレクトリで、makeし、swaptest実行モジュールを作成してください。 + (2)qlmpi/qlmpi_testsuiteディレクトリで、テスト用プログラムのコンパイルを実施してください。 + (3)LTPプログラムの実行モジュールを準備する必要があります。 + +2.テストについて + user_spaceのディレクトリにあるシェルについて説明します。 +2.1 システムコールテスト用シェル + go_syscall_test.sh [auto] + 説明 + perf_event_open,futex,process_vm_readv,process_vm_writev,move_pages + のテストを実行する。auto指定時、git reset --hard HEADコマンドで + リセット後パッチを当て、ビルド後テストを開始する。 + テスト結果は、各システムコールディレクトリの下に.logファイルとして + 保存する。 + システムコールごと個別のテストを行う場合は、各システムコール名の + ディレクトリにあるテスト用のシェルを実行する。 +2.2 swapoutテスト用シェル + go_swapout_test.sh [auto] + 説明 + swapoutのテストを実行する。auto指定時、git reset --hard HEADコマンドで + パッチを当て、ビルド後テストを繰り返す。 + テスト結果は、swapoutディレクトリに.logファイルとして保存する。 + パッチを手で当ててテストを行う場合は、swapoutディレクトリにある、 + テスト用のシェルを対応するパッチを当ててから実行する。 +2.3 パッチ及びビルドコマンド + patch_and_build.sh [patch_filename] + 説明 + git reset --hard HEADでソースをリセット後、引数で指定されたパッチを + 当ててからビルドする。引数を指定しない場合は、ソースをリセットして + ビルドを行う。テスト用シェルでautoオプションを付けた場合、テスト用 + シェルから本シェルを呼び出す。 + +3. configファイル + configファイルは各テストディレクトリにあります。各ディレクトリのシェルから + 参照されます。 + user_space/config + MCMOD_DIR mckernelのディレクトリ + SRC_PATH ソースディレクトリ + TEST_DIR テストプログラムがあるディレクトリ + + user_space/perf_event_open/config + user_space/futex/config + user_space/process_vm/config + user_space/move_pages/config + MCPATH mckernelのディレクトリ + LTP_EXE_DIR LTPの実行ファイルがあるディレクトリ + + user_space/swapout/config + MCMOD_DIR mckernelのディレクトリ + START ql_mpiexec_startのパスqlmpiテスト用 + FINALIZE ql_mpiexec_finalizeのパスqlmpiテスト用 + USR_PRG_A qlmpiテスト用プログラム /test/qlmpi/qlmpi_testsuite参照 + USR_PRG_B qlmpiテスト用プログラム /test/qlmpi/qlmpi_testsuite参照 + USR_PRG_C qlmpiテスト用プログラム /test/qlmpi/qlmpi_testsuite参照 + USR_PRG_IRREG qlmpiテスト用プログラム /test/qlmpi/qlmpi_testsuite参照 + +4. その他 +4.1 qlmpiテスト用のマシンファイルの設定 + user_space/swapout/test_cases/CT01.txt + MASTER マスターノードのマシン名もしくはIPアドレス + SLAVE 1ノードのテストのため不要 +以上 diff --git a/test/user_space/config b/test/user_space/config new file mode 100644 index 00000000..73740247 --- /dev/null +++ b/test/user_space/config @@ -0,0 +1,4 @@ +MCMOD_DIR=/home/iizuka/mckernel +SRC_PATH=/home/iizuka/src/mckernel +TEST_DIR=/home/iizuka/src/mckernel/test/user_space + diff --git a/test/user_space/futex/config b/test/user_space/futex/config new file mode 100644 index 00000000..e5f48348 --- /dev/null +++ b/test/user_space/futex/config @@ -0,0 +1,2 @@ +MCPATH=/home/iizuka/mckernel +LTP_EXE_DIR=/home/iizuka/LTP/futex diff --git a/test/user_space/futex/futex_test.sh b/test/user_space/futex/futex_test.sh new file mode 100755 index 00000000..2bafa7b8 --- /dev/null +++ b/test/user_space/futex/futex_test.sh @@ -0,0 +1,107 @@ +#!/bin/sh + +# Functions +function reboot() { + count=`pgrep -c -f 'mcexec '` + if [ ${count} -gt 0 ] + then +# echo "kill process :" ${count} + pgrep -l -f 'mcexec ' + pgrep -f 'mcexec ' | xargs sudo kill -9 + fi +# echo -n "mckernel stopping... " + sudo ${MCMOD_DIR}/sbin/mcstop+release.sh +# echo "done." + #sleep 1 + echo -n "mckernel reboot ...." + sudo ${MCMOD_DIR}/sbin/mcreboot.sh $* + echo "done." +} + +function ok_out() { + echo "[OK] ${TEST_PREFIX}`printf %03d ${TEST_NUM}` $1" + (( TEST_NUM++ )) + TEST_CODE=`printf %03d ${TEST_NUM}` +} + +function ng_out() { + echo "[NG] ${TEST_PREFIX}`printf %03d ${TEST_NUM}` $1" + exit 1 +} + +function ltp_test() { + TEST_NAME=$1 +#LTP programを実行 logを保存 + sudo ${MCPATH}/bin/mcexec ${LTP_EXE_DIR}/${TEST_NAME} >./result/${TEST_NAME}.log + +#LTP log 確認 + NUM=`cat ./test_cases/${TEST_NAME}.txt |wc -l` + for i in `seq 1 ${NUM}` + do + G_TEXT=`head -n ${i} ./test_cases/${TEST_NAME}.txt | tail -n 1` + result=`grep "${G_TEXT}" ./result/${TEST_NAME}.log` + #echo ${G_TEXT} + rc=$? + if [ ${rc} -eq 0 ]; then + ok_out "futex: ${result}" + else + ng_out "futex: result of ${TEST_NAME} ${i} are different." + fi + done +} + +TEST_PARAM_FILE=$1 +TEST_NUM=1 +TEST_CODE=001 +TEST_PREFIX=futex_ + +ME=`whoami` +if [ $# -ne 2 ]; then + source ./config +else + MCPATH=$1 + LTP_EXE_DIR=$2/futex +fi + +mkdir -p result + +reboot +#LTP programを実行 logを保存 +mcexec ${LTP_EXE_DIR}/futex_wait01 >./result/futex_wait01.log + +#kmsgを保存 +sudo ${MCPATH}/sbin/ihkosctl 0 kmsg >./result/futex_wait01.kmsg + +#kmsgで結果を出力する。 +#futex-001 アドレスが正しく引き継いでいることを確認 + +#システムコールの引数のアドレスを取得 +sys_addr=`grep "sys_futex" ./result/futex_wait01.kmsg |head -n 1 |cut -d "," -f 2` +grep "get_futex_value_locked" ./result/futex_wait01.kmsg | head -n 1 | grep ${sys_addr} >/dev/null +rc=$? +if [ ${rc} -eq 0 ]; then + text=`echo "futex: The argument address of futex is taken over by get_futex_value_locked."` + ok_out "${text}" +else + ng_out "futex: The argument value of futex does not match the value of get_futex_value_locked argument." +fi + +#futex-002 第1引数と第2引数が同じ値であることを確認 +uaddr=`grep "get_futex_value_locked" ./result/futex_wait01.kmsg | head -n 1 | sed s/"^.*\*uaddr:\([0-9]*\),.*$"/"\1"/ ` +#echo ${uaddr} +uval=`grep "get_futex_value_locked" ./result/futex_wait01.kmsg | head -n 1 | sed s/"^.*uval:\([0-9]*\),.*$"/"\1"/ ` +#echo ${uval} +if [ ${uaddr} = ${uval} ]; then + text=`echo "futex: The first argument of get_futex_value_locked matched the value of the second argument."` + ok_out "${text}" +else + ng_out "futex: The first argument of get_futex_value_locked does not match the value of the second argument." +fi + +#LTP test +ltp_test "futex_wait01" +ltp_test "futex_wait02" +ltp_test "futex_wait03" +ltp_test "futex_wait04" +ltp_test "futex_wait_bitset01" +ltp_test "futex_wait_bitset02" diff --git a/test/user_space/futex/test_cases/futex_wait01.txt b/test/user_space/futex/test_cases/futex_wait01.txt new file mode 100644 index 00000000..7e5ac06f --- /dev/null +++ b/test/user_space/futex/test_cases/futex_wait01.txt @@ -0,0 +1,4 @@ +futex_wait01 1 TPASS : +futex_wait01 2 TPASS : +futex_wait01 3 TPASS : +futex_wait01 4 TPASS : diff --git a/test/user_space/futex/test_cases/futex_wait02.txt b/test/user_space/futex/test_cases/futex_wait02.txt new file mode 100644 index 00000000..e8c2c1e4 --- /dev/null +++ b/test/user_space/futex/test_cases/futex_wait02.txt @@ -0,0 +1 @@ +futex_wait02 1 TPASS : diff --git a/test/user_space/futex/test_cases/futex_wait03.txt b/test/user_space/futex/test_cases/futex_wait03.txt new file mode 100644 index 00000000..1380742a --- /dev/null +++ b/test/user_space/futex/test_cases/futex_wait03.txt @@ -0,0 +1 @@ +futex_wait03 1 TPASS : diff --git a/test/user_space/futex/test_cases/futex_wait04.txt b/test/user_space/futex/test_cases/futex_wait04.txt new file mode 100644 index 00000000..f89c6c5f --- /dev/null +++ b/test/user_space/futex/test_cases/futex_wait04.txt @@ -0,0 +1 @@ +futex_wait04 1 TPASS : diff --git a/test/user_space/futex/test_cases/futex_wait_bitset01.txt b/test/user_space/futex/test_cases/futex_wait_bitset01.txt new file mode 100644 index 00000000..b013a13e --- /dev/null +++ b/test/user_space/futex/test_cases/futex_wait_bitset01.txt @@ -0,0 +1 @@ +futex_wait_bitset01 1 TPASS : diff --git a/test/user_space/futex/test_cases/futex_wait_bitset02.txt b/test/user_space/futex/test_cases/futex_wait_bitset02.txt new file mode 100644 index 00000000..0f82db6a --- /dev/null +++ b/test/user_space/futex/test_cases/futex_wait_bitset02.txt @@ -0,0 +1 @@ +futex_wait_bitset02 1 TPASS : diff --git a/test/user_space/go_swapout_test.sh b/test/user_space/go_swapout_test.sh new file mode 100755 index 00000000..0d3e8c3b --- /dev/null +++ b/test/user_space/go_swapout_test.sh @@ -0,0 +1,83 @@ +#!/bin/sh + +source ./config +echo $TEST_DIR +echo $MCPATH +echo $LTP_PATH + +auto_flg=0 +if [ $# = 1 ]; then + if [ $1 = "auto" ]; then + auto_flg=1 + else + auto_flg=0 + fi +fi + +echo "pager_copy_from.patch for copy_from_user\(arealist_update,arealist_morereq,arealist_preparewrite,go_pageout\) test." +#patch copy_from_user +if [ ${auto_flg} -eq 1 ]; then + cd ${TEST_DIR} + sh ./patch_and_build.sh pager_copy_from.patch >/dev/null +fi + +#copy_from_user_test start +echo swapout +cd ${TEST_DIR}/swapout +./swapout_copy_from.sh 2>&1 | tee ./swapout_copy_from.log +cd ${TEST_DIR} + +echo "pager_copy_to_01.patch for copy_to_user\(arealist_update,arealist_add,do_pageout\) test." +#copy_to_user_test start +if [ ${auto_flg} -eq 1 ]; then + cd ${TEST_DIR} + sh ./patch_and_build.sh pager_copy_to_01.patch >/dev/null +fi + +echo swapout copy_to_user 1 test start +cd ${TEST_DIR}/swapout +./swapout_copy_to_01.sh 2>&1 | tee ./swapout_copy_to_01.log +cd ${TEST_DIR} + +echo "pager_copy_to_02.patch for copy_to_user\(arealist_preparewrite,pager_open,pager_unlink,arealist_get,arealist_alloc\) test." +if [ ${auto_flg} -eq 1 ]; then + cd ${TEST_DIR} + sh ./patch_and_build.sh pager_copy_to_02.patch >/dev/null +fi +echo swapout copy_to_user 2 test start +cd ${TEST_DIR}/swapout +./swapout_copy_to_02.sh 2>&1 | tee ./swapout_copy_to_02.log +cd ${TEST_DIR} + +echo "git reset --hard HEAD for swaptest execution test." +if [ ${auto_flg} -eq 1 ]; then + cd ${TEST_DIR} + sh ./patch_and_build.sh >/dev/null +fi + +echo swapout swaptest execution test start +cd ${TEST_DIR}/swapout +./swapout_normal.sh 2>&1 | tee ./swapout_normal.log +cd ${TEST_DIR} + +echo "qlmpilib.patch for qlmpi test." +if [ ${auto_flg} -eq 1 ]; then + cd ${TEST_DIR} + sh ./patch_and_build.sh qlmpilib.patch >/dev/null +fi + +echo swapout qlmpi test start +cd ${TEST_DIR}/swapout +./ql_normal.sh ./test_cases/CT01.txt 2>&1 | tee ./ql_normal.log + +cat ./swapout_copy_from.log ./swapout_copy_to_01.log ./swapout_copy_to_02.log ./swapout_normal.log ./ql_normal.log > ./swapout_test.log + +rm ./swapout_copy_from.log ./swapout_copy_to_01.log ./swapout_copy_to_02.log ./swapout_normal.log ./ql_normal.log + +cd ${TEST_DIR} + +#最後にgitをresetしてビルドしなおす +if [ ${auto_flg} -eq 1 ]; then + cd ${TEST_DIR} + sh ./patch_and_build.sh >/dev/null +fi diff --git a/test/user_space/go_syscall_test.sh b/test/user_space/go_syscall_test.sh new file mode 100755 index 00000000..d0067bea --- /dev/null +++ b/test/user_space/go_syscall_test.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +source ./config + +auto_flg=0 +if [ $# = 1 ]; then + if [ $1 = "auto" ]; then + auto_flg=1 + else + auto_flg=0 + fi +fi + +#patch syscall.patch +if [ ${auto_flg} -eq 1 ]; then + cd ${TEST_DIR} + sh ./patch_and_build.sh syscall.patch >/dev/null +fi + +echo perf_event_open test start +cd ${TEST_DIR}/perf_event_open +./perf_event_open_test.sh 2>&1 | tee ./perf_event_open_test.log +cd ${TEST_DIR} + +echo futex test start +cd ${TEST_DIR}/futex +./futex_test.sh 2>&1 | tee ./futex_test.log +cd ${TEST_DIR} + +echo process_vm_readv test start +cd ${TEST_DIR}/process_vm +./process_vm_readv_test.sh 2>&1 | tee ./process_vm_readv_test.log +echo process_vm_writev test start +./process_vm_writev_test.sh 2>&1 | tee ./process_vm_writev_test.log +cd ${TEST_DIR} + +echo move_pages test start +cd ${TEST_DIR}/move_pages +./move_pages_test.sh 2>&1 | tee ./move_pages_test.log +cd ${TEST_DIR} + + diff --git a/test/user_space/move_pages/config b/test/user_space/move_pages/config new file mode 100644 index 00000000..77a3bd0f --- /dev/null +++ b/test/user_space/move_pages/config @@ -0,0 +1,2 @@ +MCPATH=/home/iizuka/mckernel +LTP_EXE_DIR=/home/iizuka/LTP/move_pages diff --git a/test/user_space/move_pages/move_pages_test.sh b/test/user_space/move_pages/move_pages_test.sh new file mode 100755 index 00000000..3bc9e89b --- /dev/null +++ b/test/user_space/move_pages/move_pages_test.sh @@ -0,0 +1,132 @@ +#!/bin/sh + +# Functions +function reboot() { + count=`pgrep -c -f 'mcexec '` + if [ ${count} -gt 0 ] + then +# echo "kill process :" ${count} + pgrep -l -f 'mcexec ' + pgrep -f 'mcexec ' | xargs sudo kill -9 + fi +# echo -n "mckernel stopping... " + sudo ${MCMOD_DIR}/sbin/mcstop+release.sh +# echo "done." + #sleep 1 + echo -n "mckernel reboot ...." + sudo ${MCMOD_DIR}/sbin/mcreboot.sh $* + echo "done." +} + +function ok_out() { + echo "[OK] ${TEST_PREFIX}`printf %03d ${TEST_NUM}` $1" + (( TEST_NUM++ )) + TEST_CODE=`printf %03d ${TEST_NUM}` +} + +function ng_out() { + echo "[NG] ${TEST_PREFIX}`printf %03d ${TEST_NUM}` $1" + exit 1 +} + +function ltp_test() { + TEST_NAME=$1 +#LTP programを実行 logを保存 + sudo ${MCPATH}/bin/mcexec ${LTP_EXE_DIR}/${TEST_NAME} >./result/${TEST_NAME}.log + +#LTP log 確認 + NUM=`cat ./test_cases/${TEST_NAME}.txt |wc -l` + for i in `seq 1 ${NUM}` + do + G_TEXT=`head -n ${i} ./test_cases/${TEST_NAME}.txt | tail -n 1` + result=`grep "${G_TEXT}" ./result/${TEST_NAME}.log` + #echo ${G_TEXT} + rc=$? + if [ ${rc} -eq 0 ]; then + ok_out "move_pages: ${result}" + else + ng_out "move_pages: result of ${TEST_NAME} ${i} are different." + fi + done +} + +TEST_PARAM_FILE=$1 +TEST_NUM=1 +TEST_CODE=001 +TEST_PREFIX=mp_ + +ME=`whoami` +if [ $# -ne 2 ]; then + source ./config +else + MCPATH=$1 + LTP_EXE_DIR=$2/move_pages +fi + +mkdir -p ./result + +reboot "-m256m@0,256m@1" +ltp_test "move_pages01" + +reboot "-m256m@0,256m@1" +#LTP programを実行 logを保存 +sudo ${MCPATH}/bin/mcexec ${LTP_EXE_DIR}/move_pages02 >./result/move_pages02.log + +#kmsgを保存 +sudo ${MCPATH}/sbin/ihkosctl 0 kmsg >./result/move_pages02.kmsg + +#move_pages-002 第3引数のアドレスが正しく引き継いでいることを確認 +#システムコールの引数のアドレスを取得 +sys_virt_addr=`grep "sys_move_pages" ./result/move_pages02.kmsg | head -n 1 | sed -n s/"^.*user_virt_addr:\([0-9a-f]*\),.*$"/"\1"/p ` +#echo ${sys_virt_addr} +#実行関数の引数のアドレスを取得 +handl_virt_addr=`grep "move_pages_smp_handler" ./result/move_pages02.kmsg | head -n 1 | sed -n s/"^.*user_virt_addr:\([0-9a-f]*\),.*$"/"\1"/p ` +#echo ${handl_virt_addr} +if [ ${#sys_virt_addr} -ne 0 -a ${sys_virt_addr} = ${handl_virt_addr} ]; then + text=`echo "move_pages: The argument address of move_pages is taken over by move_pages_smp_handler"` + ok_out "${text} user_virt_addr:${sys_virt_addr}" +else + ng_out "move_pages: The argument value of process_vm_writev does not match the value of do_process_vm_read_writev argument." +fi + +#move_pages-003 第4引数のアドレスが正しく引き継いでいることを確認 +#システムコールの引数のアドレスを取得 +sys_user_nodes=`grep "sys_move_pages" ./result/move_pages02.kmsg | head -n 1 | sed s/"^.*user_nodes:\([0-9a-f]*\),.*$"/"\1"/ ` +#echo ${sys_user_nodes} +#実行関数の引数のアドレスを取得 +handl_user_nodes=`grep "move_pages_smp_handler" ./result/move_pages02.kmsg | head -n 1 | sed s/"^.*user_nodes:\([0-9a-f]*\),.*$"/"\1"/ ` +#echo ${handl_user_nodes} +if [ ${#sys_user_nodes} -ne 0 -a ${sys_user_nodes} = ${handl_user_nodes} ]; then + text=`echo "move_pages: The argument address of move_pages is taken over by move_pages_smp_handler"` + ok_out "${text} user_modes:${sys_user_nodes}" +else + ng_out "move_pages: The argument value of process_vm_writev does not match the value of do_process_vm_read_writev argument." +fi + +#move_pages-004 第5引数のアドレスが正しく引き継いでいることを確認 +#システムコールの引数のアドレスを取得 +sys_user_status=`grep "sys_move_pages" ./result/move_pages02.kmsg | head -n 1 | sed s/"^.*user_status:\([0-9a-f]*\).*$"/"\1"/ ` +#echo ${sys_user_status} +#実行関数の引数のアドレスを取得 +handl_user_status=`grep "move_pages_smp_handler" ./result/move_pages02.kmsg | head -n 1 | sed s/"^.*user_status:\([0-9a-f]*\).*$"/"\1"/ ` +#echo ${handl_user_status} +if [ ${#sys_user_status} -ne 0 -a ${sys_user_status} = ${handl_user_status} ]; then + text=`echo "move_pages: The argument address of move_pages is taken over by move_pages_smp_handler"` + ok_out "${text} user_modes:${sys_user_status}" +else + ng_out "move_pages: The argument value of process_vm_writev does not match the value of do_process_vm_read_writev argument." +fi + +ltp_test "move_pages02" + +ltp_test "move_pages04" + +ltp_test "move_pages06" + +ltp_test "move_pages07" + +ltp_test "move_pages08" + +ltp_test "move_pages09" + +ltp_test "move_pages10" diff --git a/test/user_space/move_pages/test_cases/move_pages01.txt b/test/user_space/move_pages/test_cases/move_pages01.txt new file mode 100644 index 00000000..bb656f87 --- /dev/null +++ b/test/user_space/move_pages/test_cases/move_pages01.txt @@ -0,0 +1 @@ +move_pages01 1 TFAIL : diff --git a/test/user_space/move_pages/test_cases/move_pages02.txt b/test/user_space/move_pages/test_cases/move_pages02.txt new file mode 100644 index 00000000..203d261b --- /dev/null +++ b/test/user_space/move_pages/test_cases/move_pages02.txt @@ -0,0 +1 @@ +move_pages02 1 TFAIL : diff --git a/test/user_space/move_pages/test_cases/move_pages04.txt b/test/user_space/move_pages/test_cases/move_pages04.txt new file mode 100644 index 00000000..7510b111 --- /dev/null +++ b/test/user_space/move_pages/test_cases/move_pages04.txt @@ -0,0 +1 @@ +move_pages04 1 TFAIL : diff --git a/test/user_space/move_pages/test_cases/move_pages06.txt b/test/user_space/move_pages/test_cases/move_pages06.txt new file mode 100644 index 00000000..a206cf92 --- /dev/null +++ b/test/user_space/move_pages/test_cases/move_pages06.txt @@ -0,0 +1 @@ +move_pages06 1 TFAIL : diff --git a/test/user_space/move_pages/test_cases/move_pages07.txt b/test/user_space/move_pages/test_cases/move_pages07.txt new file mode 100644 index 00000000..a278595f --- /dev/null +++ b/test/user_space/move_pages/test_cases/move_pages07.txt @@ -0,0 +1 @@ +move_pages07 1 TFAIL : diff --git a/test/user_space/move_pages/test_cases/move_pages08.txt b/test/user_space/move_pages/test_cases/move_pages08.txt new file mode 100644 index 00000000..b7b05477 --- /dev/null +++ b/test/user_space/move_pages/test_cases/move_pages08.txt @@ -0,0 +1,2 @@ +move_pages08 1 TCONF : +move_pages08 2 TCONF : diff --git a/test/user_space/move_pages/test_cases/move_pages09.txt b/test/user_space/move_pages/test_cases/move_pages09.txt new file mode 100644 index 00000000..4aed91df --- /dev/null +++ b/test/user_space/move_pages/test_cases/move_pages09.txt @@ -0,0 +1 @@ +move_pages09 1 TPASS : diff --git a/test/user_space/move_pages/test_cases/move_pages10.txt b/test/user_space/move_pages/test_cases/move_pages10.txt new file mode 100644 index 00000000..79c60a60 --- /dev/null +++ b/test/user_space/move_pages/test_cases/move_pages10.txt @@ -0,0 +1 @@ +move_pages10 1 TFAIL : diff --git a/test/user_space/patch/pager_copy_from.patch b/test/user_space/patch/pager_copy_from.patch new file mode 100644 index 00000000..3f3a87d5 --- /dev/null +++ b/test/user_space/patch/pager_copy_from.patch @@ -0,0 +1,180 @@ +diff --git a/kernel/pager.c b/kernel/pager.c +index 2fc1a72..a5e7233 100644 +--- a/kernel/pager.c ++++ b/kernel/pager.c +@@ -65,7 +65,8 @@ + * the mlockcntnr structure is used. + * The mlockcntnr keeps the list of + */ +-#define MLOCKADDRS_SIZE 128 ++//#define MLOCKADDRS_SIZE 128 ++#define MLOCKADDRS_SIZE 8 + struct addrpair { + unsigned long start; + unsigned long end; +@@ -296,6 +297,8 @@ pager_open(struct swapinfo *si, char *fname, int flag, int mode) + { + int fd; + copy_to_user(si->udata_buf, fname, strlen(fname) + 1); ++// kprintf("%s: copy_to_user si->udata_buf:%s,fname:%s\n", ++// __FUNCTION__, si->udata_buf, fname); + fd = linux_open(si->udata_buf, flag, mode); + return fd; + } +@@ -304,6 +307,8 @@ static int + pager_unlink(struct swapinfo *si, char *fname) + { + copy_to_user(si->udata_buf, fname, strlen(fname) + 1); ++// kprintf("%s: copy_to_user si->udata_buf:%s,fname:%s\n", ++// __FUNCTION__, si->udata_buf, fname); + return linux_unlink(si->udata_buf); + } + +@@ -403,6 +408,9 @@ mlocklist_morereq(struct swapinfo *si, unsigned long *start) + { + struct areaent went,*ent = si->mlock_area.tail; + copy_from_user(&went, ent, sizeof(struct areaent)); ++ kprintf("%s: copy_from_user went.count:%d,ent->count:%d\n", ++ __FUNCTION__, went.count, ent->count); //test case 1 ++ + + dkprintf("mlocklist_morereq: start = %ld and = %ld\n", + went.pair[went.count].start, went.pair[went.count].end); +@@ -421,6 +429,8 @@ arealist_alloc(struct swapinfo *si, struct arealist *areap) + if (areap->head == NULL) return -ENOMEM; + memset(&went, 0, sizeof(struct areaent)); + copy_to_user(areap->head, &went, sizeof(struct areaent)); ++// kprintf("%s: copy_to_user went.count:%d,areap->head->count:%d\n", ++// __FUNCTION__, went.count, areap->head->count); //test case + return 0; + } + +@@ -465,6 +475,8 @@ arealist_get(struct swapinfo *si, struct addrpair **pair, struct arealist *area) + memset(&wtmp, 0, sizeof(struct areaent)); + copy_to_user(tmp, &wtmp, sizeof(struct areaent)); + copy_to_user(&(area->tail->next), &tmp, sizeof(struct areaent *)); ++// kprintf("%s: copy_to_user wtmp.count:%d,tmp->count:%d area->tail->next %x:%x\n", ++// __FUNCTION__, wtmp.count, tmp->count, area->tail->next, tmp); //test case + + area->tail = tmp; + if (pair) *pair = area->tail->pair; +@@ -476,8 +488,13 @@ arealist_update(int cnt, struct arealist *area) + { + int i; + copy_from_user(&i, &(area->tail->count), sizeof(int)); ++ kprintf("%s: copy_from_user i:%d, area->tail->count:%d\n", ++ __FUNCTION__, i, area->tail->count); //test case 2 ++ + i += cnt; + copy_to_user(&(area->tail->count), &i, sizeof(int)); ++// kprintf("%s: copy_to_user i:%d, area->tail->count:%d\n", ++// __FUNCTION__, i, area->tail->count); //test case + area->count += cnt; + } + +@@ -492,6 +509,8 @@ arealist_add(struct swapinfo *si, unsigned long start, unsigned long end, + if (cc < 0) return -1; + waddr.start = start; waddr.end = end; waddr.flag = flag; + copy_to_user(addr, &waddr, sizeof(struct addrpair)); ++// kprintf("%s: copy_to_user addr->start:%x, waddr.strt:%x\n", ++// __FUNCTION__, addr->start, waddr.start); //test case + + arealist_update(1, area); + return 0; +@@ -510,11 +529,17 @@ arealist_preparewrite(struct arealist *areap, struct swap_areainfo *info, + for (ent = areap->head; ent != NULL; ent = ent->next) { + int i; + copy_from_user(&went, ent, sizeof(struct areaent)); ++ kprintf("%s: copy_from_user went.count:%d,ent->count:%d\n", ++ __FUNCTION__, went.count, ent->count); //test case 3 ++ + for (i = 0; i < went.count; i++, count++) { + ssize_t sz = went.pair[i].end - went.pair[i].start; + copy_to_user(&(info[count].start), &(went.pair[i].start), sizeof(unsigned long)); + copy_to_user(&(info[count].end), &(went.pair[i].end), sizeof(unsigned long)); + copy_to_user(&(info[count].flag), &(went.pair[i].flag), sizeof(unsigned long)); ++// kprintf("%s: copy_to_user info[%d].start:%x,end:%x,flag:%x ,went.pair[%d].start:%x,end:%x,flag:%x\n", ++// __FUNCTION__, count, info[count].start, info[count].end, info[count].flag, ++// i, went.pair[i].start, went.pair[i].end, went.pair[i].flag); //test case + if (flag) { /* position in file */ + + pos = off + totsz; +@@ -526,6 +551,8 @@ arealist_preparewrite(struct arealist *areap, struct swap_areainfo *info, + } + } + copy_to_user(&(info[count].pos), &pos, sizeof(unsigned long)); ++// kprintf("%s: copy_to_user info[%d].pos:%x,pos:%x\n", ++// __FUNCTION__, count, info[count].pos, pos); + totsz += sz; + } + } +@@ -675,8 +702,10 @@ do_pagein(int flag) + // ihk_mc_pt_print_pte(vm->address_space->page_table, (void*) si->swap_info[i].start); + } + linux_close(fd); ++#if 0 + print_region("after pagin", vm); + dkprintf("do_pagein: done, currss(%lx)\n", vm->currss); ++#endif + vm->swapinfo = NULL; + kfree(si->swapfname); + kfree(si); +@@ -742,6 +771,8 @@ do_pageout(char *fname, void *buf, size_t size, int flag) + } + + copy_to_user(si->udata_buf, si->swapfname, strlen(si->swapfname) + 1); ++ kprintf("%s: copy_to_user si->udata_buf:%s,si->swapfname:%s\n", ++ __FUNCTION__, si->udata_buf, si->swapfname); + fd = linux_open(si->udata_buf, O_RDWR|O_CREAT|O_TRUNC, 0600); + if (fd < 0) { + ekprintf("do_pageout: Cannot open/create file: %s\n", fname); +@@ -807,8 +838,10 @@ do_pageout(char *fname, void *buf, size_t size, int flag) + } + } + } ++#if 0 + arealist_print("SWAP", &si->swap_area, si->swap_area.count); + arealist_print("MLOCK", &si->mlock_area, si->mlock_area.count); ++#endif + si->swap_info = myalloc(si, sizeof(struct swap_areainfo)* si->swap_area.count); + si->mlock_info = myalloc(si, sizeof(struct swap_areainfo)* si->mlock_area.count); + if (si->swap_info == NULL || si->mlock_info == NULL) goto nomem; +@@ -819,6 +852,8 @@ do_pageout(char *fname, void *buf, size_t size, int flag) + copy_to_user(&(si->swphdr->version), MCKERNEL_SWAP_VERSION, SWAP_HLEN); + copy_to_user(&(si->swphdr->count_sarea), &(si->swap_area.count), sizeof(unsigned int)); + copy_to_user(&(si->swphdr->count_marea), &(si->mlock_area.count), sizeof(unsigned int)); ++// kprintf("%s: copy_to_user si->swphdr->magic:%s,si->swphdr->version:%s,si->swphdr->count_sarea:%d,si->swphdr->count_marea:%d,si->swap_area.count:%d,si->mlock_area.count:%d\n", ++// __FUNCTION__, si->swphdr->magic, si->swphdr->version, si->swphdr->count_sarea, si->swphdr->count_marea, si->swap_area.count, si->mlock_area.count); + if ((cc = pager_write(fd, si->swphdr, sizeof(struct swap_header))) + != sizeof(struct swap_header)) { + if (cc >= 0) +@@ -844,6 +879,9 @@ do_pageout(char *fname, void *buf, size_t size, int flag) + for (i = 0; i < si->swap_area.count; i++) { + struct swap_areainfo sw_info; + copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo)); ++ kprintf("%s:1 copy_from_user %x:%x\n", ++ __FUNCTION__, sw_info.start, si->swap_info[i].start); // test case 4 ++ + sz = sw_info.end - sw_info.start; + if ((cc = pager_write(fd, (void*) sw_info.start, sz)) != sz) { + if (cc >= 0) +@@ -859,6 +897,9 @@ do_pageout(char *fname, void *buf, size_t size, int flag) + for (i = 0; i < si->swap_area.count; i++) { + struct swap_areainfo sw_info; + copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo)); ++ kprintf("%s:2 copy_from_user %x:%x\n", ++ __FUNCTION__, sw_info.start, si->swap_info[i].start); // test case 4 ++ + cc = ihk_mc_pt_free_range(vm->address_space->page_table, + vm, + (void*) sw_info.start, +@@ -880,6 +921,9 @@ do_pageout(char *fname, void *buf, size_t size, int flag) + for (i = 0; i < si->swap_area.count; i++) { + struct swap_areainfo sw_info; + copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo)); ++ kprintf("%s:3 copy_from_user %x:%x\n", ++ __FUNCTION__, sw_info.start, si->swap_info[i].start); // test case 4 ++ + sz = sw_info.end - sw_info.start; + cc = linux_munmap((void*) sw_info.start, sz, 0); + if (cc < 0) { diff --git a/test/user_space/patch/pager_copy_to_01.patch b/test/user_space/patch/pager_copy_to_01.patch new file mode 100644 index 00000000..5e9f87a4 --- /dev/null +++ b/test/user_space/patch/pager_copy_to_01.patch @@ -0,0 +1,180 @@ +diff --git a/kernel/pager.c b/kernel/pager.c +index 2fc1a72..bbffba7 100644 +--- a/kernel/pager.c ++++ b/kernel/pager.c +@@ -65,7 +65,8 @@ + * the mlockcntnr structure is used. + * The mlockcntnr keeps the list of + */ +-#define MLOCKADDRS_SIZE 128 ++//#define MLOCKADDRS_SIZE 128 ++#define MLOCKADDRS_SIZE 8 + struct addrpair { + unsigned long start; + unsigned long end; +@@ -296,6 +297,8 @@ pager_open(struct swapinfo *si, char *fname, int flag, int mode) + { + int fd; + copy_to_user(si->udata_buf, fname, strlen(fname) + 1); ++// kprintf("%s: copy_to_user si->udata_buf:%s,fname:%s\n", ++// __FUNCTION__, si->udata_buf, fname); + fd = linux_open(si->udata_buf, flag, mode); + return fd; + } +@@ -304,6 +307,8 @@ static int + pager_unlink(struct swapinfo *si, char *fname) + { + copy_to_user(si->udata_buf, fname, strlen(fname) + 1); ++// kprintf("%s: copy_to_user si->udata_buf:%s,fname:%s\n", ++// __FUNCTION__, si->udata_buf, fname); + return linux_unlink(si->udata_buf); + } + +@@ -403,6 +408,9 @@ mlocklist_morereq(struct swapinfo *si, unsigned long *start) + { + struct areaent went,*ent = si->mlock_area.tail; + copy_from_user(&went, ent, sizeof(struct areaent)); ++// kprintf("%s: copy_from_user went.count:%d,ent->count:%d\n", ++// __FUNCTION__, went.count, ent->count); //test case 1 ++ + + dkprintf("mlocklist_morereq: start = %ld and = %ld\n", + went.pair[went.count].start, went.pair[went.count].end); +@@ -421,6 +429,8 @@ arealist_alloc(struct swapinfo *si, struct arealist *areap) + if (areap->head == NULL) return -ENOMEM; + memset(&went, 0, sizeof(struct areaent)); + copy_to_user(areap->head, &went, sizeof(struct areaent)); ++// kprintf("%s: copy_to_user went.count:%d,areap->head->count:%d\n", ++// __FUNCTION__, went.count, areap->head->count); //test case + return 0; + } + +@@ -465,6 +475,8 @@ arealist_get(struct swapinfo *si, struct addrpair **pair, struct arealist *area) + memset(&wtmp, 0, sizeof(struct areaent)); + copy_to_user(tmp, &wtmp, sizeof(struct areaent)); + copy_to_user(&(area->tail->next), &tmp, sizeof(struct areaent *)); ++// kprintf("%s: copy_to_user wtmp.count:%d,tmp->count:%d area->tail->next %x:%x\n", ++// __FUNCTION__, wtmp.count, tmp->count, area->tail->next, tmp); //test case + + area->tail = tmp; + if (pair) *pair = area->tail->pair; +@@ -476,8 +488,13 @@ arealist_update(int cnt, struct arealist *area) + { + int i; + copy_from_user(&i, &(area->tail->count), sizeof(int)); ++// kprintf("%s: copy_from_user i:%d, area->tail->count:%d\n", ++// __FUNCTION__, i, area->tail->count); //test case 2 ++ + i += cnt; + copy_to_user(&(area->tail->count), &i, sizeof(int)); ++ kprintf("%s: copy_to_user i:%d, area->tail->count:%d\n", ++ __FUNCTION__, i, area->tail->count); //test case + area->count += cnt; + } + +@@ -492,6 +509,8 @@ arealist_add(struct swapinfo *si, unsigned long start, unsigned long end, + if (cc < 0) return -1; + waddr.start = start; waddr.end = end; waddr.flag = flag; + copy_to_user(addr, &waddr, sizeof(struct addrpair)); ++ kprintf("%s: copy_to_user addr->start:%x, waddr.start:%x\n", ++ __FUNCTION__, addr->start, waddr.start); //test case + + arealist_update(1, area); + return 0; +@@ -510,11 +529,17 @@ arealist_preparewrite(struct arealist *areap, struct swap_areainfo *info, + for (ent = areap->head; ent != NULL; ent = ent->next) { + int i; + copy_from_user(&went, ent, sizeof(struct areaent)); ++// kprintf("%s: copy_from_user went.count:%d,ent->count:%d\n", ++// __FUNCTION__, went.count, ent->count); //test case 3 ++ + for (i = 0; i < went.count; i++, count++) { + ssize_t sz = went.pair[i].end - went.pair[i].start; + copy_to_user(&(info[count].start), &(went.pair[i].start), sizeof(unsigned long)); + copy_to_user(&(info[count].end), &(went.pair[i].end), sizeof(unsigned long)); + copy_to_user(&(info[count].flag), &(went.pair[i].flag), sizeof(unsigned long)); ++// kprintf("%s: copy_to_user info[%d].start:%x,end:%x,flag:%x ,went.pair[%d].start:%x,end:%x,flag:%x\n", ++// __FUNCTION__, count, info[count].start, info[count].end, info[count].flag, ++// i, went.pair[i].start, went.pair[i].end, went.pair[i].flag); //test case + if (flag) { /* position in file */ + + pos = off + totsz; +@@ -526,6 +551,8 @@ arealist_preparewrite(struct arealist *areap, struct swap_areainfo *info, + } + } + copy_to_user(&(info[count].pos), &pos, sizeof(unsigned long)); ++// kprintf("%s: copy_to_user info[%d].pos:%x,pos:%x\n", ++// __FUNCTION__, count, info[count].pos, pos); + totsz += sz; + } + } +@@ -675,8 +702,10 @@ do_pagein(int flag) + // ihk_mc_pt_print_pte(vm->address_space->page_table, (void*) si->swap_info[i].start); + } + linux_close(fd); ++#if 0 + print_region("after pagin", vm); + dkprintf("do_pagein: done, currss(%lx)\n", vm->currss); ++#endif + vm->swapinfo = NULL; + kfree(si->swapfname); + kfree(si); +@@ -742,6 +771,8 @@ do_pageout(char *fname, void *buf, size_t size, int flag) + } + + copy_to_user(si->udata_buf, si->swapfname, strlen(si->swapfname) + 1); ++ kprintf("%s: copy_to_user si->udata_buf:%s,si->swapfname:%s\n", ++ __FUNCTION__, si->udata_buf, si->swapfname); + fd = linux_open(si->udata_buf, O_RDWR|O_CREAT|O_TRUNC, 0600); + if (fd < 0) { + ekprintf("do_pageout: Cannot open/create file: %s\n", fname); +@@ -807,8 +838,10 @@ do_pageout(char *fname, void *buf, size_t size, int flag) + } + } + } ++#if 0 + arealist_print("SWAP", &si->swap_area, si->swap_area.count); + arealist_print("MLOCK", &si->mlock_area, si->mlock_area.count); ++#endif + si->swap_info = myalloc(si, sizeof(struct swap_areainfo)* si->swap_area.count); + si->mlock_info = myalloc(si, sizeof(struct swap_areainfo)* si->mlock_area.count); + if (si->swap_info == NULL || si->mlock_info == NULL) goto nomem; +@@ -819,6 +852,8 @@ do_pageout(char *fname, void *buf, size_t size, int flag) + copy_to_user(&(si->swphdr->version), MCKERNEL_SWAP_VERSION, SWAP_HLEN); + copy_to_user(&(si->swphdr->count_sarea), &(si->swap_area.count), sizeof(unsigned int)); + copy_to_user(&(si->swphdr->count_marea), &(si->mlock_area.count), sizeof(unsigned int)); ++ kprintf("%s: copy_to_user si->swphdr->magic:%s,si->swphdr->version:%s,si->swphdr->count_sarea:%d,si->swphdr->count_marea:%d,si->swap_area.count:%d,si->mlock_area.count:%d\n", ++ __FUNCTION__, si->swphdr->magic, si->swphdr->version, si->swphdr->count_sarea, si->swphdr->count_marea, si->swap_area.count, si->mlock_area.count); + if ((cc = pager_write(fd, si->swphdr, sizeof(struct swap_header))) + != sizeof(struct swap_header)) { + if (cc >= 0) +@@ -844,6 +879,9 @@ do_pageout(char *fname, void *buf, size_t size, int flag) + for (i = 0; i < si->swap_area.count; i++) { + struct swap_areainfo sw_info; + copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo)); ++// kprintf("%s:1 copy_from_user %x:%x\n", ++// __FUNCTION__, sw_info.start, si->swap_info[i].start); // test case 4 ++ + sz = sw_info.end - sw_info.start; + if ((cc = pager_write(fd, (void*) sw_info.start, sz)) != sz) { + if (cc >= 0) +@@ -859,6 +897,9 @@ do_pageout(char *fname, void *buf, size_t size, int flag) + for (i = 0; i < si->swap_area.count; i++) { + struct swap_areainfo sw_info; + copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo)); ++// kprintf("%s:2 copy_from_user %x:%x\n", ++// __FUNCTION__, sw_info.start, si->swap_info[i].start); // test case 4 ++ + cc = ihk_mc_pt_free_range(vm->address_space->page_table, + vm, + (void*) sw_info.start, +@@ -880,6 +921,9 @@ do_pageout(char *fname, void *buf, size_t size, int flag) + for (i = 0; i < si->swap_area.count; i++) { + struct swap_areainfo sw_info; + copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo)); ++// kprintf("%s:3 copy_from_user %x:%x\n", ++// __FUNCTION__, sw_info.start, si->swap_info[i].start); // test case 4 ++ + sz = sw_info.end - sw_info.start; + cc = linux_munmap((void*) sw_info.start, sz, 0); + if (cc < 0) { diff --git a/test/user_space/patch/pager_copy_to_02.patch b/test/user_space/patch/pager_copy_to_02.patch new file mode 100644 index 00000000..f36fdb37 --- /dev/null +++ b/test/user_space/patch/pager_copy_to_02.patch @@ -0,0 +1,180 @@ +diff --git a/kernel/pager.c b/kernel/pager.c +index 2fc1a72..b644460 100644 +--- a/kernel/pager.c ++++ b/kernel/pager.c +@@ -65,7 +65,8 @@ + * the mlockcntnr structure is used. + * The mlockcntnr keeps the list of + */ +-#define MLOCKADDRS_SIZE 128 ++//#define MLOCKADDRS_SIZE 128 ++#define MLOCKADDRS_SIZE 8 + struct addrpair { + unsigned long start; + unsigned long end; +@@ -296,6 +297,8 @@ pager_open(struct swapinfo *si, char *fname, int flag, int mode) + { + int fd; + copy_to_user(si->udata_buf, fname, strlen(fname) + 1); ++ kprintf("%s: copy_to_user si->udata_buf:%s,fname:%s\n", ++ __FUNCTION__, si->udata_buf, fname); + fd = linux_open(si->udata_buf, flag, mode); + return fd; + } +@@ -304,6 +307,8 @@ static int + pager_unlink(struct swapinfo *si, char *fname) + { + copy_to_user(si->udata_buf, fname, strlen(fname) + 1); ++ kprintf("%s: copy_to_user si->udata_buf:%s,fname:%s\n", ++ __FUNCTION__, si->udata_buf, fname); + return linux_unlink(si->udata_buf); + } + +@@ -403,6 +408,9 @@ mlocklist_morereq(struct swapinfo *si, unsigned long *start) + { + struct areaent went,*ent = si->mlock_area.tail; + copy_from_user(&went, ent, sizeof(struct areaent)); ++// kprintf("%s: copy_from_user went.count:%d,ent->count:%d\n", ++// __FUNCTION__, went.count, ent->count); //test case 1 ++ + + dkprintf("mlocklist_morereq: start = %ld and = %ld\n", + went.pair[went.count].start, went.pair[went.count].end); +@@ -421,6 +429,8 @@ arealist_alloc(struct swapinfo *si, struct arealist *areap) + if (areap->head == NULL) return -ENOMEM; + memset(&went, 0, sizeof(struct areaent)); + copy_to_user(areap->head, &went, sizeof(struct areaent)); ++ kprintf("%s: copy_to_user went.count:%d,areap->head->count:%d\n", ++ __FUNCTION__, went.count, areap->head->count); //test case + return 0; + } + +@@ -465,6 +475,8 @@ arealist_get(struct swapinfo *si, struct addrpair **pair, struct arealist *area) + memset(&wtmp, 0, sizeof(struct areaent)); + copy_to_user(tmp, &wtmp, sizeof(struct areaent)); + copy_to_user(&(area->tail->next), &tmp, sizeof(struct areaent *)); ++ kprintf("%s: copy_to_user wtmp.count:%d,tmp->count:%d area->tail->next %x:%x\n", ++ __FUNCTION__, wtmp.count, tmp->count, area->tail->next, tmp); //test case + + area->tail = tmp; + if (pair) *pair = area->tail->pair; +@@ -476,8 +488,13 @@ arealist_update(int cnt, struct arealist *area) + { + int i; + copy_from_user(&i, &(area->tail->count), sizeof(int)); ++// kprintf("%s: copy_from_user i:%d, area->tail->count:%d\n", ++// __FUNCTION__, i, area->tail->count); //test case 2 ++ + i += cnt; + copy_to_user(&(area->tail->count), &i, sizeof(int)); ++// kprintf("%s: copy_to_user i:%d, area->tail->count:%d\n", ++// __FUNCTION__, i, area->tail->count); //test case + area->count += cnt; + } + +@@ -492,6 +509,8 @@ arealist_add(struct swapinfo *si, unsigned long start, unsigned long end, + if (cc < 0) return -1; + waddr.start = start; waddr.end = end; waddr.flag = flag; + copy_to_user(addr, &waddr, sizeof(struct addrpair)); ++// kprintf("%s: copy_to_user addr->start:%x, waddr.start:%x\n", ++// __FUNCTION__, addr->start, waddr.start); //test case + + arealist_update(1, area); + return 0; +@@ -510,11 +529,17 @@ arealist_preparewrite(struct arealist *areap, struct swap_areainfo *info, + for (ent = areap->head; ent != NULL; ent = ent->next) { + int i; + copy_from_user(&went, ent, sizeof(struct areaent)); ++// kprintf("%s: copy_from_user went.count:%d,ent->count:%d\n", ++// __FUNCTION__, went.count, ent->count); //test case 3 ++ + for (i = 0; i < went.count; i++, count++) { + ssize_t sz = went.pair[i].end - went.pair[i].start; + copy_to_user(&(info[count].start), &(went.pair[i].start), sizeof(unsigned long)); + copy_to_user(&(info[count].end), &(went.pair[i].end), sizeof(unsigned long)); + copy_to_user(&(info[count].flag), &(went.pair[i].flag), sizeof(unsigned long)); ++ kprintf("%s: copy_to_user info[%d].start:%x,end:%x,flag:%x ,went.pair[%d].start:%x,end:%x,flag:%x\n", ++ __FUNCTION__, count, info[count].start, info[count].end, info[count].flag, ++ i, went.pair[i].start, went.pair[i].end, went.pair[i].flag); //test case + if (flag) { /* position in file */ + + pos = off + totsz; +@@ -526,6 +551,8 @@ arealist_preparewrite(struct arealist *areap, struct swap_areainfo *info, + } + } + copy_to_user(&(info[count].pos), &pos, sizeof(unsigned long)); ++ kprintf("%s: copy_to_user info[%d].pos:%x,pos:%x\n", ++ __FUNCTION__, count, info[count].pos, pos); + totsz += sz; + } + } +@@ -675,8 +702,10 @@ do_pagein(int flag) + // ihk_mc_pt_print_pte(vm->address_space->page_table, (void*) si->swap_info[i].start); + } + linux_close(fd); ++#if 0 + print_region("after pagin", vm); + dkprintf("do_pagein: done, currss(%lx)\n", vm->currss); ++#endif + vm->swapinfo = NULL; + kfree(si->swapfname); + kfree(si); +@@ -742,6 +771,8 @@ do_pageout(char *fname, void *buf, size_t size, int flag) + } + + copy_to_user(si->udata_buf, si->swapfname, strlen(si->swapfname) + 1); ++// kprintf("%s: copy_to_user si->udata_buf:%s,si->swapfname:%s\n", ++// __FUNCTION__, si->udata_buf, si->swapfname); + fd = linux_open(si->udata_buf, O_RDWR|O_CREAT|O_TRUNC, 0600); + if (fd < 0) { + ekprintf("do_pageout: Cannot open/create file: %s\n", fname); +@@ -807,8 +838,10 @@ do_pageout(char *fname, void *buf, size_t size, int flag) + } + } + } ++#if 0 + arealist_print("SWAP", &si->swap_area, si->swap_area.count); + arealist_print("MLOCK", &si->mlock_area, si->mlock_area.count); ++#endif + si->swap_info = myalloc(si, sizeof(struct swap_areainfo)* si->swap_area.count); + si->mlock_info = myalloc(si, sizeof(struct swap_areainfo)* si->mlock_area.count); + if (si->swap_info == NULL || si->mlock_info == NULL) goto nomem; +@@ -819,6 +852,8 @@ do_pageout(char *fname, void *buf, size_t size, int flag) + copy_to_user(&(si->swphdr->version), MCKERNEL_SWAP_VERSION, SWAP_HLEN); + copy_to_user(&(si->swphdr->count_sarea), &(si->swap_area.count), sizeof(unsigned int)); + copy_to_user(&(si->swphdr->count_marea), &(si->mlock_area.count), sizeof(unsigned int)); ++// kprintf("%s: copy_to_user si->swphdr->magic:%s,si->swphdr->version:%s,si->swphdr->count_sarea:%d,si->swphdr->count_marea:%d,si->swap_area.count:%d,si->mlock_area.count:%d\n", ++// __FUNCTION__, si->swphdr->magic, si->swphdr->version, si->swphdr->count_sarea, si->swphdr->count_marea, si->swap_area.count, si->mlock_area.count); + if ((cc = pager_write(fd, si->swphdr, sizeof(struct swap_header))) + != sizeof(struct swap_header)) { + if (cc >= 0) +@@ -844,6 +879,9 @@ do_pageout(char *fname, void *buf, size_t size, int flag) + for (i = 0; i < si->swap_area.count; i++) { + struct swap_areainfo sw_info; + copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo)); ++// kprintf("%s:1 copy_from_user %x:%x\n", ++// __FUNCTION__, sw_info.start, si->swap_info[i].start); // test case 4 ++ + sz = sw_info.end - sw_info.start; + if ((cc = pager_write(fd, (void*) sw_info.start, sz)) != sz) { + if (cc >= 0) +@@ -859,6 +897,9 @@ do_pageout(char *fname, void *buf, size_t size, int flag) + for (i = 0; i < si->swap_area.count; i++) { + struct swap_areainfo sw_info; + copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo)); ++// kprintf("%s:2 copy_from_user %x:%x\n", ++// __FUNCTION__, sw_info.start, si->swap_info[i].start); // test case 4 ++ + cc = ihk_mc_pt_free_range(vm->address_space->page_table, + vm, + (void*) sw_info.start, +@@ -880,6 +921,9 @@ do_pageout(char *fname, void *buf, size_t size, int flag) + for (i = 0; i < si->swap_area.count; i++) { + struct swap_areainfo sw_info; + copy_from_user(&sw_info, &(si->swap_info[i]), sizeof(struct swap_areainfo)); ++// kprintf("%s:3 copy_from_user %x:%x\n", ++// __FUNCTION__, sw_info.start, si->swap_info[i].start); // test case 4 ++ + sz = sw_info.end - sw_info.start; + cc = linux_munmap((void*) sw_info.start, sz, 0); + if (cc < 0) { diff --git a/test/user_space/patch/qlmpilib.patch b/test/user_space/patch/qlmpilib.patch new file mode 100644 index 00000000..f50f8531 --- /dev/null +++ b/test/user_space/patch/qlmpilib.patch @@ -0,0 +1,13 @@ +diff --git a/executer/user/qlmpilib.c b/executer/user/qlmpilib.c +index 7fcbcb5..e373839 100644 +--- a/executer/user/qlmpilib.c ++++ b/executer/user/qlmpilib.c +@@ -158,7 +158,7 @@ int ql_client(int *argc,char ***argv) + syscall(803); + rc = PMI_Barrier(); + +- rc = swapout(swap_file, buffer, BUF_SIZE, 1); ++ rc = swapout(swap_file, buffer, BUF_SIZE, 3); + + #ifdef QL_DEBUG + printf(" swapout rc=%d\n",rc); diff --git a/test/user_space/patch/syscall.patch b/test/user_space/patch/syscall.patch new file mode 100644 index 00000000..d9010bac --- /dev/null +++ b/test/user_space/patch/syscall.patch @@ -0,0 +1,85 @@ +diff --git a/arch/x86_64/kernel/syscall.c b/arch/x86_64/kernel/syscall.c +index 29dbd04..66f77b5 100644 +--- a/arch/x86_64/kernel/syscall.c ++++ b/arch/x86_64/kernel/syscall.c +@@ -1936,6 +1936,8 @@ int do_process_vm_read_writev(int pid, + struct vm_range *range; + struct mcs_rwlock_node_irqsave lock; + struct mcs_rwlock_node update_lock; ++ kprintf("%s: arg2_addr:%x,arg4_addr:%x\n", ++ __FUNCTION__, local_iov, remote_iov); //PATCH + + /* Sanity checks */ + if (flags) { +@@ -2212,6 +2214,8 @@ int move_pages_smp_handler(int cpu_index, int nr_cpus, void *arg) + int count = mpsr->count; + struct page_table *save_pt; + extern struct page_table *get_init_page_table(void); ++ kprintf("%s: mpsr->user_virt_addr:%x,mpsr->user_nodes:%x,mpsr->user_status:%x\n", ++ __FUNCTION__, mpsr->user_virt_addr, mpsr->user_nodes, mpsr->user_status); //PATCH + + i_s = (count / nr_cpus) * cpu_index; + i_e = i_s + (count / nr_cpus); +diff --git a/kernel/futex.c b/kernel/futex.c +index 495ee50..a7d08e2 100644 +--- a/kernel/futex.c ++++ b/kernel/futex.c +@@ -749,6 +749,8 @@ static int futex_wait_setup(uint32_t __user *uaddr, uint32_t val, int fshared, + *hb = queue_lock(q); + + ret = get_futex_value_locked(&uval, uaddr); ++ kprintf("get_futex_value_locked: uval:%d,*uaddr:%d,uaddr:%x\n", ++ uval, *uaddr, uaddr); //PATCH + if (ret) { + queue_unlock(q, *hb); + put_futex_key(fshared, &q->key); +diff --git a/kernel/syscall.c b/kernel/syscall.c +index e7fed5d..9c174c9 100644 +--- a/kernel/syscall.c ++++ b/kernel/syscall.c +@@ -3827,6 +3827,8 @@ mc_perf_event_alloc(struct perf_event_attr *attr) + if (!attr) { + return NULL; + } ++ kprintf("%s: attr->disabled:%d,attr->exclude_kernel:%d\n", ++ __FUNCTION__, attr->disabled, attr->exclude_kernel); //PATCH + + event = kmalloc(sizeof(struct mc_perf_event), IHK_MC_AP_NOWAIT); + if (!event) { +@@ -5340,6 +5342,9 @@ SYSCALL_DECLARE(futex) + struct ihk_os_cpu_monitor *monitor = cpu_local_var(monitor); + + monitor->status = IHK_OS_MONITOR_KERNEL_HEAVY; ++ ++ kprintf("%s:*uaddr:%d,uaddr:%x\n", ++ __FUNCTION__, *uaddr, uaddr); //PATCH + + /* Cross-address space futex? */ + if (op & FUTEX_PRIVATE_FLAG) { +@@ -8720,6 +8725,8 @@ SYSCALL_DECLARE(move_pages) + int ret = 0; + + unsigned long t_s, t_e; ++ kprintf("%s: user_virt_addr:%x,user_nodes:%x,user_status:%x\n", ++ __FUNCTION__, user_virt_addr, user_nodes, user_status); //PATCH + + t_s = rdtsc(); + +@@ -8905,6 +8912,8 @@ SYSCALL_DECLARE(process_vm_writev) + (const struct iovec *)ihk_mc_syscall_arg3(ctx); + unsigned long riovcnt = ihk_mc_syscall_arg4(ctx); + unsigned long flags = ihk_mc_syscall_arg5(ctx); ++ kprintf("%s: arg2_addr:%x,arg4_addr:%x\n", ++ __FUNCTION__, local_iov, remote_iov); //PATCH + + return do_process_vm_read_writev(pid, local_iov, liovcnt, + remote_iov, riovcnt, flags, PROCESS_VM_WRITE); +@@ -8920,6 +8929,8 @@ SYSCALL_DECLARE(process_vm_readv) + (const struct iovec *)ihk_mc_syscall_arg3(ctx); + unsigned long riovcnt = ihk_mc_syscall_arg4(ctx); + unsigned long flags = ihk_mc_syscall_arg5(ctx); ++ kprintf("%s: arg2_addr:%x,arg4_addr:%x\n", ++ __FUNCTION__, local_iov, remote_iov); //PATCH + + return do_process_vm_read_writev(pid, local_iov, liovcnt, + remote_iov, riovcnt, flags, PROCESS_VM_READ); diff --git a/test/user_space/patch_and_build.sh b/test/user_space/patch_and_build.sh new file mode 100755 index 00000000..dd952e22 --- /dev/null +++ b/test/user_space/patch_and_build.sh @@ -0,0 +1,21 @@ +#!/bin/sh +source ./config +MC_HOME=${SRC_PATH} +cd $MC_HOME + +if [ $# -eq 1 ]; then + PATCH_NAME=$1 + git reset --hard HEAD + patch -p1 < ${TEST_DIR}/patch/${PATCH_NAME} +else + git reset --hard HEAD +fi +cd $MC_HOME +make clean +./configure --prefix=${MCMOD_DIR} --with-target=smp-x86 --with-mpi=/usr/lib64/mpich-3.2 --enable-qlmpi $* >/tmp/install.log +make >> /tmp/install.log +make install >> /tmp/install.log + +# for wallaby +chmod 777 ${MCMOD_DIR}/etc + diff --git a/test/user_space/perf_event_open/config b/test/user_space/perf_event_open/config new file mode 100644 index 00000000..7692ff25 --- /dev/null +++ b/test/user_space/perf_event_open/config @@ -0,0 +1,2 @@ +MCPATH=/home/iizuka/mckernel +LTP_EXE_DIR=/home/iizuka/LTP/perf_event_open diff --git a/test/user_space/perf_event_open/perf_event_open_test.sh b/test/user_space/perf_event_open/perf_event_open_test.sh new file mode 100755 index 00000000..f70e73cc --- /dev/null +++ b/test/user_space/perf_event_open/perf_event_open_test.sh @@ -0,0 +1,89 @@ +#!/bin/sh + +# Functions +function reboot() { + count=`pgrep -c -f 'mcexec '` + if [ ${count} -gt 0 ] + then +# echo "kill process :" ${count} + pgrep -l -f 'mcexec ' + pgrep -f 'mcexec ' | xargs sudo kill -9 + fi +# echo -n "mckernel stopping... " + sudo ${MCMOD_DIR}/sbin/mcstop+release.sh +# echo "done." + #sleep 1 + echo -n "mckernel reboot ...." + sudo ${MCMOD_DIR}/sbin/mcreboot.sh $* + echo "done." +} + +function ok_out() { + echo "[OK] ${TEST_PREFIX}`printf %03d ${TEST_NUM}` $1" + (( TEST_NUM++ )) + TEST_CODE=`printf %03d ${TEST_NUM}` +} + +function ng_out() { + echo "[NG] ${TEST_PREFIX}`printf %03d ${TEST_NUM}` $1" + exit 1 +} + +function ltp_test() { + TEST_NAME=$1 +#LTP programを実行 logを保存 + ${MCPATH}/bin/mcexec ${LTP_EXE_DIR}/${TEST_NAME} >./result/${TEST_NAME}.log + +#LTP log 確認 + NUM=`cat ./test_cases/${TEST_NAME}.txt |wc -l` + for i in `seq 1 ${NUM}` + do + G_TEXT=`head -n ${i} ./test_cases/${TEST_NAME}.txt | tail -n 1` + result=`grep "${G_TEXT}" ./result/${TEST_NAME}.log` + #echo ${G_TEXT} + rc=$? + if [ ${rc} -eq 0 ]; then + ok_out "parf_event_open: ${result}" + else + ng_out "parf_event_open: result of ${TEST_NAME} ${i} are different." + fi + done +} + +TEST_NUM=1 +TEST_CODE=001 +TEST_PREFIX=perf_ + +ME=`whoami` +if [ $# -ne 2 ]; then + source ./config +else + MCPATH=$1 + LTP_EXE_DIR=$2/perf_event_open +fi + +mkdir -p ./result +reboot +#LTP programを実行 logを保存 +mcexec ${LTP_EXE_DIR}/perf_event_open01 >./result/perf_event_open01.log + +#kmsgを保存 +sudo ${MCPATH}/sbin/ihkosctl 0 kmsg >./result/perf_event_open01.kmsg + +#kmsgで結果を出力する。 +NUM=`cat ./test_cases/perd_event_open01.kmsg.txt |wc -l` +for i in `seq 1 ${NUM}` +do + G_TEXT=`head -n ${i} ./test_cases/perd_event_open01.kmsg.txt | tail -n 1` + result=`grep ${G_TEXT} ./result/perf_event_open01.kmsg` + rc=$? + if [ ${rc} -eq 0 ]; then + text=`echo "perf_event_open: the value is over the function mc_perf_event_alloc:"` + ok_out "${text} ${G_TEXT}" + else + ng_out "perf_e nuvent_open: the value is not over the function mc_perf_event_alloc" + fi +done + +#LTP log 確認 +ltp_test "perf_event_open01" diff --git a/test/user_space/perf_event_open/test_cases/perd_event_open01.kmsg.txt b/test/user_space/perf_event_open/test_cases/perd_event_open01.kmsg.txt new file mode 100644 index 00000000..edc4adc7 --- /dev/null +++ b/test/user_space/perf_event_open/test_cases/perd_event_open01.kmsg.txt @@ -0,0 +1,2 @@ +attr->disabled:1 +attr->exclude_kernel:1 diff --git a/test/user_space/perf_event_open/test_cases/perf_event_open01.txt b/test/user_space/perf_event_open/test_cases/perf_event_open01.txt new file mode 100644 index 00000000..b330297e --- /dev/null +++ b/test/user_space/perf_event_open/test_cases/perf_event_open01.txt @@ -0,0 +1,6 @@ +perf_event_open01 1 TPASS : +perf_event_open01 2 TPASS : +perf_event_open01 3 TPASS : +perf_event_open01 4 TPASS : +perf_event_open01 5 TPASS : +perf_event_open01 6 TFAIL : diff --git a/test/user_space/process_vm/config b/test/user_space/process_vm/config new file mode 100644 index 00000000..2396798d --- /dev/null +++ b/test/user_space/process_vm/config @@ -0,0 +1,2 @@ +MCPATH=/home/iizuka/mckernel +LTP_EXE_DIR=/home/iizuka/LTP/process_vm diff --git a/test/user_space/process_vm/process_vm_readv_test.sh b/test/user_space/process_vm/process_vm_readv_test.sh new file mode 100755 index 00000000..60ae82f8 --- /dev/null +++ b/test/user_space/process_vm/process_vm_readv_test.sh @@ -0,0 +1,109 @@ +#!/bin/sh + +# Functions +function reboot() { + count=`pgrep -c -f 'mcexec '` + if [ ${count} -gt 0 ] + then +# echo "kill process :" ${count} + pgrep -l -f 'mcexec ' + pgrep -f 'mcexec ' | xargs sudo kill -9 + fi +# echo -n "mckernel stopping... " + sudo ${MCMOD_DIR}/sbin/mcstop+release.sh +# echo "done." + #sleep 1 + echo -n "mckernel reboot ...." + sudo ${MCMOD_DIR}/sbin/mcreboot.sh $* + echo "done." +} + +function ok_out() { + echo "[OK] ${TEST_PREFIX}`printf %03d ${TEST_NUM}` $1" + (( TEST_NUM++ )) + TEST_CODE=`printf %03d ${TEST_NUM}` +} + +function ng_out() { + echo "[NG] ${TEST_PREFIX}`printf %03d ${TEST_NUM}` $1" + exit 1 +} + +function ltp_test() { + TEST_NAME=$1 + if [ $# -eq 1 ]; then + TP_NAME=${TEST_NAME} + else + TP_NAME=$2 + fi +#LTP programを実行 logを保存 + sudo ${MCPATH}/bin/mcexec ${LTP_EXE_DIR}/${TP_NAME} >./result/${TEST_NAME}.log + +#LTP log 確認 + NUM=`cat ./test_cases/${TEST_NAME}.txt |wc -l` + for i in `seq 1 ${NUM}` + do + G_TEXT=`head -n ${i} ./test_cases/${TEST_NAME}.txt | tail -n 1` + result=`grep "${G_TEXT}" ./result/${TEST_NAME}.log` + #echo ${G_TEXT} + rc=$? + if [ ${rc} -eq 0 ]; then + ok_out "process_vm_readv: ${result}" + else + ng_out "process_vm_readv: result of ${TEST_NAME} ${i} are different." + fi + done +} + +TEST_PARAM_FILE=$1 +TEST_NUM=1 +TEST_CODE=001 +TEST_PREFIX=pvr_ + +ME=`whoami` +if [ $# -ne 2 ]; then + source ./config +else + MCPATH=$1 + LTP_EXE_DIR=$2/process_vm +fi + +mkdir -p ./result + +#LTP programを実行 logを保存 +sudo ${MCPATH}/bin/mcexec ${LTP_EXE_DIR}/process_vm01 -r >./result/process_vm_readv01.log + +#kmsgを保存 +sudo ${MCPATH}/sbin/ihkosctl 0 kmsg >./result/process_vm_readv01.kmsg + +#process_vm_readv-001 第2引数のアドレスが正しく引き継いでいることを確認 +#システムコールの引数のアドレスを取得 +sys_arg2_addr=`grep "sys_process_vm_readv" ./result/process_vm_readv01.kmsg | head -n 1 | sed s/"^.*arg2_addr:\([0-9a-f]*\),.*$"/"\1"/ ` +#echo ${sys_arg2_addr} +#実行関数の引数のアドレスを取得 +do_arg2_addr=`grep "do_process_vm_read_writev" ./result/process_vm_readv01.kmsg | head -n 1 | sed s/"^.*arg2_addr:\([0-9a-f]*\),.*$"/"\1"/ ` +#echo ${do_arg2_addr} +if [ ${#sys_arg2_addr} -ne 0 -a ${sys_arg2_addr} = ${do_arg2_addr} ]; then + text=`echo "process_vm_readv: The argument address of process_vm_readv is taken over by do_process_vm_read_writev"` + ok_out "${text} arg2:${sys_arg2_addr}" +else + ng_out "process_vm_readv: The argument value of process_vm_readv does not match the value of do_process_vm_read_writev argument." +fi + +#process_vm_readv-001 第4引数のアドレスが正しく引き継いでいることを確認 +#システムコールの引数のアドレスを取得 +sys_arg4_addr=`grep "sys_process_vm_readv" ./result/process_vm_readv01.kmsg | head -n 1 | sed s/"^.*arg4_addr:\([0-9a-f]*\).*$"/"\1"/ ` +#echo ${sys_arg4_addr} +#実行関数の引数のアドレスを取得 +do_arg4_addr=`grep "do_process_vm_read_writev" ./result/process_vm_readv01.kmsg | head -n 1 | sed s/"^.*arg4_addr:\([0-9a-f]*\).*$"/"\1"/ ` +#echo ${do_arg4_addr} +if [ ${#sys_arg4_addr} -ne 0 -a ${sys_arg4_addr} = ${do_arg4_addr} ]; then + text=`echo "process_vm_readv: The argument address of process_vm_readv is taken over by do_process_vm_read_writev"` + ok_out "${text} arg4:${sys_arg4_addr}" +else + ng_out "process_vm_readv: The argument value of process_vm_readv does not match the value of do_process_vm_read_writev argument." +fi + +ltp_test "process_vm_readv01" "process_vm01 -r" +ltp_test "process_vm_readv02" +ltp_test "process_vm_readv03" diff --git a/test/user_space/process_vm/process_vm_writev_test.sh b/test/user_space/process_vm/process_vm_writev_test.sh new file mode 100755 index 00000000..cb676f18 --- /dev/null +++ b/test/user_space/process_vm/process_vm_writev_test.sh @@ -0,0 +1,109 @@ +#!/bin/sh + +# Functions +function reboot() { + count=`pgrep -c -f 'mcexec '` + if [ ${count} -gt 0 ] + then +# echo "kill process :" ${count} + pgrep -l -f 'mcexec ' + pgrep -f 'mcexec ' | xargs sudo kill -9 + fi +# echo -n "mckernel stopping... " + sudo ${MCMOD_DIR}/sbin/mcstop+release.sh +# echo "done." + #sleep 1 + echo -n "mckernel reboot ...." + sudo ${MCMOD_DIR}/sbin/mcreboot.sh $* + echo "done." +} + +function ok_out() { + echo "[OK] ${TEST_PREFIX}`printf %03d ${TEST_NUM}` $1" + (( TEST_NUM++ )) + TEST_CODE=`printf %03d ${TEST_NUM}` +} + +function ng_out() { + echo "[NG] ${TEST_PREFIX}`printf %03d ${TEST_NUM}` $1" + exit 1 +} + +function ltp_test() { + TEST_NAME=$1 + if [ $# -eq 1 ]; then + TP_NAME=${TEST_NAME} + else + TP_NAME=$2 + fi +#LTP programを実行 logを保存 + sudo ${MCPATH}/bin/mcexec ${LTP_EXE_DIR}/${TP_NAME} >./result/${TEST_NAME}.log + +#LTP log 確認 + NUM=`cat ./test_cases/${TEST_NAME}.txt |wc -l` + for i in `seq 1 ${NUM}` + do + G_TEXT=`head -n ${i} ./test_cases/${TEST_NAME}.txt | tail -n 1` + result=`grep "${G_TEXT}" ./result/${TEST_NAME}.log` + #echo ${G_TEXT} + rc=$? + if [ ${rc} -eq 0 ]; then + ok_out "process_vm_writev: ${result}" + else + ng_out "process_vm_writev: result of ${TEST_NAME} ${i} are different." + fi + done +} + +TEST_PARAM_FILE=$1 +TEST_NUM=1 +TEST_CODE=001 +TEST_PREFIX=pvw_ + +ME=`whoami` +if [ $# -ne 2 ]; then + source ./config +else + MCPATH=$1 + LTP_EXE_DIR=$2/process_vm +fi + +mkdir -p ./result + +reboot +#LTP programを実行 logを保存 +sudo ${MCPATH}/bin/mcexec ${LTP_EXE_DIR}/process_vm01 -w >./result/process_vm_writev01.log + +#kmsgを保存 +sudo ${MCPATH}/sbin/ihkosctl 0 kmsg >./result/process_vm_writev01.kmsg + +#process_vm_writev-001 第2引数のアドレスが正しく引き継いでいることを確認 +#システムコールの引数のアドレスを取得 +sys_arg2_addr=`grep "sys_process_vm_writev" ./result/process_vm_writev01.kmsg | head -n 1 | sed s/"^.*arg2_addr:\([0-9|a-f]*\),.*$"/"\1"/ ` +#echo ${sys_arg2_addr} +#実行関数の引数のアドレスを取得 +do_arg2_addr=`grep "do_process_vm_read_writev" ./result/process_vm_writev01.kmsg | head -n 1 | sed s/"^.*arg2_addr:\([0-9|a-f]*\),.*$"/"\1"/ ` +#echo ${do_arg2_addr} +if [ ${#sys_arg2_addr} -ne 0 -a ${sys_arg2_addr} = ${do_arg2_addr} ]; then + text=`echo "process_vm_writev: The argument address of process_vm_writev is taken over by do_process_vm_read_writev"` + ok_out "${text} arg2:${sys_arg2_addr}" +else + ng_out "process_vm_writev: The argument value of process_vm_writev does not match the value of do_process_vm_read_writev argument." +fi + +#process_vm_writev-001 第4引数のアドレスが正しく引き継いでいることを確認 +#システムコールの引数のアドレスを取得 +sys_arg4_addr=`grep "sys_process_vm_writev" ./result/process_vm_writev01.kmsg | head -n 1 | sed s/"^.*arg4_addr:\([0-9|a-f]*\).*$"/"\1"/ ` +#echo ${sys_arg4_addr} +#実行関数の引数のアドレスを取得 +do_arg4_addr=`grep "do_process_vm_read_writev" ./result/process_vm_writev01.kmsg | head -n 1 | sed s/"^.*arg4_addr:\([0-9|a-f]*\).*$"/"\1"/ ` +#echo ${do_arg4_addr} +if [ ${#sys_arg4_addr} -ne 0 -a ${sys_arg4_addr} = ${do_arg4_addr} ]; then + text=`echo "process_vm_writev: The argument address of process_vm_writev is taken over by do_process_vm_read_writev"` + ok_out "${text} arg4:${sys_arg4_addr}" +else + ng_out "process_vm_writev: The argument value of process_vm_writev does not match the value of do_process_vm_read_writev argument." +fi + +ltp_test "process_vm_writev01" "process_vm01 -w" +ltp_test "process_vm_writev02" diff --git a/test/user_space/process_vm/test_cases/process_vm_readv01.txt b/test/user_space/process_vm/test_cases/process_vm_readv01.txt new file mode 100644 index 00000000..392b8f26 --- /dev/null +++ b/test/user_space/process_vm/test_cases/process_vm_readv01.txt @@ -0,0 +1,28 @@ +process_vm_readv 1 TPASS : expected ret success - returned value = 4096 +process_vm_readv 2 TPASS : expected ret success - returned value = -1 +process_vm_readv 3 TPASS : expected failure: TEST_ERRNO=EINVAL(22): Invalid argument +process_vm_readv 4 TPASS : expected ret success - returned value = -1 +process_vm_readv 5 TPASS : expected failure: TEST_ERRNO=EINVAL(22): Invalid argument +process_vm_readv 6 TPASS : expected ret success - returned value = -1 +process_vm_readv 7 TPASS : expected failure: TEST_ERRNO=EINVAL(22): Invalid argument +process_vm_readv 8 TPASS : expected ret success - returned value = -1 +process_vm_readv 9 TPASS : expected failure: TEST_ERRNO=EINVAL(22): Invalid argument +process_vm_readv 10 TPASS : expected ret success - returned value = 4096 +process_vm_readv 11 TPASS : expected ret success - returned value = -1 +process_vm_readv 12 TPASS : expected failure: TEST_ERRNO=EINVAL(22): Invalid argument +process_vm_readv 13 TPASS : expected ret success - returned value = -1 +process_vm_readv 14 TPASS : expected failure: TEST_ERRNO=EFAULT(14): Bad address +process_vm_readv 15 TPASS : expected ret success - returned value = -1 +process_vm_readv 16 TPASS : expected failure: TEST_ERRNO=EFAULT(14): Bad address +process_vm_readv 17 TPASS : expected ret success - returned value = -1 +process_vm_readv 18 TPASS : expected failure: TEST_ERRNO=EFAULT(14): Bad address +process_vm_readv 19 TPASS : expected ret success - returned value = -1 +process_vm_readv 20 TPASS : expected failure: TEST_ERRNO=EFAULT(14): Bad address +process_vm_readv 21 TPASS : expected ret success - returned value = -1 +process_vm_readv 22 TPASS : expected failure: TEST_ERRNO=ESRCH(3): No such process +process_vm_readv 23 TPASS : expected ret success - returned value = -1 +process_vm_readv 24 TPASS : expected failure: TEST_ERRNO=ESRCH(3): No such process +process_vm_readv 25 TPASS : expected ret success - returned value = -1 +process_vm_readv 26 TPASS : expected failure: TEST_ERRNO=EFAULT(14): Bad address +process_vm_readv 27 TPASS : expected ret success - returned value = -1 +process_vm_readv 28 TPASS : expected failure: TEST_ERRNO=EFAULT(14): Bad address diff --git a/test/user_space/process_vm/test_cases/process_vm_readv02.txt b/test/user_space/process_vm/test_cases/process_vm_readv02.txt new file mode 100644 index 00000000..ecca590f --- /dev/null +++ b/test/user_space/process_vm/test_cases/process_vm_readv02.txt @@ -0,0 +1 @@ +process_vm_readv02 1 TPASS : expected string received. diff --git a/test/user_space/process_vm/test_cases/process_vm_readv03.txt b/test/user_space/process_vm/test_cases/process_vm_readv03.txt new file mode 100644 index 00000000..894f51ad --- /dev/null +++ b/test/user_space/process_vm/test_cases/process_vm_readv03.txt @@ -0,0 +1,2 @@ +process_vm_readv03 1 TFAIL : process_vm_readv03.c:186: process_vm_readv: errno=EFAULT(14): Bad address +process_vm_readv03 1 TFAIL : process_vm_readv03.c:103: child 1 returns 256 diff --git a/test/user_space/process_vm/test_cases/process_vm_writev01.txt b/test/user_space/process_vm/test_cases/process_vm_writev01.txt new file mode 100644 index 00000000..150bc87c --- /dev/null +++ b/test/user_space/process_vm/test_cases/process_vm_writev01.txt @@ -0,0 +1,28 @@ +process_vm_writev 1 TPASS : expected ret success - returned value = 4096 +process_vm_writev 2 TPASS : expected ret success - returned value = -1 +process_vm_writev 3 TPASS : expected failure: TEST_ERRNO=EINVAL(22): Invalid argument +process_vm_writev 4 TPASS : expected ret success - returned value = -1 +process_vm_writev 5 TPASS : expected failure: TEST_ERRNO=EINVAL(22): Invalid argument +process_vm_writev 6 TPASS : expected ret success - returned value = -1 +process_vm_writev 7 TPASS : expected failure: TEST_ERRNO=EINVAL(22): Invalid argument +process_vm_writev 8 TPASS : expected ret success - returned value = -1 +process_vm_writev 9 TPASS : expected failure: TEST_ERRNO=EINVAL(22): Invalid argument +process_vm_writev 10 TPASS : expected ret success - returned value = 4096 +process_vm_writev 11 TPASS : expected ret success - returned value = -1 +process_vm_writev 12 TPASS : expected failure: TEST_ERRNO=EINVAL(22): Invalid argument +process_vm_writev 13 TPASS : expected ret success - returned value = -1 +process_vm_writev 14 TPASS : expected failure: TEST_ERRNO=EFAULT(14): Bad address +process_vm_writev 15 TPASS : expected ret success - returned value = -1 +process_vm_writev 16 TPASS : expected failure: TEST_ERRNO=EFAULT(14): Bad address +process_vm_writev 17 TPASS : expected ret success - returned value = -1 +process_vm_writev 18 TPASS : expected failure: TEST_ERRNO=EFAULT(14): Bad address +process_vm_writev 19 TPASS : expected ret success - returned value = -1 +process_vm_writev 20 TPASS : expected failure: TEST_ERRNO=EFAULT(14): Bad address +process_vm_writev 21 TPASS : expected ret success - returned value = -1 +process_vm_writev 22 TPASS : expected failure: TEST_ERRNO=ESRCH(3): No such process +process_vm_writev 23 TPASS : expected ret success - returned value = -1 +process_vm_writev 24 TPASS : expected failure: TEST_ERRNO=ESRCH(3): No such process +process_vm_writev 25 TPASS : expected ret success - returned value = -1 +process_vm_writev 26 TPASS : expected failure: TEST_ERRNO=EFAULT(14): Bad address +process_vm_writev 27 TPASS : expected ret success - returned value = -1 +process_vm_writev 28 TPASS : expected failure: TEST_ERRNO=EFAULT(14): Bad address diff --git a/test/user_space/process_vm/test_cases/process_vm_writev02.txt b/test/user_space/process_vm/test_cases/process_vm_writev02.txt new file mode 100644 index 00000000..04a2d4d1 --- /dev/null +++ b/test/user_space/process_vm/test_cases/process_vm_writev02.txt @@ -0,0 +1 @@ +process_vm_writev02 1 TPASS : child 0: all bytes are expected. diff --git a/test/user_space/swapout/Makefile b/test/user_space/swapout/Makefile new file mode 100644 index 00000000..1af9b01e --- /dev/null +++ b/test/user_space/swapout/Makefile @@ -0,0 +1,19 @@ +PPOSDIR=/home/iizuka/mckernel +MPIDIR=/usr/lib64/mpich-3.2 +MPIBINDIR=$(MPIDIR)/bin +MPILIBDIR=$(MPIDIR)/lib +CC=gcc + +LIBDIR=$(PPOSDIR)/lib +LDFLAGS=-L$(LIBDIR) -Wl,-rpath=$(LIBDIR) -Wl,-rpath,$(MPILIBDIR) +CFLAGS= -I$(PPOSDIR)/include + +TARGETS= swaptest + +all:: $(TARGETS) + +swaptest: swaptest.c + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $@.c + +clean:: + rm -f $(TARGETS) diff --git a/test/user_space/swapout/config b/test/user_space/swapout/config new file mode 100644 index 00000000..ce08fc50 --- /dev/null +++ b/test/user_space/swapout/config @@ -0,0 +1,9 @@ +MCMOD_DIR=/home/iizuka/mckernel + +START=${MCMOD_DIR}/bin/ql_mpiexec_start +FINALIZE=${MCMOD_DIR}/bin/ql_mpiexec_finalize + +USR_PRG_A=../../qlmpi/qlmpi_testsuite/usr_prg_A +USR_PRG_B=../../qlmpi/qlmpi_testsuite/usr_prg_B +USR_PRG_C=../../qlmpi/qlmpi_testsuite/usr_prg_C +USR_PRG_IRREG=../../qlmpi/qlmpi_testsuite/usr_prg_irreg diff --git a/test/user_space/swapout/ql_normal.sh b/test/user_space/swapout/ql_normal.sh new file mode 100755 index 00000000..92a6c6f3 --- /dev/null +++ b/test/user_space/swapout/ql_normal.sh @@ -0,0 +1,368 @@ +#!/bin/sh + +# Functions +function ok_out() { + echo "[OK] ${TEST_PREFIX}`printf %03d ${TEST_NUM}` $1" + (( TEST_NUM++ )) + TEST_CODE=`printf %03d ${TEST_NUM}` +} + +function ng_out() { + echo "[NG] ${TEST_PREFIX}`printf %03d ${TEST_NUM}` $1" + exit 1 +} + +if [ $# -lt 1 ]; then + echo "too few arguments." + echo "usage: `basename $0` " +fi + +# Functions +function reboot() { + count=`pgrep -c -f 'mcexec '` + if [ ${count} -gt 0 ] + then + echo "kill process :" ${count} + pgrep -l -f 'mcexec ' + pgrep -f 'mcexec ' | xargs sudo kill -9 + fi +# echo -n "mckernel stopping... " + sudo ${MCMOD_DIR}/sbin/mcstop+release.sh +# echo "done." + #sleep 1 + echo -n "mckernel booting... " 1>&2 + sudo ${MCMOD_DIR}/sbin/mcreboot.sh $* + echo "done." 1>&2 +} +TEST_PARAM_FILE=$1 +TEST_NUM=1 +TEST_CODE=001 + +ME=`whoami` + +# read config +source ./config + +# read test param +source ${TEST_PARAM_FILE} + +# make machinefile +mkdir ./machinefiles &> /dev/null +MFILE=./machinefiles/mfile_${TEST_PREFIX} +echo ${MASTER}:${PROC_PER_NODE} > ${MFILE} +for slave in ${SLAVE} +do + echo ${slave}:${PROC_PER_NODE} >> ${MFILE} +done + +reboot + +PROC_NUM=`expr ${PROC_PER_NODE} \* ${MPI_NODE_NUM}` + +# read machinefile +declare -a node_arry +while read line +do + node_arry+=(${line%:*}) +done < ${MFILE} +MASTER=${node_arry[0]} + +# make result directory +RESULT_DIR=./result/${TEST_PREFIX} +mkdir -p ${RESULT_DIR} + +RANK_MAX=`expr ${PROC_NUM} - 1` + +# Log files +start_1st_A_log=${RESULT_DIR}/exec_1st_A.log +start_1st_B_log=${RESULT_DIR}/exec_1st_B.log +start_1st_C_log=${RESULT_DIR}/exec_1st_C.log + +start_2nd_A_log=${RESULT_DIR}/exec_2nd_A.log +start_2nd_B_log=${RESULT_DIR}/exec_2nd_B.log +start_2nd_C_log=${RESULT_DIR}/exec_2nd_C.log + +finalize_A_log=${RESULT_DIR}/finalize_A.log +finalize_B_log=${RESULT_DIR}/finalize_B.log +finalize_C_log=${RESULT_DIR}/finalize_C.log + +# Arguments +args_1st_A="1234 hoge 02hoge" +args_2nd_A="foo 99bar test" + +# Env +envs_1st_A="1st_exec_A" +envs_2nd_A="This_is_2nd_exec_A" + +### テスト開始時点でql_serverとテスト用MPIプログラムが各ノードで実行されていない +for node in ${node_arry[@]} +do + cnt=`ssh $node "pgrep -u ${ME} -c 'ql_(server|talker)'"` + if [ ${cnt} -gt 0 ]; then + ng_out "ql_server is running on ${node}" + fi + + cnt=`ssh $node "pgrep -u ${ME} -c 'mpiexec'"` + if [ ${cnt} -gt 0 ]; then + ng_out "other MPI program is running on ${node}" + fi +done +ok_out "ql_server and usr_prgs are not running on each node" + +### usr_prg_A を実行するql_mpiexec_start の返り値が0 (成功) +env QL_TEST=${envs_1st_A} ${START} -machinefile ${MFILE} -n ${PROC_NUM} ${USR_PRG_A} ${args_1st_A} > ${start_1st_A_log} +rc=$? +if [ ${rc} -eq 0 ]; then + ok_out "ql_mpiexec_start usr_prg_A (first exec) returns 0" +else + ng_out "ql_mpiexec_start usr_prg_A (first exec) returns ${rc}" +fi + +### 初回実行後、マスターノード上でql_serverが動作している +cnt=`ssh ${MASTER} "pgrep -u ${ME} -c 'ql_server'"` +if [ ${cnt} -ne 1 ]; then + ng_out "ql_server is not running on master node" +else + ok_out "ql_server is running on master node" +fi + +### 各ノードのusr_prg_A の引数が実行時に指定したものと一致している +for rank in `seq 0 ${RANK_MAX}` +do + line=`grep -e "^${rank}:" ${start_1st_A_log} | grep -e "argv="` + tgt=${line#*argv=} + if [ "X${tgt}" != "X${USR_PRG_A} ${args_1st_A}" ]; then + ng_out "usr_prg_A's args is incorrect on rank:${rank}\n ${line}" + fi +done +ok_out "usr_prg_A's args are correct on each node" + +### 各ノードのusr_prg_A テスト用に指定した環境変数が実行時に指定したものと一致している +for rank in `seq 0 ${RANK_MAX}` +do + line=`grep -e "^${rank}:" ${start_1st_A_log} | grep -e "QL_TEST="` + tgt=${line#*QL_TEST=} + if [ "X${tgt}" != "X${envs_1st_A}" ]; then + ng_out "usr_prg_A's env (QL_TEST) is incorrect on each node:${rank}\n ${line}" + fi +done +ok_out "usr_prg_A's env (QL_TEST) is correct on each node" + +### 各ノードのusr_prg_A の計算処理が完了 +for rank in `seq 0 ${RANK_MAX}` +do + line=`grep -e "^${rank}:" ${start_1st_A_log} | grep -e "done="` + tgt=${line#*done=} + if [ "X${tgt}" != "Xyes" ]; then + ng_out "usr_prg_A's calculation is not done on rank:${rank}" + fi +done +ok_out "usr_prg_A's calculation is done on each node" + +### ql_mpiexec_start の完了後、usr_prg_A が再開指示待ちになっている +for node in ${node_arry[@]} +do + cnt=`ssh $node "pgrep -u ${ME} -fl 'usr_prg_A'" | grep " exe" | wc -l` + if [ ${cnt} -eq 0 ]; then + ng_out "usr_prg_A is not running on ${node}" + else + echo " ${cnt} programs is waiting on ${node}" + fi +done +ok_out "usr_prg_A is waiting for resume-req on each node" + +### usr_prg_B を実行するql_mpiexec_start の返り値が0 (成功) +${START} -machinefile ${MFILE} -n ${PROC_NUM} ${USR_PRG_B} 1 2 3 > ${start_1st_B_log} +rc=$? +if [ ${rc} -eq 0 ]; then + ok_out "ql_mpiexec_start usr_prg_B (first exec) returns 0" +else + ng_out "ql_mpiexec_start usr_prg_B (first exec) returns ${rc}" +fi + +### 各ノードのusr_prg_B の計算処理が完了 +for rank in `seq 0 ${RANK_MAX}` +do + line=`grep -e "^${rank}:" ${start_1st_B_log} | grep -e "done="` + tgt=${line#*done=} + if [ "X${tgt}" != "Xyes" ]; then + ng_out "usr_prg_B's calculation is not done on rank:${rank}" + fi +done +ok_out "usr_prg_B's calculation is done on each node" + +### ql_mpiexec_start の完了後、usr_prg_B が再開指示待ちになっている +for node in ${node_arry[@]} +do + cnt=`ssh $node "pgrep -u ${ME} -fl 'usr_prg_B'" | grep " exe" | wc -l` + if [ ${cnt} -eq 0 ]; then + ng_out "usr_prg_B is not running on ${node}" + else + echo " ${cnt} programs is waiting on ${node}" + fi +done +ok_out "usr_prg_B is waiting for resume-req on each node" + +### usr_prg_C を実行するql_mpiexec_start の返り値が0 (成功) +${START} -machinefile ${MFILE} -n ${PROC_NUM} ${USR_PRG_C} a b c > ${start_1st_C_log} +rc=$? +if [ ${rc} -eq 0 ]; then + ok_out "ql_mpiexec_start usr_prg_C (first exec) returns 0" +else + ng_out "ql_mpiexec_start usr_prg_C (first exec) returns ${rc}" +fi + +### 各ノードのusr_prg_C の計算処理が完了 +for rank in `seq 0 ${RANK_MAX}` +do + line=`grep -e "^${rank}:" ${start_1st_C_log} | grep -e "done="` + tgt=${line#*done=} + if [ "X${tgt}" != "Xyes" ]; then + ng_out "usr_prg_C's calculation is not done on rank:${rank}" + fi +done +ok_out "usr_prg_C's calculation is done on each node" + +### ql_mpiexec_start の完了後、usr_prg_C が再開指示待ちになっている +for node in ${node_arry[@]} +do + cnt=`ssh $node "pgrep -u ${ME} -fl 'usr_prg_C'" | grep " exe" | wc -l` + if [ ${cnt} -eq 0 ]; then + ng_out "usr_prg_C is not running on ${node}" + else + echo " ${cnt} programs is waiting on ${node}" + fi +done +ok_out "usr_prg_C is waiting for resume-req on each node" + +### usr_prg_A を再実行するql_mpiexec_start の返り値が0 (成功) +env QL_TEST=${envs_2nd_A} ${START} -machinefile ${MFILE} -n ${PROC_NUM} ${USR_PRG_A} ${args_2nd_A} > ${start_2nd_A_log} +rc=$? +if [ ${rc} -eq 0 ]; then + ok_out "(again) ql_mpiexec_start usr_prg_A returns 0" +else + ng_out "(again) ql_mpiexec_start usr_prg_A returns ${rc}" +fi + +### 各ノードのusr_prg_A の引数が再実行時に指定したものと一致している +for rank in `seq 0 ${RANK_MAX}` +do + line=`grep -e "^${rank}:" ${start_2nd_A_log} | grep -e "argv="` + tgt=${line#*argv=} + if [ "X${tgt}" != "X${USR_PRG_A} ${args_2nd_A}" ]; then + ng_out "usr_prg_A's args is incorrect on rank:${rank}\n ${line}" + fi +done +ok_out "(again) usr_prg_A's args are correct on each node" + +### 各ノードのusr_prg_A テスト用に指定した環境変数が再実行時に指定したものと一致している +for rank in `seq 0 ${RANK_MAX}` +do + line=`grep -e "^${rank}:" ${start_2nd_A_log} | grep -e "QL_TEST="` + tgt=${line#*QL_TEST=} + if [ "X${tgt}" != "X${envs_2nd_A}" ]; then + ng_out "usr_prg_A's env (QL_TEST) is incorrect on each node:${rank}\n ${line}" + fi +done +ok_out "(again) usr_prg_A's env (QL_TEST) is correct on each node" + +### 各ノードのusr_prg_A の計算処理が完了 +for rank in `seq 0 ${RANK_MAX}` +do + line=`grep -e "^${rank}:" ${start_2nd_A_log} | grep -e "done="` + tgt=${line#*done=} + if [ "X${tgt}" != "Xyes" ]; then + ng_out "usr_prg_A's calculation is not done on rank:${rank}" + fi +done +ok_out "(again) usr_prg_A's calculation is done on each node" + +### ql_mpiexec_start の完了後、usr_prg_A が再開指示待ちになっている +for node in ${node_arry[@]} +do + cnt=`ssh $node "pgrep -u ${ME} -fl 'usr_prg_A'" | grep " exe" | wc -l` + if [ ${cnt} -eq 0 ]; then + ng_out "usr_prg_A is not running on ${node}" + else + echo " ${cnt} programs is waiting on ${node}" + fi +done +ok_out "(again) usr_prg_A is waiting for resume-req on each node" + +### usr_prg_B を再実行するql_mpiexec_start の返り値が0 (成功) +${START} -machinefile ${MFILE} -n ${PROC_NUM} ${USR_PRG_B} 10 20 30 40 > ${start_2nd_B_log} +rc=$? +if [ ${rc} -eq 0 ]; then + ok_out "(again) ql_mpiexec_start usr_prg_B returns 0" +else + ng_out "(again) ql_mpiexec_start usr_prg_B returns ${rc}" +fi + +### 各ノードのusr_prg_B の計算処理が完了 +for rank in `seq 0 ${RANK_MAX}` +do + line=`grep -e "^${rank}:" ${start_2nd_B_log} | grep -e "done="` + tgt=${line#*done=} + if [ "X${tgt}" != "Xyes" ]; then + ng_out "usr_prg_B's calculation is not done on rank:${rank}" + fi +done +ok_out "(again) usr_prg_B's calculation is done on each node" + +### ql_mpiexec_start の完了後、usr_prg_B が再開指示待ちになっている +for node in ${node_arry[@]} +do + cnt=`ssh $node "pgrep -u ${ME} -fl 'usr_prg_B'" | grep " exe" | wc -l` + if [ ${cnt} -eq 0 ]; then + ng_out "usr_prg_B is not running on ${node}" + else + echo " ${cnt} programs is waiting on ${node}" + fi +done +ok_out "(again) usr_prg_B is waiting for resume-req on each node" + +### usr_prg_A を終了するql_mpiexec_finalize の返り値が0 (成功) +${FINALIZE} -machinefile ${MFILE} -n ${PROC_NUM} ${USR_PRG_A} > ${finalize_A_log} +rc=$? +if [ ${rc} -eq 0 ]; then + ok_out "ql_mpiexec_finalize usr_prg_A return 0" +else + ng_out "ql_mpiexec_finalize usr_prg_A return ${rc}" +fi + +### usr_prg_B を終了するql_mpiexec_finalize の返り値が0 (成功) +${FINALIZE} -machinefile ${MFILE} -n ${PROC_NUM} ${USR_PRG_B} > ${finalize_B_log} +rc=$? +if [ ${rc} -eq 0 ]; then + ok_out "ql_mpiexec_finalize usr_prg_B return 0" +else + ng_out "ql_mpiexec_finalize usr_prg_B return ${rc}" +fi + +### usr_prg_Bの終了後、ql_serverがマスターノード上で動作している +cnt=`ssh ${MASTER} "pgrep -u ${ME} -c 'ql_server'"` +if [ ${cnt} -ne 1 ]; then + ng_out "ql_server is not running on master node" +else + ok_out "ql_server is still running on master node" +fi + +### usr_prg_C を終了するql_mpiexec_finalize の返り値が0 (成功) +${FINALIZE} -machinefile ${MFILE} -n ${PROC_NUM} ${USR_PRG_C} > ${finalize_C_log} +rc=$? +if [ ${rc} -eq 0 ]; then + ok_out "ql_mpiexec_finalize usr_prg_C return 0" +else + ng_out "ql_mpiexec_finalize usr_prg_C return ${rc}" +fi + +### すべてのMPIプログラムが終了したので、ql_serverが終了した +cnt=`ssh ${MASTER} "pgrep -u ${ME} -c 'ql_server'"` +sleep 1 +if [ ${cnt} -eq 0 ]; then + ok_out "ql_server is not running on master node" +else + ng_out "ql_server is still running on master node" +fi + +echo "[OK] so_026 qlmpi test " diff --git a/test/user_space/swapout/swapout_copy_from.sh b/test/user_space/swapout/swapout_copy_from.sh new file mode 100755 index 00000000..269dfd33 --- /dev/null +++ b/test/user_space/swapout/swapout_copy_from.sh @@ -0,0 +1,132 @@ +#!/bin/sh + +# Functions +function reboot() { + count=`pgrep -c -f 'mcexec '` + if [ ${count} -gt 0 ] + then + echo "kill process :" ${count} + pgrep -l -f 'mcexec ' + pgrep -f 'mcexec ' | xargs sudo kill -9 + fi +# echo -n "mckernel stopping... " + sudo ${MCMOD_DIR}/sbin/mcstop+release.sh +# echo "done." + #sleep 1 + echo -n "mckernel booting... " 1>&2 + sudo ${MCMOD_DIR}/sbin/mcreboot.sh $* + echo "done." 1>&2 +} + +function ok_out() { + echo "[OK] ${TEST_PREFIX}`printf %03d ${TEST_NUM}` $1" + (( TEST_NUM++ )) + TEST_CODE=`printf %03d ${TEST_NUM}` +} + +function ng_out() { + echo "[NG] ${TEST_PREFIX}`printf %03d ${TEST_NUM}` $1" + exit 1 +} + +TEST_PARAM_FILE=$1 +TEST_NUM=1 +TEST_CODE=001 +TEST_PREFIX=so_ + +ME=`whoami` + +# read config +source ./config + +MCPATH=${MCMOD_DIR} + +mkdir -p ./result + +reboot +#programを実行 logを保存 +${MCPATH}/bin/mcexec ./swaptest 2 >./result/swapout_copy_from.log + +#kmsgを保存 +sudo ${MCPATH}/sbin/ihkosctl 0 kmsg >./result/swapout_copy_from.kmsg + +#swapout001 arealist_update i and count check. +#arealist_update i +arealist_i=`grep "arealist_update" ./result/swapout_copy_from.kmsg | head -n 1 | sed s/"^.*copy_from_user i:\([0-9a-f]*\),.*$"/"\1"/ ` +#echo ${arearlist_i} +#arealist_update count +arealist_count=`grep "arealist_update" ./result/swapout_copy_from.kmsg | head -n 1 | sed s/"^.*count:\([0-9a-f]*\).*$"/"\1"/ ` +#echo ${arearlist_count} +if [ ${#arealist_i} -ne 0 -a ${arealist_i} = ${arealist_count} ]; then + text=`echo "arealist_update:variable i matched rea->tail->count"` + ok_out "${text} :(${arealist_i})" +else + ng_out "arealist_update: The value of count does not match the value of i." +fi + +#swapout002 mlocklist_morereq went.count and ent->count check. +#ent.count +went=`grep "mlocklist_morereq" ./result/swapout_copy_from.kmsg | head -n 1 | sed s/"^.*copy_from_user went.count:\([0-9a-f]*\),.*$"/"\1"/ ` +#echo ${went} +#ent->count +ent=`grep "mlocklist_morereq" ./result/swapout_copy_from.kmsg | head -n 1 | sed s/"^.*->count:\([0-9a-f]*\).*$"/"\1"/ ` +#echo ${ent} +if [ ${#went} -ne 0 -a ${went} = ${ent} ]; then + text=`echo "mlocklist_morereq:variable ent.count matched ent->count"` + ok_out "${text} :(${went})" +else + ng_out "mlocklist_morereq: The value of count does not match the value of i." +fi + +#swapout003 arealist_preparewrite went.count and ent->count check. +#ent.count +went=`grep "arealist_preparewrite" ./result/swapout_copy_from.kmsg | head -n 1 | sed s/"^.*copy_from_user went.count:\([0-9a-f]*\),.*$"/"\1"/ ` +#echo ${went} +ent=`grep "arealist_preparewrite" ./result/swapout_copy_from.kmsg | head -n 1 | sed s/"^.*->count:\([0-9a-f]*\).*$"/"\1"/ ` +#echo ${ent} +if [ ${#went} -ne 0 -a ${went} = ${ent} ]; then + text=`echo "arealist_preprarewrite:variable ent.count matched ent->count"` + ok_out "${text} :(${went})" +else + ng_out "arealist_preprarewrite: The value of count does not match the value of i." +fi + +#swapout004 do_pageout loop1 si->swap_info[].start and sw_info.start check. +#swap_inf +swap_info=`grep "do_pageout:1" ./result/swapout_copy_from.kmsg | head -n 1 | sed s/"^.*copy_from_user \([0-9|a-f]*\):.*$"/"\1"/ ` +#echo ${swap_info} +#sw_info +sw_info=`grep "do_pageout:1" ./result/swapout_copy_from.kmsg | head -n 1 | sed s/"^.*copy_from_user [0-9|a-f]*:\([0-9|a-f]*\).*$"/"\1"/ ` +#echo ${sw_info} +if [ ${#swap_info} -ne 0 -a ${swap_info} = ${sw_info} ]; then + text=`echo "do_pageout loop1:variable swap_info[].start matched sw_info.start"` + ok_out "${text} :(${swap_info})" +else + ng_out "do_pageout loop1: The value of swapinfo[].start does not match the value of sw_info.start." +fi + +#swapout005 do_pageout loop2 si->swap_info[].start and sw_info.start check. +swap_info=`grep "do_pageout:2" ./result/swapout_copy_from.kmsg | head -n 1 | sed s/"^.*copy_from_user \([0-9|a-f]*\):.*$"/"\1"/ ` +#echo ${swap_info} +sw_info=`grep "do_pageout:2" ./result/swapout_copy_from.kmsg | head -n 1 | sed s/"^.*copy_from_user [0-9|a-f]*:\([0-9|a-f]*\).*$"/"\1"/ ` +#echo ${sw_info} +if [ ${#swap_info} -ne 0 -a ${swap_info} = ${sw_info} ]; then + text=`echo "do_pageout loop2:variable swap_info[].start matched sw_info.start"` + ok_out "${text} :(${swap_info})" +else + ng_out "do_pageout loop2: The value of swapinfo[].start does not match the value of sw_info.start." +fi + +#swapout006 do_pageout loop3 si->swap_info[].start and sw_info.start check. +#swap_inf +swap_info=`grep "do_pageout:3" ./result/swapout_copy_from.kmsg | head -n 1 | sed s/"^.*copy_from_user \([0-9|a-f]*\):.*$"/"\1"/ ` +#echo ${swap_info} +sw_info=`grep "do_pageout:3" ./result/swapout_copy_from.kmsg | head -n 1 | sed s/"^.*copy_from_user [0-9|a-f]*:\([0-9|a-f]*\).*$"/"\1"/ ` +#echo ${sw_info} +if [ ${#swap_info} -ne 0 -a ${swap_info} = ${sw_info} ]; then + text=`echo "do_pageout loop3:variable swap_info[].start matched sw_info.start"` + ok_out "${text} :(${swap_info})" +else + ng_out "do_pageout loop3: The value of swapinfo[].start does not match the value of sw_info.start." +fi + diff --git a/test/user_space/swapout/swapout_copy_to_01.sh b/test/user_space/swapout/swapout_copy_to_01.sh new file mode 100755 index 00000000..23419919 --- /dev/null +++ b/test/user_space/swapout/swapout_copy_to_01.sh @@ -0,0 +1,131 @@ +#!/bin/sh + +# Functions +function reboot() { + count=`pgrep -c -f 'mcexec '` + if [ ${count} -gt 0 ] + then + echo "kill process :" ${count} + pgrep -l -f 'mcexec ' + pgrep -f 'mcexec ' | xargs sudo kill -9 + fi +# echo -n "mckernel stopping... " + sudo ${MCMOD_DIR}/sbin/mcstop+release.sh +# echo "done." + #sleep 1 + echo -n "mckernel booting... " 1>&2 + sudo ${MCMOD_DIR}/sbin/mcreboot.sh $* + echo "done." 1>&2 +} + +function ok_out() { + echo "[OK] ${TEST_PREFIX}`printf %03d ${TEST_NUM}` $1" + (( TEST_NUM++ )) + TEST_CODE=`printf %03d ${TEST_NUM}` +} + +function ng_out() { + echo "[NG] ${TEST_PREFIX}`printf %03d ${TEST_NUM}` $1" + exit 1 +} + +TEST_PARAM_FILE=$1 +TEST_NUM=7 +TEST_CODE=001 +TEST_PREFIX=so_ + +ME=`whoami` + +# read config +source ./config + +MCPATH=${MCMOD_DIR} + +mkdir -p result + +reboot +#programを実行 logを保存 +${MCPATH}/bin/mcexec ./swaptest 2 >./result/swapout_copy_to_01.log + +#kmsgを保存 +sudo ${MCPATH}/sbin/ihkosctl 0 kmsg >./result/swapout_copy_to_01.kmsg + +#swapout007 arealist_update i and count check. +arealist_i=`grep "arealist_update" ./result/swapout_copy_to_01.kmsg | head -n 1 | sed s/"^.*copy_to_user i:\([0-9a-f]*\),.*$"/"\1"/ ` +#echo ${arearlist_i} +arealist_count=`grep "arealist_update" ./result/swapout_copy_to_01.kmsg | head -n 1 | sed s/"^.*count:\([0-9a-f]*\).*$"/"\1"/ ` +#echo ${arearlist_count} +if [ ${#arealist_i} -ne 0 -a ${arealist_i} = ${arealist_count} ]; then + text=`echo "arealist_update:variable i matched rea->tail->count"` + ok_out "${text} :(${arealist_i})" +else + ng_out "arealist_update: The value of count does not match the value of i." +fi + +#swapout008 arealist_add addr->start and waddr.start check. +addr=`grep "arealist_add" ./result/swapout_copy_to_01.kmsg | head -n 1 | sed s/"^.*copy_to_user addr->start:\([0-9a-f]*\),.*$"/"\1"/ ` +#echo ${addr} +waddr=`grep "arealist_add" ./result/swapout_copy_to_01.kmsg | head -n 1 | sed s/"^.*waddr.start:\([0-9a-f]*\)$"/"\1"/ ` +#echo ${waddr} +if [ ${#addr} -ne 0 -a ${addr} = ${waddr} ]; then + text=`echo "arealist_add:addr->start matched waddr.start"` + ok_out "${text} :(${waddr})" +else + ng_out "arealist_add: The value of addr->start does not match the value of wsddr.start." +fi + +#swapout009 do_pageout si->swapfname and si->udata_buf check. +udata_buf=`grep "do_pageout" ./result/swapout_copy_to_01.kmsg | head -n 1 | sed s/"^.*copy_to_user si->udata_buf:\(.*\),.*$"/"\1"/ ` +#echo ${udata_buf} +swapfname=`grep "do_pageout" ./result/swapout_copy_to_01.kmsg | head -n 1 | sed s/"^.*si->swapfname:\(.*\)$"/"\1"/ ` +#echo ${swapfname} +if [ ${#udata_buf} -ne 0 -a "${udata_buf}" = "${swapfname}" ]; then + text=`echo "do_pageout:variable si->udata_buf matched si->swapfname"` + ok_out "${text} :(${udata_buf})" +else + ng_out "do_pageout: The value of si->udata_buf does not match the value of si->swapfname." +fi + +#swapout010 do_pageout si->swphdr->magic +magic=`grep "do_pageout:.* si->swphdr->magic" ./result/swapout_copy_to_01.kmsg | head -n 1 | sed s/"^.*copy_to_user si->swphdr->magic:\(.*\),si->swphdr->version:.*$"/"\1"/ ` +#echo ${magic} +if [ "${magic}" = "McKernel swap" ]; then + text=`echo "do_pageout:si->swphdr->magic is McKernel swap"` + ok_out "${text} :(${magic})" +else + ng_out "do_pageout: does not match the value of si->swphdr->magic." +fi + +#swapout011 do_pageout si->swphdr->version +version=`grep "do_pageout:.*,si->swphdr->version" ./result/swapout_copy_to_01.kmsg | head -n 1 | sed s/"^.*copy_to_user .*,si->swphdr->version:\(.*\),si->swphdr->count_sarea:.*$"/"\1"/ ` +#echo ${version} +if [ "${version}" = "0.9.0" ]; then + text=`echo "do_pageout:si->swphdr->version is 0.9.0"` + ok_out "${text} :(${version})" +else + ng_out "do_pageout: does not match the value of si->swphdr->version." +fi + +#swapout012 d_pageout si->swphdr->count_sarea +sarea=`grep "do_pageout:.*,si->swphdr->count_sarea" ./result/swapout_copy_to_01.kmsg | head -n 1 | sed s/"^.*copy_to_user .*,si->swphdr->count_sarea:\([0-9|a-f]*\),.*$"/"\1"/ ` +echo ${sarea} +count=`grep "do_pageout:.*,si->swphdr->count_sarea" ./result/swapout_copy_to_01.kmsg | head -n 1 | sed s/"^.*si->swap_area.count:\([0-9|a-f]*\),.*$"/"\1"/ ` +#echo ${count} +if [ ${#sarea} -ne 0 -a ${sarea} = ${count} ]; then + text=`echo "do_pageout:variable count_sarea matched swap_area.count"` + ok_out "${text} :(${sarea})" +else + ng_out "do_pageout: The value of count_sarea does not match the value of swap_area.count." +fi + +#swapout013 d_pageout si->swphdr->count_marea +marea=`grep "do_pageout:.*si->swphdr->count_marea" ./result/swapout_copy_to_01.kmsg | head -n 1 | sed s/"^.*copy_to_user .*,si->swphdr->count_marea:\([0-9|a-f]*\),.*$"/"\1"/ ` +#echo ${marea} +count=`grep "do_pageout:.*si->mlock_area.count" ./result/swapout_copy_to_01.kmsg | head -n 1 | sed s/"^.*si->mlock_area.count:\([0-9|a-f]*\)$"/"\1"/ ` +#echo ${count} +if [ ${#marea} -ne 0 -a ${marea} = ${count} ]; then + text=`echo "do_pageout:variable count_marea matched mlock_area.count"` + ok_out "${text} :(${marea})" +else + ng_out "do_pageout: The value of count_marea does not match the value of mlock_area.count." +fi diff --git a/test/user_space/swapout/swapout_copy_to_02.sh b/test/user_space/swapout/swapout_copy_to_02.sh new file mode 100755 index 00000000..d6187ccb --- /dev/null +++ b/test/user_space/swapout/swapout_copy_to_02.sh @@ -0,0 +1,156 @@ +#!/bin/sh + +# Functions +function reboot() { + count=`pgrep -c -f 'mcexec '` + if [ ${count} -gt 0 ] + then + echo "kill process :" ${count} + pgrep -l -f 'mcexec ' + pgrep -f 'mcexec ' | xargs sudo kill -9 + fi +# echo -n "mckernel stopping... " + sudo ${MCMOD_DIR}/sbin/mcstop+release.sh +# echo "done." + #sleep 1 + echo -n "mckernel booting... " 1>&2 + sudo ${MCMOD_DIR}/sbin/mcreboot.sh $* + echo "done." 1>&2 +} + +function ok_out() { + echo "[OK] ${TEST_PREFIX}`printf %03d ${TEST_NUM}` $1" + (( TEST_NUM++ )) + TEST_CODE=`printf %03d ${TEST_NUM}` +} + +function ng_out() { + echo "[NG] ${TEST_PREFIX}`printf %03d ${TEST_NUM}` $1" + exit 1 +} + +TEST_PARAM_FILE=$1 +TEST_NUM=14 +TEST_CODE=001 +TEST_PREFIX=so_ + +ME=`whoami` + +# read config +source ./config + +MCPATH=${MCMOD_DIR} + +mkdir -p ./result + +reboot +#programを実行 logを保存 +${MCPATH}/bin/mcexec ./swaptest 2 >./result/swapout_copy_to_02.log + +#kmsgを保存 +sudo ${MCPATH}/sbin/ihkosctl 0 kmsg >./result/swapout_copy_to_02.kmsg + +#swapout014 arealist_preparewrite info[].start +start=`grep "arealist_preparewrite:.* info\[[0-9]\].start:" ./result/swapout_copy_to_02.kmsg | head -n 1 | sed s/"^.*copy_to_user info\[[0-9]\].start:\([0-9|a-f]*\),end:.*$"/"\1"/ ` +#echo ${start} +wstart=`grep "arealist_preparewrite:.* ,went.pair\[[0-9]\]\.start:" ./result/swapout_copy_to_02.kmsg | head -n 1 | sed s/"^.* ,went.pair\[[0-9]\]\.start:\([0-9|a-f]*\),end:.*$"/"\1"/ ` +#echo ${wstart} +if [ ${#start} -ne 0 -a "${start}" = "${wstart}" ]; then + text=`echo "arealist_preparewrite:info[].start matched went.pair[].start"` + ok_out "${text} :(${start})" +else + ng_out "arealist_preparewrite: does not match the value of info[].start" +fi + +#swapout015 arealist_preparewrite info[].end +end=`grep "arealist_preparewrite:.* info\[[0-9]\].start:" ./result/swapout_copy_to_02.kmsg | head -n 1 | sed s/"^.*copy_to_user info\[[0-9]\].start:[0-9|a-f]*,end:\([0-9|a-f]*\),flag:.*$"/"\1"/ ` +#echo ${end} +wend=`grep "arealist_preparewrite:.* ,went.pair\[[0-9]\]\.start:" ./result/swapout_copy_to_02.kmsg | head -n 1 | sed s/"^.* ,went.pair\[[0-9]\].start:[0-9|a-f]*,end:\([0-9|a-f]*\),flag:.*$"/"\1"/ ` +#echo ${wend} +if [ ${#end} -ne 0 -a "${end}" = "${wend}" ]; then + text=`echo "arealist_preparewrite:info[].end matched went.pair[].end"` + ok_out "${text} :(${end})" +else + ng_out "arealist_preparewrite: does not match the value of info[].end" +fi + +#swapout016 arealist_preparewrite info[].flag +flag=`grep "arealist_preparewrite:.* info\[[0-9]\].start:" ./result/swapout_copy_to_02.kmsg | head -n 1 | sed s/"^.*copy_to_user info\[[0-9]\].start:[0-9a-f]*,.*flag:\([0-9a-f]*\) ,.*$"/"\1"/ ` +#echo ${flag} +wflag=`grep "arealist_preparewrite:.* ,went.pair\[[0-9]\]\.start:" ./result/swapout_copy_to_02.kmsg | head -n 1 | sed s/"^.* ,went.pair\[[0-9]\].start:[0-9a-f]*,.*flag:\([0-9a-f]*\)$"/"\1"/ ` +#echo ${wflag} +if [ ${#flag} -ne 0 -a "${flag}" = "${wflag}" ]; then + text=`echo "arealist_preparewrite:info[].flag matched went.pair[].flag"` + ok_out "${text} :(${flag})" +else + ng_out "arealist_preparewrite: does not match the value of info[].flag" +fi + +#swapout017 arealist_preparewrite info[].pos +pos=`grep "arealist_preparewrite:.* info\[[0-9]\].pos:" ./result/swapout_copy_to_02.kmsg | head -n 1 | sed s/"^.*copy_to_user info\[[0-9]\].pos:\([0-9a-f]*\),pos:[0-9a-f]*$"/"\1"/ ` +#echo ${pos} +wpos=`grep "arealist_preparewrite:.* info\[[0-9]\].pos:" ./result/swapout_copy_to_02.kmsg | head -n 1 | sed s/"^.*copy_to_user info\[[0-9]\].pos:[0-9a-f]*,pos:\([0-9a-f]*\)$"/"\1"/ ` +#echo ${wpos} +if [ ${#pos} -ne 0 -a "${pos}" = "${wpos}" ]; then + text=`echo "arealist_preparewrite:info[].pos matched went.pair[].pos"` + ok_out "${text} :(${pos})" +else + ng_out "arealist_preparewrite: does not match the value of info[].pos" +fi + +#swapout018 pager_open swapfname +fname=`grep "pager_open: copy_to_user si->udata_buf:" ./result/swapout_copy_to_02.kmsg | head -n 1 | sed s/"^.* si->udata_buf:\(.*\),fname:.*$"/"\1"/ ` +#echo ${fname} +wfname=`grep "pager_open: copy_to_user si->udata_buf:" ./result/swapout_copy_to_02.kmsg | head -n 1 | sed s/"^.* si->udata_buf:.*,fname:\(.*\)$"/"\1"/ ` +#echo ${wfname} +if [ ${#fname} -ne 0 -a "${fname}" = "${wfname}" ]; then + text=`echo "pager_open:swapfname matched si-udate_buf"` + ok_out "${text} :(${fname})" +else + ng_out "pager_open: does not match the value of swapfname" +fi + +#swapout019 pager_unlink swapfname +fname=`grep "pager_unlink: copy_to_user si->udata_buf:" ./result/swapout_copy_to_02.kmsg | head -n 1 | sed s/"^.* si->udata_buf:\(.*\),fname:.*$"/"\1"/ ` +#echo ${fname} +wfname=`grep "pager_unlink: copy_to_user si->udata_buf:" ./result/swapout_copy_to_02.kmsg | head -n 1 | sed s/"^.* si->udata_buf:.*,fname:\(.*\)$"/"\1"/ ` +#echo ${wfname} +if [ ${#fname} -ne 0 -a "${fname}" = "${wfname}" ]; then + text=`echo "pager_unlink:swapfname matched si-udate_buf"` + ok_out "${text} :(${fname})" +else + ng_out "pager_unlink: does not match the value of swapfname" +fi + +#swapout020 arealist_get user_space initialize +count=`grep "arealist_get:" ./result/swapout_copy_to_02.kmsg | head -n 1 | sed s/"^.*tmp->count:\([0-9]\) area.*$"/"\1"/ ` +#echo ${count} +if [ "${count}" = "0" ]; then + text=`echo "arealist_get:arealist is inistialized."` + ok_out "${text} :(${count})" +else + ng_out "arealist_get: arealist was not initialized" +fi + +#swapout021 prealist_get arealist->next +next=`grep "arealist_get: copy_to_user" ./result/swapout_copy_to_02.kmsg | head -n 1 | sed s/"^.* area->tail->next \([0-9a-f]*\):\([0-9a-f]*\)$"/"\1"/ ` +#echo ${next} +wnext=`grep "arealist_get: copy_to_user" ./result/swapout_copy_to_02.kmsg | head -n 1 | sed s/"^.* area->tail->next \([0-9a-f]*\):\([0-9a-f]*\)$"/"\2"/ ` +#echo ${wnext} +if [ ${#next} -ne 0 -a "${next}" = "${wnext}" ]; then + text=`echo "arealist_get: area->tail->next is matched"` + ok_out "${text} :(${next})" +else + ng_out "arealist_get: does not match the value of area->tail->next" +fi + +#swapout022 arealist_alloc user_space initialize +count=`grep "arealist_alloc:" ./result/swapout_copy_to_02.kmsg | head -n 1 | sed s/"^.*areap->head->count:\([0-9]\)$"/"\1"/ ` +#echo ${count} +if [ "${count}" = "0" ]; then + text=`echo "arealist_alloc:arealist is inistialized."` + ok_out "${text} :(${count})" +else + ng_out "arealist_get: arealist was not initialized" +fi + diff --git a/test/user_space/swapout/swapout_normal.sh b/test/user_space/swapout/swapout_normal.sh new file mode 100755 index 00000000..0180b24d --- /dev/null +++ b/test/user_space/swapout/swapout_normal.sh @@ -0,0 +1,90 @@ +#!/bin/sh + +# Functions +function reboot() { + count=`pgrep -c -f 'mcexec '` + if [ ${count} -gt 0 ] + then + echo "kill process :" ${count} + pgrep -l -f 'mcexec ' + pgrep -f 'mcexec ' | xargs sudo kill -9 + fi +# echo -n "mckernel stopping... " + sudo ${MCMOD_DIR}/sbin/mcstop+release.sh +# echo "done." + #sleep 1 + echo -n "mckernel booting... " 1>&2 + sudo ${MCMOD_DIR}/sbin/mcreboot.sh $* + echo "done." 1>&2 +} + +function ok_out() { + echo "[OK] ${TEST_PREFIX}`printf %03d ${TEST_NUM}` $1" + (( TEST_NUM++ )) + TEST_CODE=`printf %03d ${TEST_NUM}` +} + +function ng_out() { + echo "[NG] ${TEST_PREFIX}`printf %03d ${TEST_NUM}` $1" + exit 1 +} + +TEST_PARAM_FILE=$1 +TEST_NUM=23 +TEST_CODE=001 +TEST_PREFIX=so_ + +ME=`whoami` + +# read config +source ./config + +MCPATH=${MCMOD_DIR} + +mkdir -p result + +reboot +#programを実行 logを保存 +${MCPATH}/bin/mcexec ./swaptest 2 >./result/swapout_normal.log + +#kmsgを保存 +sudo ${MCPATH}/sbin/ihkosctl 0 kmsg >./result/swapout_normal.kmsg + +#swapout023 execute swaptest(return code) +grep "^swapout returns: 0$" ./result/swapout_normal.log +ret=$? +if [ ${ret} -eq 0 ]; then + ok_out "swaptest program is nomrmal exit." +else + ng_out "swaptest pogram is abnormal exit." +fi + +#swapout024 execute swaptest (restore data) +grep "^data = hello$" ./result/swapout_normal.log +ret=$? +if [ ${ret} -eq 0 ]; then + ok_out "confirmed restoration of data." +else + ng_out "did not restore the data." +fi + +#wapout025 execute swapout (restore user space) +rc=1 +for str in `sed -n -e /"^.*: SWAP:.*$"/,/"^.*: MLOCK:.*$"/p ./result/swapout_normal.kmsg |sed -n s/"^\[ 0\]: \t\([0-9a-f]*\) -- \([0-9a-f]*\)$"/"\1:\2"/p` +do + grep ${str} ./result/swapout_normal.kmsg >/dev/null + rtn=$? + if [ ${rtn} -eq 0 ]; then + echo ${str} is matched. + rc=0 + else + echo ${str} is not matched. + rc=1 + break + fi +done +if [ ${rc} -eq 0 ]; then + ok_out "pageout areas and pagein areas are matched." +else + ng_out "pagein areas is not matched." +fi diff --git a/test/user_space/swapout/swaptest.c b/test/user_space/swapout/swaptest.c new file mode 100644 index 00000000..3c48446f --- /dev/null +++ b/test/user_space/swapout/swaptest.c @@ -0,0 +1,81 @@ +#include +#include +#include +#include +#include +#include +#define BUF_SIZE (32*1024) + +int data[1024*1024]; +char sym2[1024*1024] = { 10, 20, 30, 0 }; +char sym3[1024*1024] = { 10, 20, 30, 0 }; +char *sym1 = "aaaaaa"; +char buffer[BUF_SIZE]; +char *ptr1, *ptr2; +char fnamebuf[1024]; + +int +swapout(char *fname, void *buf, size_t sz, int flag) +{ + int cc; + cc = syscall(801, fname, buf, sz, flag); + return cc; +} +int +linux_mlock(const void *addr, size_t len) +{ + int cc; + cc = syscall(802, addr, len); + return cc; +} + + +int +main(int argc, char **argv) +{ + int cc; + int flag = 0; + + if (argc == 2) { + flag = atoi(argv[1]); + } + switch (flag) { + case 1: + printf("skipping real paging for debugging and just calling swapout in Linux\n"); + break; + case 2: + printf("skipping calling swapout in Linux\n"); + break; + } + printf("&data = %p\n", data); + printf("&sym1 = %p\n", &sym1); + printf("&sym2 = %p\n", sym2); + printf("&sym3 = %p\n", sym3); + printf("&cc = %p\n", &cc); + ptr1 = malloc(1024); + ptr2 = malloc(1024*1024); + printf("ptr1 = %p\n", ptr1); + printf("ptr2 = %p\n", ptr2); + sprintf((char*) data, "hello\n"); + /* + * testing mlock in mckernel side + */ + cc = mlock(data, 16*1024); + printf("McKernel mlock returns: %d\n", cc); + /* + * testing mlock in linux side + */ + cc = linux_mlock(data, 16*1024); + printf("linux_mlock returns: %d\n", cc); + strcpy(sym2, "returns: %d\n"); + strcpy(sym3, "data = %s\n"); + + /* buf area will be used in swapout systemcall for debugging */ + strcpy(fnamebuf, "/tmp/pages"); + cc = swapout(fnamebuf, buffer, BUF_SIZE, flag); + printf("swapout returns: %d\n", cc); + printf("data = %s", data); + printf(sym2, cc); + printf(sym3, data); + return 0; +} diff --git a/test/user_space/swapout/test_cases/CT01.txt b/test/user_space/swapout/test_cases/CT01.txt new file mode 100644 index 00000000..2b0cc714 --- /dev/null +++ b/test/user_space/swapout/test_cases/CT01.txt @@ -0,0 +1,5 @@ +TEST_PREFIX=CT01 +MPI_NODE_NUM=1 +PROC_PER_NODE=1 +MASTER=10.0.1.46 +SLAVE=