diff --git a/kernel/process.c b/kernel/process.c index afedae41..9282909c 100644 --- a/kernel/process.c +++ b/kernel/process.c @@ -2750,6 +2750,8 @@ void release_process_vm(struct process_vm *vm) { struct process *proc = vm->proc; + struct vm_range_numa_policy *policy; + struct rb_node *node; if (!ihk_atomic_dec_and_test(&vm->refcount)) { return; @@ -2777,6 +2779,15 @@ release_process_vm(struct process_vm *vm) detach_address_space(vm->address_space, vm->proc->pid); proc->vm = NULL; release_process(proc); + + while ((node = rb_first(&vm->vm_range_numa_policy_tree))) { + policy = rb_entry(node, struct vm_range_numa_policy, + policy_rb_node); + rb_erase(&policy->policy_rb_node, + &vm->vm_range_numa_policy_tree); + kfree(policy); + } + kfree(vm); } diff --git a/test/issues/1101/C1101.sh b/test/issues/1101/C1101.sh new file mode 100644 index 00000000..5058c9f1 --- /dev/null +++ b/test/issues/1101/C1101.sh @@ -0,0 +1,37 @@ +#!/bin/sh +USELTP=0 +USEOSTEST=0 +BOOTPARAM="-c 1-3 -m 1G@0 -e memdebug" + +. ../../common.sh + +################################################################################ +if unxz < C1101T01.txt.xz | grep '^end 1999 ' > /dev/null 2>&1; then + echo '*** C1101T01 PASS' +else + echo '*** C1101T01 FAILED' +fi + +$MCEXEC ./C1101T02 +sleep 2 +$IHKOSCTL 0 intr 200 +sleep 2 +$IHKOSCTL 0 clear_kmsg + +for i in 2 3 4 5; do + echo "*** C1101T0$i START" + if $MCEXEC ./C1101T0$i; then + sleep 2 + $IHKOSCTL 0 intr 200 + sleep 2 + l=`$IHKOSCTL 0 kmsg | grep "memory leak" | wc -l` + $IHKOSCTL 0 clear_kmsg + if [ $l = 0 ]; then + echo "*** C1101T0$i PASS" + else + echo "*** C1101T0$i FAILED" + fi + else + echo "*** C1101T0$i FAILED" + fi +done diff --git a/test/issues/1101/C1101T01.txt.xz b/test/issues/1101/C1101T01.txt.xz new file mode 100644 index 00000000..3d9654db Binary files /dev/null and b/test/issues/1101/C1101T01.txt.xz differ diff --git a/test/issues/1101/C1101T02.c b/test/issues/1101/C1101T02.c new file mode 100644 index 00000000..dfbbd72e --- /dev/null +++ b/test/issues/1101/C1101T02.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include +#include +#include +#include + +int +main(int argc, char **argv) +{ + void *p; + unsigned long mask; + + p = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, + -1, 0); + if (p == ((void *)-1)) { + perror("mmap"); + exit(1); + } + mask = 0; + if (mbind(p, 4096, MPOL_DEFAULT, &mask, 2, MPOL_MF_MOVE) == -1) { + perror("mbind"); + exit(1); + } + munmap(p, 4096); + exit(0); +} diff --git a/test/issues/1101/C1101T03.c b/test/issues/1101/C1101T03.c new file mode 100644 index 00000000..b23f7edc --- /dev/null +++ b/test/issues/1101/C1101T03.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include +#include +#include +#include + +int +main(int argc, char **argv) +{ + void *p; + unsigned long mask; + + p = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, + -1, 0); + if (p == ((void *)-1)) { + perror("mmap"); + exit(1); + } + mask = 1; + if (mbind(p, 4096, MPOL_BIND, &mask, 2, MPOL_MF_MOVE) == -1) { + perror("mbind"); + exit(1); + } + munmap(p, 4096); + exit(0); +} diff --git a/test/issues/1101/C1101T04.c b/test/issues/1101/C1101T04.c new file mode 100644 index 00000000..e5be7076 --- /dev/null +++ b/test/issues/1101/C1101T04.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include +#include +#include +#include + +int +main(int argc, char **argv) +{ + void *p; + unsigned long mask; + + p = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, + -1, 0); + if (p == ((void *)-1)) { + perror("mmap"); + exit(1); + } + mask = 1; + if (mbind(p, 4096, MPOL_INTERLEAVE, &mask, 2, MPOL_MF_MOVE) == -1) { + perror("mbind"); + exit(1); + } + munmap(p, 4096); + exit(0); +} diff --git a/test/issues/1101/C1101T05.c b/test/issues/1101/C1101T05.c new file mode 100644 index 00000000..9a8992da --- /dev/null +++ b/test/issues/1101/C1101T05.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include +#include +#include +#include + +int +main(int argc, char **argv) +{ + void *p; + unsigned long mask; + + p = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, + -1, 0); + if (p == ((void *)-1)) { + perror("mmap"); + exit(1); + } + mask = 1; + if (mbind(p, 4096, MPOL_PREFERRED, &mask, 2, MPOL_MF_MOVE) == -1) { + perror("mbind"); + exit(1); + } + munmap(p, 4096); + exit(0); +} diff --git a/test/issues/1101/C1101_arm64.txt b/test/issues/1101/C1101_arm64.txt new file mode 100644 index 00000000..056dfae5 --- /dev/null +++ b/test/issues/1101/C1101_arm64.txt @@ -0,0 +1,19 @@ +Script started on 2019-12-19 06:01:59+00:00 +bash-4.4$ make test +sh ./C1101.sh +aarch64 +mcstop+release.sh ... done +mcreboot.sh -c 1-3 -m 1G@0 -e memdebug ... done +*** C1101T01 PASS +*** C1101T02 START +*** C1101T02 PASS +*** C1101T03 START +*** C1101T03 PASS +*** C1101T04 START +*** C1101T04 PASS +*** C1101T05 START +*** C1101T05 PASS +bash-4.4$ exit +exit + +Script done on 2019-12-19 06:02:34+00:00 diff --git a/test/issues/1101/C1101_x86_64.txt b/test/issues/1101/C1101_x86_64.txt new file mode 100644 index 00000000..8e9b5706 --- /dev/null +++ b/test/issues/1101/C1101_x86_64.txt @@ -0,0 +1,23 @@ +Script started on Thu Dec 19 14:58:46 2019 +bash-4.2$ make test +gcc -g -Wall -o C1101T02 C1101T02.c -lnuma +gcc -g -Wall -o C1101T03 C1101T03.c -lnuma +gcc -g -Wall -o C1101T04 C1101T04.c -lnuma +gcc -g -Wall -o C1101T05 C1101T05.c -lnuma +sh ./C1101.sh +x86_64 +mcstop+release.sh ... done +mcreboot.sh -c 1-3 -m 1G@0 -e memdebug ... done +*** C1101T01 PASS +*** C1101T02 START +*** C1101T02 PASS +*** C1101T03 START +*** C1101T03 PASS +*** C1101T04 START +*** C1101T04 PASS +*** C1101T05 START +*** C1101T05 PASS +bash-4.2$ exit +exit + +Script done on Thu Dec 19 14:59:18 2019 diff --git a/test/issues/1101/Makefile b/test/issues/1101/Makefile new file mode 100644 index 00000000..5c689e7e --- /dev/null +++ b/test/issues/1101/Makefile @@ -0,0 +1,22 @@ +CC = gcc +TARGET = C1101T02 C1101T03 C1101T04 C1101T05 + +all:: $(TARGET) + +C1101T02: C1101T02.c + $(CC) -g -Wall -o $@ $^ -lnuma + +C1101T03: C1101T03.c + $(CC) -g -Wall -o $@ $^ -lnuma + +C1101T04: C1101T04.c + $(CC) -g -Wall -o $@ $^ -lnuma + +C1101T05: C1101T05.c + $(CC) -g -Wall -o $@ $^ -lnuma + +test:: all + sh ./C1101.sh + +clean:: + rm -f $(TARGET) *.o diff --git a/test/issues/1101/README b/test/issues/1101/README new file mode 100644 index 00000000..a1e8b8af --- /dev/null +++ b/test/issues/1101/README @@ -0,0 +1,24 @@ +【Issue#1101 動作確認】 +□ テスト内容 +1. Issue 指摘事項の再現確認 +C1101T01 OFPにてHPLを2000回連続実行し、現象が発生しないことを確認する。 + OFPでのHPL実行結果を C1101T01.txt.xz にxz圧縮形式で格納している。 + 2000回の連続実行に成功したことを以って PASS とする。 + +2. mbind を呼び出してメモリリークが発生しないことを確認する。 + 全てのテストが PASS すること。 +C1101T02 mbind(MPOL_DEFAULT) の動作確認。 +C1101T03 mbind(MPOL_BIND) の動作確認。 +C1101T04 mbind(MPOL_INTERLEAVE) の動作確認。 +C1101T05 mbind(MPOL_PREFERRED) の動作確認。 + +□ 実行手順 +$ make test + +McKernelのインストール先は、$HOME/.mck_test_config を +参照する。.mck_test_config は、McKernel をビルドした際に生成される +mck_test_config.sample ファイルを $HOME にコピーし、適宜編集すること。 + +□ 実行結果 +C1101_x86_64.txt(x86_64実行結果)、C1101_arm64.txt(arm64実行結果)参照。 +全ての項目が PASS していることを確認。