uti: futex call function in mcctrl

Previously, futex code of McKerenl was called by mccontrol,
but there ware some problems with this method.
(Mainly, location of McKernel image on memory)

Call futex code in mcctrl instead of the one in McKernel image,
giving the following benefits:
1. Not relying on shared kernel virtual address space with Linux any more
2. The cpu id store / retrieve is not needed and resulting in the code

Change-Id: Ic40929b64a655b270c435859fa287fedb713ee5c
refe: #1428
This commit is contained in:
Ken Sato
2020-09-18 14:42:26 +09:00
committed by Masamichi Takagi
parent 35296c8210
commit a9973e913d
62 changed files with 4320 additions and 1116 deletions

87
test/issues/1428/C1428.sh Executable file
View File

@ -0,0 +1,87 @@
#/bin/sh
USELTP=1
USEOSTEST=0
. ../../common.sh
issue="1428"
tid=01
arch="`uname -p`"
if [ "${arch}" == "x86_64" ]; then
UTI_TEST_DIR="../../uti"
elif [ "${arch}" == "aarch64" ]; then
UTI_TEST_DIR="../../uti/arm64"
else
echo "Error: ${arch} is unexpected arch"
exit 1
fi
# make uti test
pushd ${UTI_TEST_DIR}
make
popd
for tno in `seq 12 20`
do
tname=`printf "C${issue}T%02d" ${tid}`
echo "*** ${tname} start *******************************"
sudo ${MCEXEC} --enable-uti ${UTI_TEST_DIR}/CT${tno} 2>&1 | tee ./${tname}.txt
rc=$?
ngs=`grep "NG" ./${tname}.txt | wc -l`
if [ ${ngs} -eq 0 ]; then
echo "*** ${tname} PASSED ******************************"
else
echo "*** ${tname} FAILED ******************************"
fi
let tid++
echo ""
done
echo "*** Stop mckernel to exec CT31-34 on Linux"
mcstop
for tno in `seq 31 34`
do
sudo ${UTI_TEST_DIR}/CT${tno} -l &> ./lnx_CT${tno}.txt
done
echo "*** Boot mckernel"
mcreboot
echo ""
for tno in `seq 31 34`
do
tname=`printf "C${issue}T%02d" ${tid}`
echo "*** ${tname} start *******************************"
sudo ${MCEXEC} --enable-uti ${UTI_TEST_DIR}/CT${tno} 2>&1 | tee ./${tname}.txt
rc=$?
ngs=`grep "NG" ./${tname}.txt | wc -l`
echo "** Result on Linux **"
grep "waiter" ./lnx_CT${tno}.txt
if [ ${ngs} -eq 0 ]; then
echo "*** ${tname} PASSED ******************************"
else
echo "*** ${tname} FAILED ******************************"
fi
let tid++
echo ""
done
for tp in futex_wait01 futex_wait02 futex_wait03 futex_wait04 futex_wait_bitset01 futex_wait_bitset02 futex_wake01 futex_wake02 futex_wake03
do
tname=`printf "C${issue}T%02d" ${tid}`
echo "*** ${tname} start *******************************"
sudo $MCEXEC $LTPBIN/$tp 2>&1 | tee $tp.txt
ok=`grep PASS $tp.txt | wc -l`
ng=`grep FAIL $tp.txt | wc -l`
if [ $ng = 0 ]; then
echo "*** ${tname} PASSED ($ok)"
else
echo "*** ${tname} FAILED (ok=$ok ng=$ng)"
fi
let tid++
echo ""
done

11
test/issues/1428/Makefile Normal file
View File

@ -0,0 +1,11 @@
CFLAGS=-g
LDFLAGS=
TARGET=
all: $(TARGET)
test: all
./C1428.sh
clean:
rm -f $(TARGET) *.o *.txt

32
test/issues/1428/README Normal file
View File

@ -0,0 +1,32 @@
【Issue#1428 動作確認】
□ テスト内容
1. McKernelのuti用テストプログラムのうち、futex機能を用いるテストを実行し、
utiスレッドを用いたfutex機能が正常に動作することを確認
実行するのは、test/utiの中のCT1220、および、CT3134
テスト内容の詳細は、test/uti/README を参照
2. 以下のLTPを用いて既存のfutex機能に影響が無いことを確認
- futex_wait01
- futex_wait02
- futex_wait03
- futex_wait04
- futex_wake_bitset01
- futex_wake_bitset02
- futex_wake01
- futex_wake02
- futex_wake03
□ 実行手順
test/uti/Makefile または test/uti/arm64/Makefile 中の
UTI_DIR の内容を環境に合わせて変更する。
$ make test
McKernelのインストール先や、OSTEST, LTPの配置場所は、
$HOME/.mck_test_config を参照している
.mck_test_config は、McKernelをビルドした際に生成されるmck_test_config.sample ファイルを
$HOMEにコピーし、適宜編集する
□ 実行結果
x86_64_result.log aarch64_result.log 参照。
すべての項目をPASSしていることを確認。

View File

@ -0,0 +1,248 @@
./C1428.sh
mcstop+release.sh ... done
mcreboot.sh -c 37-43,49-55 -m 2G@2,2G@3 -r 37-43:36+49-55:48 -O ... done
~/src/mckernel/test/uti/arm64 ~/src/mckernel/test/issues/1428
~/src/mckernel/test/issues/1428
*** C1428T01 start *******************************
CT12001 futex START
CT12002 pthread_create OK
CT12100 running on Linux CPU OK
CT12003 FUTEX_WAKE OK
CT12101 FUTEX_WAIT OK
CT12004 pthread_join OK
CT12005 END
*** C1428T01 PASSED ******************************
*** C1428T02 start *******************************
CT13001 futex START
CT13002 pthread_create OK
CT13100 running on Linux CPU OK
CT13101 FUTEX_WAKE OK
CT13003 FUTEX_WAIT OK
CT13004 pthread_join OK
CT13005 END
*** C1428T02 PASSED ******************************
*** C1428T03 start *******************************
CT14001 futex START
CT14002 util_indicate_clone OK
CT14003 pthread_create OK
CT14004 lock first OK
CT14100 running on Linux OK
CT14101 lock second OK
CT14005 pthread_join OK
CT14006 END
nsec=94214570, nspw=9.421457
*** C1428T03 PASSED ******************************
*** C1428T04 start *******************************
CT15001 futex START
CT15002 util_indicate_clone OK
CT15003 pthread_create OK
CT15100 running on Linux OK
CT15101 lock first OK
CT15004 lock second OK
CT15005 pthread_join OK
CT15006 END
nsec=94214620, nspw=9.421462
*** C1428T04 PASSED ******************************
*** C1428T05 start *******************************
CT16001 futex START
CT16002 util_indicate_clone OK
CT16003 pthread_create OK
CT16101 running on Linux OK
CT16102 return from pthread_cond_wait() OK
CT16004 pthread_join OK
CT16005 END
*** C1428T05 PASSED ******************************
*** C1428T06 start *******************************
CT17001 futex START
CT17002 util_indicate_clone OK
CT17003 pthread_create OK
CT17004 lock on 0x4200a8 OK
CT17100 running on Linux OK
CT17005 wake on 0x4200e0 OK
CT17006 pthread_join OK
CT17007 END
*** C1428T06 PASSED ******************************
*** C1428T07 start *******************************
CT18001 futex START
CT18002 pthread_create OK
CT18101 running on Linux CPU OK
start=1613528413.931088714
op=109
end=1613528414.759485821
CT18102 FUTEX_WAIT OK
CT18103 timeout OK
CT18003 FUTEX_WAKE missing the waiter OK
CT18004 pthread_join OK
CT18005 END
*** C1428T07 PASSED ******************************
*** C1428T08 start *******************************
CT19001 futex START
CT19002 pthread_create OK
CT19100 running on Linux CPU OK
start=7347844.370216897
op=9
end=7347845.190062937
CT19101 FUTEX_WAIT OK
CT19102 timeout OK
CT19003 FUTEX_WAKE missing the waiter OK
CT19004 pthread_join OK
CT19005 END
*** C1428T08 PASSED ******************************
*** C1428T09 start *******************************
CT20001 futex START
CT20002 pthread_create OK
CT20100 running on Linux CPU OK
start=1613528425.067456921
end=1613528425.879490654
CT20101 FUTEX_WAIT OK
CT20102 timeout OK
CT20003 FUTEX_WAKE missing the waiter OK
CT20004 pthread_join OK
CT20005 END
*** C1428T09 PASSED ******************************
*** Stop mckernel to exec CT31-34 on Linux
mcstop+release.sh ... done
*** Boot mckernel
mcreboot.sh -c 37-43,49-55 -m 2G@2,2G@3 -r 37-43:36+49-55:48 -O ... done
*** C1428T10 start *******************************
[INFO] nloop=1000,blocktime=10000000
[INFO] Master thread (tid: 54422) is running on 00,00
nsec=94970130, nspw=9.497013
[ OK ] Master thread is running on McKernel
[ OK ] util_indicate_clone
[INFO] Utility thread (tid: 54440) is running on 29,29
[ OK ] Utility thread is running on Linux
[INFO] waker: 9756747550 nsec, waiter: 9762950100 nsec, (waiter - waker) / nloop: 6202 nsec
** Result on Linux **
[INFO] waker: 9984565840 nsec, waiter: 9988427640 nsec, (waiter - waker) / nloop: 3861 nsec
*** C1428T10 PASSED ******************************
*** C1428T11 start *******************************
[INFO] nloop=1000,blocktime=10000000
[INFO] Master thread (tid: 54449) is running on 00,00
nsec=95183170, nspw=9.518317
[ OK ] Master thread is running on McKernel
[ OK ] util_indicate_clone
[INFO] Utility thread (tid: 54467) is running on 27,27
[ OK ] Utility thread is running on Linux
[INFO] waker: 9724199060 nsec, waiter: 9730702360 nsec, (waiter - waker) / nloop: 6503 nsec
** Result on Linux **
[INFO] waker: 9987888970 nsec, waiter: 9991459180 nsec, (waiter - waker) / nloop: 3570 nsec
*** C1428T11 PASSED ******************************
*** C1428T12 start *******************************
[INFO] nloop=1000,blocktime=10000000
[INFO] Master thread (tid: 54476) is running on 00,00
nsec=96968310, nspw=9.696831
[ OK ] Master thread is running on McKernel
[ OK ] util_indicate_clone
[INFO] Utility thread (tid: 54494) is running on 27,27
[ OK ] Utility thread is running on Linux
[INFO] waiter: 9747346620 nsec, waker: 9736919490 nsec, (waiter - waker) / nloop: 10427 nsec
** Result on Linux **
[INFO] waiter: 9922548360 nsec, waker: 9918225010 nsec, (waiter - waker) / nloop: 4323 nsec
*** C1428T12 PASSED ******************************
*** C1428T13 start *******************************
[INFO] nloop=1000,blocktime=10000000
[INFO] Master thread (tid: 54503) is running on 01,01
nsec=94160460, nspw=9.416046
[ OK ] Master thread is running on McKernel
[ OK ] util_indicate_clone
[INFO] Utility thread (tid: 54521) is running on 01,01
[ OK ] Utility thread is running on Linux
[INFO] waiter: 10112660440 nsec, waker: 10105975190 nsec, (waiter - waker) / nloop: 6685 nsec
** Result on Linux **
[INFO] waiter: 10082423010 nsec, waker: 10078381240 nsec, (waiter - waker) / nloop: 4041 nsec
*** C1428T13 PASSED ******************************
*** C1428T14 start *******************************
futex_wait01 1 TPASS : futex_wait(): errno=ETIMEDOUT(110): Connection timed out
futex_wait01 2 TPASS : futex_wait(): errno=EAGAIN/EWOULDBLOCK(11): Resource temporarily unavailable
futex_wait01 3 TPASS : futex_wait(): errno=ETIMEDOUT(110): Connection timed out
futex_wait01 4 TPASS : futex_wait(): errno=EAGAIN/EWOULDBLOCK(11): Resource temporarily unavailable
*** C1428T14 PASSED (4)
*** C1428T15 start *******************************
futex_wait02 1 TPASS : futex_wait() woken up
*** C1428T15 PASSED (1)
*** C1428T16 start *******************************
futex_wait03 1 TPASS : futex_wait() woken up
*** C1428T16 PASSED (1)
*** C1428T17 start *******************************
futex_wait04 1 TPASS : futex_wait() returned -1: errno=EAGAIN/EWOULDBLOCK(11): Resource temporarily unavailable
*** C1428T17 PASSED (1)
*** C1428T18 start *******************************
tst_test.c:1096: INFO: Timeout per run is 0h 05m 00s
futex_wait_bitset.h:17: INFO: testing futex_wait_bitset() timeout with CLOCK_MONOTONIC
futex_wait_bitset.h:59: PASS: futex_wait_bitset() waited 102024us, expected 100010us
Summary:
passed 1
failed 0
skipped 0
warnings 0
*** C1428T18 PASSED (1)
*** C1428T19 start *******************************
tst_test.c:1096: INFO: Timeout per run is 0h 05m 00s
futex_wait_bitset.h:17: INFO: testing futex_wait_bitset() timeout with CLOCK_REALTIME
futex_wait_bitset.h:59: PASS: futex_wait_bitset() waited 101995us, expected 100010us
Summary:
passed 1
failed 0
skipped 0
warnings 0
*** C1428T19 PASSED (1)
*** C1428T20 start *******************************
futex_wake01 1 TPASS : futex_wake() returned 0
futex_wake01 2 TPASS : futex_wake() returned 0
futex_wake01 3 TPASS : futex_wake() returned 0
futex_wake01 4 TPASS : futex_wake() returned 0
futex_wake01 5 TPASS : futex_wake() returned 0
futex_wake01 6 TPASS : futex_wake() returned 0
*** C1428T20 PASSED (6)
*** C1428T21 start *******************************
futex_wake02 1 TPASS : futex_wake() woken up 1 threads
futex_wake02 2 TPASS : futex_wake() woken up 2 threads
futex_wake02 3 TPASS : futex_wake() woken up 3 threads
futex_wake02 4 TPASS : futex_wake() woken up 4 threads
futex_wake02 5 TPASS : futex_wake() woken up 5 threads
futex_wake02 6 TPASS : futex_wake() woken up 6 threads
futex_wake02 7 TPASS : futex_wake() woken up 7 threads
futex_wake02 8 TPASS : futex_wake() woken up 8 threads
futex_wake02 9 TPASS : futex_wake() woken up 9 threads
futex_wake02 10 TPASS : futex_wake() woken up 10 threads
futex_wake02 11 TPASS : futex_wake() woken up 0 threads
futex_wake02 0 TINFO : Child process returned TPASS
*** C1428T21 PASSED (12)
*** C1428T22 start *******************************
futex_wake03 1 TPASS : futex_wake() woken up 1 childs
futex_wake03 2 TPASS : futex_wake() woken up 2 childs
futex_wake03 3 TPASS : futex_wake() woken up 3 childs
futex_wake03 4 TPASS : futex_wake() woken up 4 childs
futex_wake03 5 TPASS : futex_wake() woken up 5 childs
futex_wake03 6 TPASS : futex_wake() woken up 6 childs
futex_wake03 7 TPASS : futex_wake() woken up 7 childs
futex_wake03 8 TPASS : futex_wake() woken up 8 childs
futex_wake03 9 TPASS : futex_wake() woken up 9 childs
futex_wake03 10 TPASS : futex_wake() woken up 10 childs
futex_wake03 11 TPASS : futex_wake() woken up 0 children
*** C1428T22 PASSED (11)

View File

@ -0,0 +1,131 @@
[m-takagi@wallaby14 1428]$ make test
./C1428.sh
mcstop+release.sh ... done
mcreboot.sh -k 0 -f LOG_LOCAL6 -c 1-7,9-15,17-23,25-31 -m 10G@0,10G@1 -r 1-7:0+9-15:8+17-23:16+25-31:24 -O ... done
~/project/os/mckernel/test/uti ~/project/os/mckernel/test/issues/1428
make[1]: Entering directory `/home/m-takagi/project/os/mckernel/test/uti'
dd bs=4096 count=1000 if=/dev/zero of=./file
1000+0 records in
1000+0 records out
4096000 bytes (4.1 MB) copied, 0.0398667 s, 103 MB/s
make[1]: Leaving directory `/home/m-takagi/project/os/mckernel/test/uti'
~/project/os/mckernel/test/issues/1428
*** Stop mckernel to exec CT31-34 on Linux
mcstop+release.sh ... done
*** Boot mckernel
mcreboot.sh -k 0 -f LOG_LOCAL6 -c 1-7,9-15,17-23,25-31 -m 10G@0,10G@1 -r 1-7:0+9-15:8+17-23:16+25-31:24 -O ... done
*** C1428T01 start *******************************
[INFO] nloop=1000,blocktime=10000000
[INFO] Master thread (tid: 1518) is running on 00,00
[ OK ] Master thread is running on McKernel
[ OK ] util_indicate_clone
[INFO] Utility thread (tid: 1551) is running on 00,00
[ OK ] Utility thread is running on Linux
[INFO] waker: 26037705112 cycles, waiter: 26042430924 cycles, (waiter - waker) / nloop: 4725 cycles
** Result on Linux **
[INFO] waker: 19797701232 cycles, waiter: 19799301694 cycles, (waiter - waker) / nloop: 1600 cycles
*** C1428T01 PASSED ******************************
*** C1428T02 start *******************************
[INFO] nloop=1000,blocktime=10000000
[INFO] Master thread (tid: 1568) is running on 00,00
[ OK ] Master thread is running on McKernel
[ OK ] util_indicate_clone
[INFO] Utility thread (tid: 1600) is running on 00,00
[ OK ] Utility thread is running on Linux
[INFO] waker: 26064839352 cycles, waiter: 26070575240 cycles, (waiter - waker) / nloop: 5735 cycles
** Result on Linux **
[INFO] waker: 24762320086 cycles, waiter: 24764268665 cycles, (waiter - waker) / nloop: 1948 cycles
*** C1428T02 PASSED ******************************
*** C1428T03 start *******************************
[INFO] nloop=1000,blocktime=10000000
[INFO] Master thread (tid: 1609) is running on 00,00
[ OK ] Master thread is running on McKernel
[ OK ] util_indicate_clone
[INFO] Utility thread (tid: 1641) is running on 00,00
[ OK ] Utility thread is running on Linux
[INFO] waiter: 26042752992 cycles, waker: 26037367808 cycles, (waiter - waker) / nloop: 5385 cycles
** Result on Linux **
[INFO] waiter: 25124067612 cycles, waker: 25122513727 cycles, (waiter - waker) / nloop: 1553 cycles
*** C1428T03 PASSED ******************************
*** C1428T04 start *******************************
[INFO] nloop=1000,blocktime=10000000
[INFO] Master thread (tid: 1651) is running on 01,01
[ OK ] Master thread is running on McKernel
[ OK ] util_indicate_clone
[INFO] Utility thread (tid: 1684) is running on 00,00
[ OK ] Utility thread is running on Linux
[INFO] waiter: 26004096360 cycles, waker: 25998796808 cycles, (waiter - waker) / nloop: 5299 cycles
** Result on Linux **
[INFO] waiter: 26289569877 cycles, waker: 26287829592 cycles, (waiter - waker) / nloop: 1740 cycles
*** C1428T04 PASSED ******************************
*** C1428T05 start *******************************
futex_wait01 1 TPASS : futex_wait(): errno=ETIMEDOUT(110): Connection timed out
futex_wait01 2 TPASS : futex_wait(): errno=EAGAIN/EWOULDBLOCK(11): Resource temporarily unavailable
futex_wait01 3 TPASS : futex_wait(): errno=ETIMEDOUT(110): Connection timed out
futex_wait01 4 TPASS : futex_wait(): errno=EAGAIN/EWOULDBLOCK(11): Resource temporarily unavailable
*** C1428T05 PASSED (4)
*** C1428T06 start *******************************
futex_wait02 1 TPASS : futex_wait() woken up
*** C1428T06 PASSED (1)
*** C1428T07 start *******************************
futex_wait03 1 TPASS : futex_wait() woken up
*** C1428T07 PASSED (1)
*** C1428T08 start *******************************
futex_wait04 1 TPASS : futex_wait() returned -1: errno=EAGAIN/EWOULDBLOCK(11): Resource temporarily unavailable
*** C1428T08 PASSED (1)
*** C1428T09 start *******************************
futex_wait_bitset01 0 TINFO : testing futex_wait_bitset() timeout with CLOCK_MONOTONIC
futex_wait_bitset01 1 TPASS : futex_wait_bitset() waited 146706us, expected 100010us
*** C1428T09 PASSED (1)
*** C1428T10 start *******************************
futex_wait_bitset02 0 TINFO : testing futex_wait_bitset() timeout with CLOCK_REALTIME
futex_wait_bitset02 1 TPASS : futex_wait_bitset() waited 146709us, expected 100010us
*** C1428T10 PASSED (1)
*** C1428T11 start *******************************
futex_wake01 1 TPASS : futex_wake() returned 0
futex_wake01 2 TPASS : futex_wake() returned 0
futex_wake01 3 TPASS : futex_wake() returned 0
futex_wake01 4 TPASS : futex_wake() returned 0
futex_wake01 5 TPASS : futex_wake() returned 0
futex_wake01 6 TPASS : futex_wake() returned 0
*** C1428T11 PASSED (6)
*** C1428T12 start *******************************
futex_wake02 1 TPASS : futex_wake() woken up 1 threads
futex_wake02 2 TPASS : futex_wake() woken up 2 threads
futex_wake02 3 TPASS : futex_wake() woken up 3 threads
futex_wake02 4 TPASS : futex_wake() woken up 4 threads
futex_wake02 5 TPASS : futex_wake() woken up 5 threads
futex_wake02 6 TPASS : futex_wake() woken up 6 threads
futex_wake02 7 TPASS : futex_wake() woken up 7 threads
futex_wake02 8 TPASS : futex_wake() woken up 8 threads
futex_wake02 9 TPASS : futex_wake() woken up 9 threads
futex_wake02 10 TPASS : futex_wake() woken up 10 threads
futex_wake02 11 TPASS : futex_wake() woken up 0 threads
futex_wake02 0 TINFO : Child process returned TPASS
*** C1428T12 PASSED (12)
*** C1428T13 start *******************************
futex_wake03 1 TPASS : futex_wake() woken up 1 childs
futex_wake03 2 TPASS : futex_wake() woken up 2 childs
futex_wake03 3 TPASS : futex_wake() woken up 3 childs
futex_wake03 4 TPASS : futex_wake() woken up 4 childs
futex_wake03 5 TPASS : futex_wake() woken up 5 childs
futex_wake03 6 TPASS : futex_wake() woken up 6 childs
futex_wake03 7 TPASS : futex_wake() woken up 7 childs
futex_wake03 8 TPASS : futex_wake() woken up 8 childs
futex_wake03 9 TPASS : futex_wake() woken up 9 childs
futex_wake03 10 TPASS : futex_wake() woken up 10 childs
futex_wake03 11 TPASS : futex_wake() woken up 0 children
*** C1428T13 PASSED (11)