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:
committed by
Masamichi Takagi
parent
35296c8210
commit
a9973e913d
87
test/issues/1428/C1428.sh
Executable file
87
test/issues/1428/C1428.sh
Executable 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
11
test/issues/1428/Makefile
Normal 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
32
test/issues/1428/README
Normal file
@ -0,0 +1,32 @@
|
||||
【Issue#1428 動作確認】
|
||||
□ テスト内容
|
||||
1. McKernelのuti用テストプログラムのうち、futex機能を用いるテストを実行し、
|
||||
utiスレッドを用いたfutex機能が正常に動作することを確認
|
||||
実行するのは、test/utiの中のCT12~20、および、CT31~34
|
||||
テスト内容の詳細は、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していることを確認。
|
||||
248
test/issues/1428/aarch64_result.log
Normal file
248
test/issues/1428/aarch64_result.log
Normal 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)
|
||||
131
test/issues/1428/x86_64_result.log
Normal file
131
test/issues/1428/x86_64_result.log
Normal 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)
|
||||
@ -83,26 +83,6 @@ double nspw; /* nsec per work */
|
||||
|
||||
#define N_INIT 10000000
|
||||
|
||||
void fwq_init(unsigned long *mem) {
|
||||
struct timespec start, end;
|
||||
unsigned long nsec;
|
||||
int i;
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
|
||||
BULK_FSW(N_INIT, mem);
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end);
|
||||
nsec = (TS2NS(end.tv_sec, end.tv_nsec) - TS2NS(start.tv_sec, start.tv_nsec));
|
||||
nspw = nsec / (double)N_INIT;
|
||||
printf("nsec=%ld, nspw=%f\n", nsec, nspw);
|
||||
}
|
||||
|
||||
void fwq(long delay_nsec, unsigned long* mem) {
|
||||
if (delay_nsec < 0) {
|
||||
printf("%s: delay_nsec<0\n", __FUNCTION__);
|
||||
}
|
||||
//printf("delay_nsec=%ld,count=%f\n", delay_nsec, delay_nsec / nspw);
|
||||
BULK_FSW(delay_nsec / nspw, mem);
|
||||
}
|
||||
|
||||
void mydelay(long delay_nsec, long *mem) {
|
||||
struct timespec start, end;
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
|
||||
@ -154,11 +134,11 @@ void *progress_fn(void *_arg) {
|
||||
break;
|
||||
}
|
||||
|
||||
fwq(POLL_DELAY, &arg->mem);
|
||||
fwq(POLL_DELAY);
|
||||
|
||||
/* Event found */
|
||||
if (nevents > 0) {
|
||||
fwq(COMPL_DELAY, &arg->mem); /* Simulate MPI protocol response */
|
||||
fwq(COMPL_DELAY); /* Simulate MPI protocol response */
|
||||
nevents = 0;
|
||||
}
|
||||
|
||||
@ -190,7 +170,7 @@ int main(int argc, char **argv) {
|
||||
fprintf(stdout, "CT09002 main running on McKernel INFO\n");
|
||||
}
|
||||
|
||||
fwq_init(&mem);
|
||||
fwq_init();
|
||||
pthread_mutex_init(&ep_lock, NULL);
|
||||
|
||||
thr_args.bar_count = 0;
|
||||
@ -243,16 +223,16 @@ int main(int argc, char **argv) {
|
||||
|
||||
/* Acquire endpoint and send request-to-send packet */
|
||||
pthread_mutex_lock(&ep_lock);
|
||||
fwq(RTS_DELAY, &mem);
|
||||
fwq(RTS_DELAY);
|
||||
pthread_mutex_unlock(&ep_lock);
|
||||
|
||||
/* Start calculation */
|
||||
|
||||
/* Generate event on behaf of responder */
|
||||
fwq(NIC_DELAY, &mem);
|
||||
fwq(NIC_DELAY);
|
||||
nevents++;
|
||||
|
||||
fwq(CALC_DELAY - NIC_DELAY, &mem); /* Overlap remainder */
|
||||
fwq(CALC_DELAY - NIC_DELAY); /* Overlap remainder */
|
||||
|
||||
/* Wait until async thread consumes the event */
|
||||
while (nevents > 0) {
|
||||
@ -260,7 +240,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
} else {
|
||||
/* No overlap case */
|
||||
fwq(RTS_DELAY + CALC_DELAY + POLL_DELAY + COMPL_DELAY, &mem);
|
||||
fwq(RTS_DELAY + CALC_DELAY + POLL_DELAY + COMPL_DELAY);
|
||||
}
|
||||
}
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end);
|
||||
|
||||
@ -34,23 +34,6 @@ double nspw; /* nsec per work */
|
||||
|
||||
#define N_INIT 10000000
|
||||
|
||||
void fwq_init(unsigned long *mem) {
|
||||
struct timespec start, end;
|
||||
unsigned long nsec;
|
||||
int i;
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
|
||||
BULK_FSW(N_INIT, mem);
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end);
|
||||
nsec = (TS2NS(end.tv_sec, end.tv_nsec) - TS2NS(start.tv_sec, start.tv_nsec));
|
||||
nspw = nsec / (double)N_INIT;
|
||||
printf("nsec=%ld, nspw=%f\n", nsec, nspw);
|
||||
}
|
||||
|
||||
void fwq(unsigned long delay_nsec, unsigned long* mem) {
|
||||
//printf("delay_nsec=%ld,count=%f\n", delay_nsec, delay_nsec / nspw);
|
||||
BULK_FSW(delay_nsec / nspw, mem);
|
||||
}
|
||||
|
||||
void *
|
||||
util_thread(void *arg)
|
||||
{
|
||||
@ -65,7 +48,7 @@ util_thread(void *arg)
|
||||
}
|
||||
errno = 0;
|
||||
|
||||
fwq(500 * 1000 * 1000UL, &mem); /* Sending debug messages through serial takes 0.05 sec */
|
||||
fwq(500 * 1000 * 1000UL); /* Sending debug messages through serial takes 0.05 sec */
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
if (owned) {
|
||||
@ -84,7 +67,7 @@ int main(int argc, char **argv) {
|
||||
unsigned long mem;
|
||||
|
||||
pthread_mutex_init(&mutex, NULL);
|
||||
fwq_init(&mem);
|
||||
fwq_init();
|
||||
|
||||
fprintf(stderr, "CT14001 futex START\n");
|
||||
|
||||
@ -110,7 +93,7 @@ int main(int argc, char **argv) {
|
||||
fprintf(stderr, "CT14004 lock first NG\n");
|
||||
}
|
||||
owned = 1;
|
||||
fwq(2000 * 1000 * 1000UL, &mem); /* Need 2 sec to make child sleep */
|
||||
fwq(2000 * 1000 * 1000UL); /* Need 2 sec to make child sleep */
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
pthread_join(thr, NULL);
|
||||
|
||||
@ -34,23 +34,6 @@ double nspw; /* nsec per work */
|
||||
|
||||
#define N_INIT 10000000
|
||||
|
||||
void fwq_init(unsigned long *mem) {
|
||||
struct timespec start, end;
|
||||
unsigned long nsec;
|
||||
int i;
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
|
||||
BULK_FSW(N_INIT, mem);
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end);
|
||||
nsec = (TS2NS(end.tv_sec, end.tv_nsec) - TS2NS(start.tv_sec, start.tv_nsec));
|
||||
nspw = nsec / (double)N_INIT;
|
||||
printf("nsec=%ld, nspw=%f\n", nsec, nspw);
|
||||
}
|
||||
|
||||
void fwq(unsigned long delay_nsec, unsigned long* mem) {
|
||||
//printf("delay_nsec=%ld,count=%f\n", delay_nsec, delay_nsec / nspw);
|
||||
BULK_FSW(delay_nsec / nspw, mem);
|
||||
}
|
||||
|
||||
void *
|
||||
util_thread(void *arg)
|
||||
{
|
||||
@ -72,7 +55,7 @@ util_thread(void *arg)
|
||||
fprintf(stderr, "CT14101 lock first NG\n");
|
||||
}
|
||||
owned = 1;
|
||||
fwq(2000 * 1000 * 1000UL, &mem); /* Need 2 sec to make parent sleep */
|
||||
fwq(2000 * 1000 * 1000UL); /* Need 2 sec to make parent sleep */
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
return NULL;
|
||||
@ -83,7 +66,7 @@ int main(int argc, char **argv) {
|
||||
unsigned long mem;
|
||||
|
||||
pthread_mutex_init(&mutex, NULL);
|
||||
fwq_init(&mem);
|
||||
fwq_init();
|
||||
|
||||
fprintf(stderr, "CT14001 futex START\n");
|
||||
|
||||
@ -102,7 +85,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
fprintf(stderr, "CT14003 pthread_create OK\n");
|
||||
|
||||
fwq(500 * 1000 * 1000UL, &mem); /* Sending debug messages through serial takes 0.05 sec */
|
||||
fwq(500 * 1000 * 1000UL); /* Sending debug messages through serial takes 0.05 sec */
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
if (owned) {
|
||||
|
||||
@ -74,23 +74,6 @@ double nspw; /* nsec per work */
|
||||
|
||||
#define N_INIT 10000000
|
||||
|
||||
void fwq_init(unsigned long *mem) {
|
||||
struct timespec start, end;
|
||||
unsigned long nsec;
|
||||
int i;
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
|
||||
BULK_FSW(N_INIT, mem);
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end);
|
||||
nsec = (TS2NS(end.tv_sec, end.tv_nsec) - TS2NS(start.tv_sec, start.tv_nsec));
|
||||
nspw = nsec / (double)N_INIT;
|
||||
printf("nsec=%ld, nspw=%f\n", nsec, nspw);
|
||||
}
|
||||
|
||||
void fwq(unsigned long delay_nsec, unsigned long* mem) {
|
||||
//printf("delay_nsec=%ld,count=%f\n", delay_nsec, delay_nsec / nspw);
|
||||
BULK_FSW(delay_nsec / nspw, mem);
|
||||
}
|
||||
|
||||
void mydelay(long delay_nsec, long *mem) {
|
||||
struct timespec start, end;
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
|
||||
@ -136,7 +119,7 @@ void *progress_fn(void *_arg) {
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&ep_lock);
|
||||
fwq(random() % 1000000000, &mem); /* 0 - 1 sec */
|
||||
fwq(random() % 1000000000); /* 0 - 1 sec */
|
||||
pthread_mutex_lock(&ep_lock);
|
||||
}
|
||||
return NULL;
|
||||
@ -156,7 +139,7 @@ int main(int argc, char **argv) {
|
||||
fprintf(stdout, "CT09002 main running on McKernel INFO\n");
|
||||
}
|
||||
|
||||
fwq_init(&mem);
|
||||
fwq_init();
|
||||
pthread_mutex_init(&ep_lock, NULL);
|
||||
|
||||
for(i = 0; i < NTHR; i++) {
|
||||
@ -189,7 +172,7 @@ int main(int argc, char **argv) {
|
||||
for (i = 0; i < 10; i++) {
|
||||
pthread_mutex_lock(&ep_lock);
|
||||
nevents++;
|
||||
fwq(random() % 1000000000, &mem); /* 0 - 1 sec */
|
||||
fwq(random() % 1000000000); /* 0 - 1 sec */
|
||||
pthread_mutex_unlock(&ep_lock);
|
||||
while (nevents > 0) {
|
||||
FIXED_SIZE_WORK(&mem);
|
||||
|
||||
@ -74,23 +74,6 @@ double nspw; /* nsec per work */
|
||||
|
||||
#define N_INIT 10000000
|
||||
|
||||
void fwq_init(unsigned long *mem) {
|
||||
struct timespec start, end;
|
||||
unsigned long nsec;
|
||||
int i;
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
|
||||
BULK_FSW(N_INIT, mem);
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end);
|
||||
nsec = (TS2NS(end.tv_sec, end.tv_nsec) - TS2NS(start.tv_sec, start.tv_nsec));
|
||||
nspw = nsec / (double)N_INIT;
|
||||
printf("nsec=%ld, nspw=%f\n", nsec, nspw);
|
||||
}
|
||||
|
||||
void fwq(unsigned long delay_nsec, unsigned long* mem) {
|
||||
//printf("delay_nsec=%ld,count=%f\n", delay_nsec, delay_nsec / nspw);
|
||||
BULK_FSW(delay_nsec / nspw, mem);
|
||||
}
|
||||
|
||||
void mydelay(long delay_nsec, long *mem) {
|
||||
struct timespec start, end;
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
|
||||
@ -126,7 +109,7 @@ void *progress_fn(void *_arg) {
|
||||
for (i = 0; i < 100; i++) {
|
||||
pthread_mutex_lock(&ep_lock);
|
||||
nevents++;
|
||||
fwq(random() % 100000000, &mem); /* 0 - 0.1 sec */
|
||||
fwq(random() % 100000000); /* 0 - 0.1 sec */
|
||||
pthread_mutex_unlock(&ep_lock);
|
||||
while (nevents > 0) {
|
||||
FIXED_SIZE_WORK(&mem);
|
||||
@ -150,7 +133,7 @@ int main(int argc, char **argv) {
|
||||
fprintf(stdout, "CT09002 main running on McKernel INFO\n");
|
||||
}
|
||||
|
||||
fwq_init(&mem);
|
||||
fwq_init();
|
||||
pthread_mutex_init(&ep_lock, NULL);
|
||||
|
||||
for(i = 0; i < NTHR; i++) {
|
||||
@ -193,7 +176,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&ep_lock);
|
||||
fwq(random() % 100000000, &mem); /* 0 - 0.1 sec */
|
||||
fwq(random() % 100000000); /* 0 - 0.1 sec */
|
||||
pthread_mutex_lock(&ep_lock);
|
||||
}
|
||||
pthread_mutex_unlock(&ep_lock);
|
||||
|
||||
@ -75,23 +75,6 @@ double nspw; /* nsec per work */
|
||||
|
||||
#define N_INIT 10000000
|
||||
|
||||
void fwq_init(unsigned long *mem) {
|
||||
struct timespec start, end;
|
||||
unsigned long nsec;
|
||||
int i;
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
|
||||
BULK_FSW(N_INIT, mem);
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end);
|
||||
nsec = (TS2NS(end.tv_sec, end.tv_nsec) - TS2NS(start.tv_sec, start.tv_nsec));
|
||||
nspw = nsec / (double)N_INIT;
|
||||
printf("nsec=%ld, nspw=%f\n", nsec, nspw);
|
||||
}
|
||||
|
||||
void fwq(unsigned long delay_nsec, unsigned long* mem) {
|
||||
//printf("delay_nsec=%ld,count=%f\n", delay_nsec, delay_nsec / nspw);
|
||||
BULK_FSW(delay_nsec / nspw, mem);
|
||||
}
|
||||
|
||||
void mydelay(long delay_nsec, long *mem) {
|
||||
struct timespec start, end;
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
|
||||
@ -135,7 +118,7 @@ void *progress_fn(void *_arg) {
|
||||
}
|
||||
nevents = 0;
|
||||
pthread_mutex_unlock(&ep_lock);
|
||||
fwq(random() % 100000000, &mem); /* 0 - 0.1 sec */
|
||||
fwq(random() % 100000000); /* 0 - 0.1 sec */
|
||||
pthread_mutex_lock(&ep_lock);
|
||||
}
|
||||
pthread_mutex_unlock(&ep_lock);
|
||||
@ -156,7 +139,7 @@ int main(int argc, char **argv) {
|
||||
fprintf(stdout, "CT09002 main running on McKernel INFO\n");
|
||||
}
|
||||
|
||||
fwq_init(&mem);
|
||||
fwq_init();
|
||||
pthread_cond_init(&ep_cond, NULL);
|
||||
pthread_mutex_init(&ep_lock, NULL);
|
||||
|
||||
@ -188,7 +171,7 @@ int main(int argc, char **argv) {
|
||||
fprintf(stdout, "CT09004 pthread_create OK\n");
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
|
||||
for (i = 0; i < 100; i++) {
|
||||
fwq(random() % 100000000, &mem); /* 0 - 0.1 sec */
|
||||
fwq(random() % 100000000); /* 0 - 0.1 sec */
|
||||
pthread_mutex_lock(&ep_lock);
|
||||
nevents++;
|
||||
pthread_cond_signal(&ep_cond);
|
||||
|
||||
@ -75,23 +75,6 @@ double nspw; /* nsec per work */
|
||||
|
||||
#define N_INIT 10000000
|
||||
|
||||
void fwq_init(unsigned long *mem) {
|
||||
struct timespec start, end;
|
||||
unsigned long nsec;
|
||||
int i;
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
|
||||
BULK_FSW(N_INIT, mem);
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end);
|
||||
nsec = (TS2NS(end.tv_sec, end.tv_nsec) - TS2NS(start.tv_sec, start.tv_nsec));
|
||||
nspw = nsec / (double)N_INIT;
|
||||
printf("nsec=%ld, nspw=%f\n", nsec, nspw);
|
||||
}
|
||||
|
||||
void fwq(unsigned long delay_nsec, unsigned long* mem) {
|
||||
//printf("delay_nsec=%ld,count=%f\n", delay_nsec, delay_nsec / nspw);
|
||||
BULK_FSW(delay_nsec / nspw, mem);
|
||||
}
|
||||
|
||||
void mydelay(long delay_nsec, long *mem) {
|
||||
struct timespec start, end;
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
|
||||
@ -125,7 +108,7 @@ void *progress_fn(void *_arg) {
|
||||
pthread_mutex_unlock(&arg->bar_lock);
|
||||
|
||||
for (i = 0; i < 100; i++) {
|
||||
fwq(random() % 100000000, &mem); /* 0 - 0.1 sec */
|
||||
fwq(random() % 100000000); /* 0 - 0.1 sec */
|
||||
pthread_mutex_lock(&ep_lock);
|
||||
nevents++;
|
||||
pthread_cond_signal(&ep_cond);
|
||||
@ -152,7 +135,7 @@ int main(int argc, char **argv) {
|
||||
fprintf(stdout, "CT09002 main running on McKernel INFO\n");
|
||||
}
|
||||
|
||||
fwq_init(&mem);
|
||||
fwq_init();
|
||||
pthread_mutex_init(&ep_lock, NULL);
|
||||
|
||||
for(i = 0; i < NTHR; i++) {
|
||||
@ -193,7 +176,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
nevents = 0;
|
||||
pthread_mutex_unlock(&ep_lock);
|
||||
fwq(random() % 100000000, &mem); /* 0 - 0.1 sec */
|
||||
fwq(random() % 100000000); /* 0 - 0.1 sec */
|
||||
pthread_mutex_lock(&ep_lock);
|
||||
}
|
||||
pthread_mutex_unlock(&ep_lock);
|
||||
|
||||
@ -102,25 +102,6 @@ double nspw; /* nsec per work */
|
||||
|
||||
#define N_INIT 10000000
|
||||
|
||||
void fwq_init() {
|
||||
struct timespec start, end;
|
||||
unsigned long nsec;
|
||||
int i;
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
|
||||
bulk_fsw(N_INIT);
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end);
|
||||
nsec = (TS2NS(end.tv_sec, end.tv_nsec) - TS2NS(start.tv_sec, start.tv_nsec));
|
||||
nspw = nsec / (double)N_INIT;
|
||||
printf("nsec=%ld, nspw=%f\n", nsec, nspw);
|
||||
}
|
||||
|
||||
void fwq(long delay_nsec) {
|
||||
if (delay_nsec < 0) {
|
||||
printf("%s: delay_nsec<0\n", __FUNCTION__);
|
||||
}
|
||||
//printf("delay_nsec=%ld,count=%f\n", delay_nsec, delay_nsec / nspw);
|
||||
bulk_fsw(delay_nsec / nspw);
|
||||
}
|
||||
int progress_responder(struct thr_arg *thr_arg) {
|
||||
int ret = 0;
|
||||
int j;
|
||||
|
||||
@ -152,25 +152,6 @@ static int print_cpu_last_executed_on() {
|
||||
goto fn_exit;
|
||||
}
|
||||
|
||||
void fwq_init() {
|
||||
struct timespec start, end;
|
||||
unsigned long nsec;
|
||||
int i;
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
|
||||
bulk_fsw(N_INIT);
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end);
|
||||
nsec = (TS2NS(end.tv_sec, end.tv_nsec) - TS2NS(start.tv_sec, start.tv_nsec));
|
||||
nspw = nsec / (double)N_INIT;
|
||||
printf("nsec=%ld, nspw=%f\n", nsec, nspw);
|
||||
}
|
||||
|
||||
void fwq(long delay_nsec) {
|
||||
if (delay_nsec < 0) {
|
||||
printf("%s: delay_nsec<0\n", __FUNCTION__);
|
||||
}
|
||||
bulk_fsw(delay_nsec / nspw);
|
||||
}
|
||||
|
||||
void init_bar(struct thr_arg* thr_arg) {
|
||||
pthread_mutex_lock(&thr_arg->bar_lock);
|
||||
thr_arg->bar_count= 0;
|
||||
|
||||
@ -44,26 +44,6 @@ static inline void bulk_fsw(unsigned long n) {
|
||||
|
||||
#define N_INIT 1000000
|
||||
|
||||
void fwq_init() {
|
||||
struct timespec start, end;
|
||||
unsigned long nsec;
|
||||
int i;
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
|
||||
bulk_fsw(N_INIT);
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end);
|
||||
nsec = (TS2NS(end.tv_sec, end.tv_nsec) - TS2NS(start.tv_sec, start.tv_nsec));
|
||||
nspw = nsec / (double)N_INIT;
|
||||
printf("nsec=%ld, nspw=%f\n", nsec, nspw);
|
||||
}
|
||||
|
||||
void fwq(long delay_nsec) {
|
||||
if (delay_nsec < 0) {
|
||||
printf("%s: delay_nsec<0\n", __FUNCTION__);
|
||||
}
|
||||
//printf("delay_nsec=%ld,count=%f\n", delay_nsec, delay_nsec / nspw);
|
||||
bulk_fsw(delay_nsec / nspw);
|
||||
}
|
||||
|
||||
void *util_thread(void *arg) {
|
||||
int rc;
|
||||
|
||||
|
||||
@ -53,23 +53,6 @@ double nspw; /* nsec per work */
|
||||
|
||||
#define N_INIT 10000000
|
||||
|
||||
void fwq_init(unsigned long *mem) {
|
||||
struct timespec start, end;
|
||||
unsigned long nsec;
|
||||
int i;
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
|
||||
BULK_FSW(N_INIT, mem);
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end);
|
||||
nsec = (TS2NS(end.tv_sec, end.tv_nsec) - TS2NS(start.tv_sec, start.tv_nsec));
|
||||
nspw = nsec / (double)N_INIT;
|
||||
printf("[INFO] nsec=%ld, nspw=%f\n", nsec, nspw);
|
||||
}
|
||||
|
||||
void fwq(unsigned long delay_nsec, unsigned long* mem) {
|
||||
//printf("delay_nsec=%ld,count=%f\n", delay_nsec, delay_nsec / nspw);
|
||||
BULK_FSW(delay_nsec / nspw, mem);
|
||||
}
|
||||
|
||||
void fwq_omp(unsigned long delay_nsec, unsigned long* mem) {
|
||||
#pragma omp parallel
|
||||
{
|
||||
@ -110,7 +93,7 @@ void *util_fn(void *_arg) {
|
||||
|
||||
if (nevents > 0) {
|
||||
nevents--;
|
||||
fwq(random() % 100000000, &mem); /* 0 - 0.1 sec */
|
||||
fwq(random() % 100000000); /* 0 - 0.1 sec */
|
||||
}
|
||||
pthread_mutex_unlock(&ep_lock);
|
||||
}
|
||||
@ -127,7 +110,7 @@ int main(int argc, char **argv) {
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret != -1, "Master is running on McKernel\n");
|
||||
|
||||
fwq_init(&mem);
|
||||
fwq_init();
|
||||
pthread_mutex_init(&ep_lock, NULL);
|
||||
|
||||
pthread_barrier_init(&bar, NULL, NTHR + 1);
|
||||
|
||||
@ -25,17 +25,20 @@ pthread_t thr;
|
||||
long t_cond_wait, t_fwq;
|
||||
long nloop;
|
||||
long blocktime = 10L * 1000 * 1000;
|
||||
int linux_run;
|
||||
|
||||
void *util_fn(void *arg)
|
||||
{
|
||||
int i;
|
||||
int ret;
|
||||
long start, end;
|
||||
long start, end;
|
||||
|
||||
print_cpu_last_executed_on("Utility thread");
|
||||
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret == -1, "Utility thread is running on Linux\n");
|
||||
if (!linux_run) {
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret == -1, "Utility thread is running on Linux\n");
|
||||
}
|
||||
|
||||
pthread_barrier_wait(&bar);
|
||||
for (i = 0; i < nloop; i++) {
|
||||
@ -50,7 +53,6 @@ void *util_fn(void *arg)
|
||||
flag = 1;
|
||||
pthread_cond_signal(&cond);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
}
|
||||
|
||||
fn_fail:
|
||||
@ -66,21 +68,24 @@ int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int ret;
|
||||
long start, end;
|
||||
long start, end;
|
||||
cpu_set_t cpuset;
|
||||
pthread_attr_t attr;
|
||||
pthread_barrierattr_t bar_attr;
|
||||
struct sched_param param = { .sched_priority = 99 };
|
||||
int opt;
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "+b:", options, NULL)) != -1) {
|
||||
while ((opt = getopt_long(argc, argv, "+b:l", options, NULL)) != -1) {
|
||||
switch (opt) {
|
||||
case 'b':
|
||||
blocktime = atoi(optarg);
|
||||
break;
|
||||
default: /* '?' */
|
||||
printf("unknown option %c\n", optopt);
|
||||
exit(1);
|
||||
case 'b':
|
||||
blocktime = atoi(optarg);
|
||||
break;
|
||||
case 'l':
|
||||
linux_run = 1;
|
||||
break;
|
||||
default: /* '?' */
|
||||
printf("unknown option %c\n", optopt);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
nloop = (10 * 1000000000UL) / blocktime;
|
||||
@ -103,11 +108,13 @@ int main(int argc, char **argv)
|
||||
pthread_barrierattr_init(&bar_attr);
|
||||
pthread_barrier_init(&bar, &bar_attr, 2);
|
||||
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret != -1, "Master thread is running on McKernel\n");
|
||||
if (!linux_run) {
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret != -1, "Master thread is running on McKernel\n");
|
||||
|
||||
ret = syscall(731, 1, NULL);
|
||||
OKNGNOJUMP(ret != -1, "util_indicate_clone\n");
|
||||
ret = syscall(731, 1, NULL);
|
||||
OKNGNOJUMP(ret != -1, "util_indicate_clone\n");
|
||||
}
|
||||
|
||||
if ((ret = pthread_attr_init(&attr))) {
|
||||
printf("%s: Error: pthread_attr_init failed (%d)\n", __FUNCTION__, ret);
|
||||
@ -128,11 +135,13 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if ((ret = sched_setscheduler(0, SCHED_FIFO, ¶m))) {
|
||||
fprintf(stderr, "Error: sched_setscheduler failed (%d)\n", ret);
|
||||
goto fn_fail;
|
||||
fprintf(stderr, "Warning: sched_setscheduler: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
syscall(701, 1 | 2);
|
||||
if (!linux_run) {
|
||||
syscall(701, 1 | 2);
|
||||
}
|
||||
pthread_barrier_wait(&bar);
|
||||
for (i = 0; i < nloop; i++) {
|
||||
start = rdtsc_light();
|
||||
@ -147,7 +156,9 @@ int main(int argc, char **argv)
|
||||
end = rdtsc_light();
|
||||
t_cond_wait += end - start;
|
||||
}
|
||||
syscall(701, 4 | 8);
|
||||
if (!linux_run) {
|
||||
syscall(701, 4 | 8);
|
||||
}
|
||||
|
||||
pthread_join(thr, NULL);
|
||||
printf("[INFO] waker: %ld cycles, waiter: %ld cycles, (waiter - waker) / nloop: %ld cycles\n", t_fwq, t_cond_wait, (t_cond_wait - t_fwq) / nloop);
|
||||
|
||||
102
test/uti/CT31.sh
102
test/uti/CT31.sh
@ -1,102 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
bn=`basename $0`
|
||||
fn=`echo $bn | sed 's/.sh//'`
|
||||
|
||||
nloop=800
|
||||
stop=0
|
||||
reboot=0
|
||||
go=0
|
||||
mck=0
|
||||
NNODES=1
|
||||
NPROC=$((1 * NNODES))
|
||||
LASTNODE=8200
|
||||
use_hfi=0
|
||||
|
||||
while getopts srgmh:N:P:L: OPT
|
||||
do
|
||||
case ${OPT} in
|
||||
s) stop=1
|
||||
;;
|
||||
r) reboot=1
|
||||
;;
|
||||
g) go=1
|
||||
;;
|
||||
m) mck=1
|
||||
;;
|
||||
h) use_hfi=1
|
||||
;;
|
||||
N) NNODES=$OPTARG
|
||||
;;
|
||||
P) NPROC=$OPTARG
|
||||
;;
|
||||
L) LASTNODE=$OPTARG
|
||||
;;
|
||||
*) echo "invalid option -${OPT}" >&2
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
|
||||
MYHOME=/work/gg10/e29005
|
||||
ABS_SRCDIR=${MYHOME}/project/os/mckernel/test/uti
|
||||
MCK=${MYHOME}/project/os/install
|
||||
|
||||
NODES=`echo $(seq -s ",c" $(($LASTNODE + 1 - $NNODES)) $LASTNODE) | sed 's/^/c/'`
|
||||
PPN=$((NPROC / NNODES))
|
||||
echo NPROC=$NPROC NNODES=$NNODES PPN=$PPN NODES=$NODES
|
||||
|
||||
if [ ${mck} -eq 1 ]; then
|
||||
MCEXEC="${MCK}/bin/mcexec"
|
||||
mcexecopt="--enable-uti"
|
||||
if [ ${use_hfi} -eq 1 ]; then
|
||||
mcexecopt="--enable-hfi1 $mcexecopt"
|
||||
fi
|
||||
else
|
||||
MCEXEC=
|
||||
mcexecopt=
|
||||
fi
|
||||
|
||||
if [ ${stop} -eq 1 ]; then
|
||||
PDSH_SSH_ARGS_APPEND="-tt -q" pdsh -t 2 -w $NODES \
|
||||
sudo mount /work
|
||||
|
||||
if [ ${mck} -eq 1 ]; then
|
||||
PDSH_SSH_ARGS_APPEND="-tt -q" pdsh -t 2 -w $NODES \
|
||||
/sbin/pidof mcexec \| xargs -r kill -9
|
||||
PDSH_SSH_ARGS_APPEND="-tt -q" pdsh -t 2 -w $NODES \
|
||||
sudo ${MCK}/sbin/mcstop+release.sh
|
||||
else
|
||||
:
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ${reboot} -eq 1 ]; then
|
||||
PDSH_SSH_ARGS_APPEND="-tt -q" pdsh -t 2 -w $NODES \
|
||||
sudo mount /work
|
||||
|
||||
if [ ${mck} -eq 1 ]; then
|
||||
PDSH_SSH_ARGS_APPEND="-tt -q" pdsh -t 2 -w $NODES \
|
||||
sudo ${MCK}/sbin/mcreboot.sh -c 2-17,70-85,138-153,206-221,20-35,88-103,156-171,224-239,36-51,104-119,172-187,240-255,52-67,120-135,188-203,256-271 -r 2-5,70-73,138-141,206-209:0+6-9,74-77,142-145,210-213:1+10-13,78-81,146-149,214-217:68+14-17,82-85,150-153,218-221:69+20-23,88-91,156-159,224-227:136+24-27,92-95,160-163,228-231:137+28-31,96-99,164-167,232-235:204+32-35,100-103,168-171,236-239:205+36-39,104-107,172-175,240-243:18+40-43,108-111,176-179,244-247:19+44-47,112-115,180-183,248-251:86+48-51,116-119,184-187,252-255:87+52-55,120-123,188-191,256-259:154+56-59,124-127,192-195,260-263:155+60-63,128-131,196-199,264-267:222+64-67,132-135,200-203,268-271:223 -m 32G@0,12G@1
|
||||
else
|
||||
:
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ${go} -eq 1 ]; then
|
||||
cd $ABS_SRCDIR
|
||||
make $fn
|
||||
|
||||
PDSH_SSH_ARGS_APPEND="-tt -q" pdsh -t 2 -w $NODES \
|
||||
ulimit -u 16384;
|
||||
PDSH_SSH_ARGS_APPEND="-tt -q" pdsh -t 2 -w $NODES \
|
||||
ulimit -s unlimited
|
||||
|
||||
for((count=0;count<nloop;count++)); do
|
||||
sudo $MCEXEC $mcexecopt ./$fn
|
||||
echo =====
|
||||
echo $count
|
||||
echo =====
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
160
test/uti/CT32.c
160
test/uti/CT32.c
@ -4,60 +4,57 @@
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <linux/futex.h>
|
||||
#include <sys/mman.h>
|
||||
#include <signal.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdint.h>
|
||||
#include <uti.h>
|
||||
#include "util.h"
|
||||
|
||||
#define WAITER_CPU 0
|
||||
#define WAKER_CPU 1
|
||||
|
||||
int sem;
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t cond;
|
||||
pthread_barrier_t bar;
|
||||
int flag;
|
||||
pthread_t thr;
|
||||
long t_futex_wait, t_fwq;
|
||||
long t_cond_wait, t_fwq;
|
||||
long nloop;
|
||||
long blocktime = 10L * 1000 * 1000;
|
||||
int linux_run;
|
||||
|
||||
void *util_fn(void *arg)
|
||||
{
|
||||
int i;
|
||||
int ret;
|
||||
long start, end;
|
||||
int testid = 32101;
|
||||
long start, end;
|
||||
|
||||
print_cpu_last_executed_on("Utility thread");
|
||||
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret == -1, "Utility thread is running on Linux\n");
|
||||
|
||||
pthread_barrier_wait(&bar);
|
||||
|
||||
for (i = 0; i < nloop; i++) {
|
||||
start = rdtsc_light();
|
||||
|
||||
fwq(blocktime);
|
||||
|
||||
end = rdtsc_light();
|
||||
t_fwq += end - start;
|
||||
|
||||
if ((ret = syscall(__NR_futex, &sem, FUTEX_WAKE, 1, NULL, NULL, 0)) == -1) {
|
||||
printf("Error: futex wake: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
//pthread_barrier_wait(&bar);
|
||||
|
||||
if (!linux_run) {
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret == -1, "Utility thread is running on Linux\n");
|
||||
}
|
||||
|
||||
pthread_barrier_wait(&bar);
|
||||
for (i = 0; i < nloop; i++) {
|
||||
start = rdtsc_light();
|
||||
|
||||
pthread_mutex_lock(&mutex); /* no futex */
|
||||
while(!flag) {
|
||||
pthread_cond_wait(&cond, &mutex); /* 1st futex */
|
||||
}
|
||||
flag = 0;
|
||||
pthread_mutex_unlock(&mutex); /* 2nd futex */
|
||||
|
||||
end = rdtsc_light();
|
||||
t_cond_wait += end - start;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
fn_fail:
|
||||
return NULL;
|
||||
}
|
||||
@ -71,21 +68,24 @@ int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int ret;
|
||||
long start, end;
|
||||
long start, end;
|
||||
cpu_set_t cpuset;
|
||||
pthread_attr_t attr;
|
||||
pthread_barrierattr_t bar_attr;
|
||||
struct sched_param param = { .sched_priority = 99 };
|
||||
int opt;
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "+b:", options, NULL)) != -1) {
|
||||
while ((opt = getopt_long(argc, argv, "+b:l", options, NULL)) != -1) {
|
||||
switch (opt) {
|
||||
case 'b':
|
||||
blocktime = atoi(optarg);
|
||||
break;
|
||||
default: /* '?' */
|
||||
printf("unknown option %c\n", optopt);
|
||||
exit(1);
|
||||
case 'b':
|
||||
blocktime = atoi(optarg);
|
||||
break;
|
||||
case 'l':
|
||||
linux_run = 1;
|
||||
break;
|
||||
default: /* '?' */
|
||||
printf("unknown option %c\n", optopt);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
nloop = (10 * 1000000000UL) / blocktime;
|
||||
@ -102,88 +102,66 @@ int main(int argc, char **argv)
|
||||
|
||||
fwq_init();
|
||||
|
||||
pthread_mutex_init(&mutex, NULL);
|
||||
pthread_cond_init(&cond, NULL);
|
||||
|
||||
pthread_barrierattr_init(&bar_attr);
|
||||
pthread_barrier_init(&bar, &bar_attr, 2);
|
||||
|
||||
if (!linux_run) {
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret != -1, "Master thread is running on McKernel\n");
|
||||
|
||||
ret = syscall(731, 1, NULL);
|
||||
OKNGNOJUMP(ret != -1, "util_indicate_clone\n");
|
||||
}
|
||||
|
||||
if ((ret = pthread_attr_init(&attr))) {
|
||||
printf("Error: pthread_attr_init: %s\n", strerror(errno));
|
||||
printf("%s: Error: pthread_attr_init failed (%d)\n", __FUNCTION__, ret);
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
#if 0
|
||||
uti_attr_t uti_attr;
|
||||
ret = uti_attr_init(&uti_attr);
|
||||
if (ret) {
|
||||
printf("%s: Error: uti_attr_init failed (%d)\n", __FUNCTION__, ret);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Give a hint that it's beneficial to prioritize it in scheduling. */
|
||||
ret = UTI_ATTR_HIGH_PRIORITY(&uti_attr);
|
||||
if (ret) {
|
||||
printf("%s: Error: UTI_ATTR_HIGH_PRIORITY failed (%d)\n", __FUNCTION__, ret);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED))) {
|
||||
printf("%s: Error: pthread_attr_setdetachstate failed (%d)\n", __FUNCTION__, ret);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((ret = uti_pthread_create(&thr, &attr, progress_function, NULL, &uti_attr))) {
|
||||
printf("%s: Error: uti_pthread_create: %s\n", __FUNCTION__, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((ret = uti_attr_destroy(&uti_attr))) {
|
||||
printf("%s: Error: uti_attr_destroy failed (%d)\n", __FUNCTION__, ret);
|
||||
exit(1);
|
||||
}
|
||||
#else
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(WAKER_CPU, &cpuset);
|
||||
|
||||
if ((ret = pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset))) {
|
||||
printf("Error: pthread_attr_setaffinity_np: %s\n", strerror(errno));
|
||||
printf("%s: Error: pthread_attr_setaffinity_np failed (%d)\n", __FUNCTION__, ret);
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret != -1, "Master thread is running on McKernel\n");
|
||||
|
||||
ret = syscall(731, 1, NULL);
|
||||
OKNGNOJUMP(ret != -1, "util_indicate_clone\n");
|
||||
|
||||
if ((ret = pthread_create(&thr, &attr, util_fn, NULL))) {
|
||||
printf("Error: pthread_create: %s\n", strerror(errno));
|
||||
fprintf(stderr, "Error: pthread_create failed (%d)\n", ret);
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if ((ret = sched_setscheduler(0, SCHED_FIFO, ¶m))) {
|
||||
printf("Error: sched_setscheduler: %s\n", strerror(errno));
|
||||
ret = -errno;
|
||||
goto fn_fail;
|
||||
fprintf(stderr, "Warning: sched_setscheduler: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
syscall(701, 1 | 2);
|
||||
if (!linux_run) {
|
||||
syscall(701, 1 | 2);
|
||||
}
|
||||
pthread_barrier_wait(&bar);
|
||||
start = rdtsc_light();
|
||||
for (i = 0; i < nloop; i++) {
|
||||
|
||||
if ((ret = syscall(__NR_futex, &sem, FUTEX_WAIT, 0, NULL, NULL, 0))) {
|
||||
printf("Error: futex wait failed (%s)\n", strerror(errno));
|
||||
}
|
||||
start = rdtsc_light();
|
||||
|
||||
//pthread_barrier_wait(&bar); /* 2nd futex */
|
||||
fwq(blocktime);
|
||||
|
||||
end = rdtsc_light();
|
||||
t_fwq += end - start;
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
flag = 1;
|
||||
pthread_cond_signal(&cond);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
}
|
||||
if (!linux_run) {
|
||||
syscall(701, 4 | 8);
|
||||
}
|
||||
end = rdtsc_light();
|
||||
t_futex_wait += end - start;
|
||||
syscall(701, 4 | 8);
|
||||
|
||||
pthread_join(thr, NULL);
|
||||
printf("[INFO] waiter: %ld cycles, waker: %ld cycles, (waiter - waker) / nloop: %ld cycles\n", t_fwq, t_futex_wait, (t_futex_wait - t_fwq) / nloop);
|
||||
printf("[INFO] waker: %ld cycles, waiter: %ld cycles, (waiter - waker) / nloop: %ld cycles\n", t_fwq, t_cond_wait, (t_cond_wait - t_fwq) / nloop);
|
||||
|
||||
ret = 0;
|
||||
fn_fail:
|
||||
|
||||
104
test/uti/CT32.sh
104
test/uti/CT32.sh
@ -1,104 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
bn=`basename $0`
|
||||
fn=`echo $bn | sed 's/.sh//'`
|
||||
|
||||
stop=0
|
||||
reboot=0
|
||||
go=0
|
||||
mck=0
|
||||
disable_uti=1
|
||||
NNODES=1
|
||||
NPROC=$((1 * NNODES))
|
||||
LASTNODE=8200
|
||||
use_hfi=0
|
||||
|
||||
while getopts srgmh:N:P:L:d: OPT
|
||||
do
|
||||
case ${OPT} in
|
||||
s) stop=1
|
||||
;;
|
||||
r) reboot=1
|
||||
;;
|
||||
g) go=1
|
||||
;;
|
||||
m) mck=1
|
||||
;;
|
||||
h) use_hfi=1
|
||||
;;
|
||||
d) disable_uti=$OPTARG
|
||||
;;
|
||||
N) NNODES=$OPTARG
|
||||
;;
|
||||
P) NPROC=$OPTARG
|
||||
;;
|
||||
L) LASTNODE=$OPTARG
|
||||
;;
|
||||
*) echo "invalid option -${OPT}" >&2
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
|
||||
MYHOME=/work/gg10/e29005
|
||||
ABS_SRCDIR=${MYHOME}/project/os/mckernel/test/uti
|
||||
MCK=${MYHOME}/project/os/install
|
||||
|
||||
NODES=`echo $(seq -s ",c" $(($LASTNODE + 1 - $NNODES)) $LASTNODE) | sed 's/^/c/'`
|
||||
PPN=$((NPROC / NNODES))
|
||||
echo NPROC=$NPROC NNODES=$NNODES PPN=$PPN NODES=$NODES
|
||||
|
||||
if [ $disable_uti -eq 1 ]; then
|
||||
export DISABLE_UTI=1
|
||||
else
|
||||
unset DISABLE_UTI
|
||||
fi
|
||||
|
||||
if [ ${mck} -eq 1 ]; then
|
||||
MCEXEC="${MCK}/bin/mcexec"
|
||||
mcexecopt="--enable-uti"
|
||||
if [ ${use_hfi} -eq 1 ]; then
|
||||
mcexecopt="--enable-hfi1 $mcexecopt"
|
||||
fi
|
||||
else
|
||||
MCEXEC=
|
||||
mcexecopt=
|
||||
fi
|
||||
|
||||
if [ ${stop} -eq 1 ]; then
|
||||
PDSH_SSH_ARGS_APPEND="-tt -q" pdsh -t 2 -w $NODES \
|
||||
sudo mount /work
|
||||
|
||||
if [ ${mck} -eq 1 ]; then
|
||||
PDSH_SSH_ARGS_APPEND="-tt -q" pdsh -t 2 -w $NODES \
|
||||
/sbin/pidof mcexec \| xargs -r kill -9
|
||||
PDSH_SSH_ARGS_APPEND="-tt -q" pdsh -t 2 -w $NODES \
|
||||
sudo ${MCK}/sbin/mcstop+release.sh
|
||||
else
|
||||
:
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ${reboot} -eq 1 ]; then
|
||||
PDSH_SSH_ARGS_APPEND="-tt -q" pdsh -t 2 -w $NODES \
|
||||
sudo mount /work
|
||||
|
||||
if [ ${mck} -eq 1 ]; then
|
||||
PDSH_SSH_ARGS_APPEND="-tt -q" pdsh -t 2 -w $NODES \
|
||||
sudo ${MCK}/sbin/mcreboot.sh -c 2-17,70-85,138-153,206-221,20-35,88-103,156-171,224-239,36-51,104-119,172-187,240-255,52-67,120-135,188-203,256-271 -r 2-5,70-73,138-141,206-209:0+6-9,74-77,142-145,210-213:1+10-13,78-81,146-149,214-217:68+14-17,82-85,150-153,218-221:69+20-23,88-91,156-159,224-227:136+24-27,92-95,160-163,228-231:137+28-31,96-99,164-167,232-235:204+32-35,100-103,168-171,236-239:205+36-39,104-107,172-175,240-243:18+40-43,108-111,176-179,244-247:19+44-47,112-115,180-183,248-251:86+48-51,116-119,184-187,252-255:87+52-55,120-123,188-191,256-259:154+56-59,124-127,192-195,260-263:155+60-63,128-131,196-199,264-267:222+64-67,132-135,200-203,268-271:223 -m 32G@0,12G@1
|
||||
else
|
||||
:
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ${go} -eq 1 ]; then
|
||||
cd $ABS_SRCDIR
|
||||
make $fn
|
||||
|
||||
PDSH_SSH_ARGS_APPEND="-tt -q" pdsh -t 2 -w $NODES \
|
||||
ulimit -u 16384;
|
||||
PDSH_SSH_ARGS_APPEND="-tt -q" pdsh -t 2 -w $NODES \
|
||||
ulimit -s unlimited
|
||||
|
||||
sudo $MCEXEC $mcexecopt ./$fn
|
||||
fi
|
||||
|
||||
102
test/uti/CT33.c
102
test/uti/CT33.c
@ -22,54 +22,46 @@ int sem;
|
||||
pthread_barrier_t bar;
|
||||
int flag;
|
||||
pthread_t thr;
|
||||
long t_fwq, t_futex_wake, t_futex_wait;
|
||||
long t_fwq2;
|
||||
long t_futex_wait, t_fwq;
|
||||
long nloop;
|
||||
long blocktime = 10 * 1000 * 1000L;
|
||||
long blocktime = 10L * 1000 * 1000;
|
||||
int linux_run;
|
||||
|
||||
void *util_fn(void *arg)
|
||||
{
|
||||
int i;
|
||||
int ret;
|
||||
long start, end;
|
||||
long start2, end2;
|
||||
long start, end;
|
||||
int testid = 32101;
|
||||
|
||||
print_cpu_last_executed_on("Utility thread");
|
||||
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret == -1, "Utility thread is running on Linux\n");
|
||||
|
||||
/* Measure fwq time */
|
||||
start = rdtsc_light();
|
||||
for (i = 0; i < nloop; i++) {
|
||||
fwq(blocktime);
|
||||
if (!linux_run) {
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret == -1, "Utility thread is running on Linux\n");
|
||||
}
|
||||
end = rdtsc_light();
|
||||
t_fwq2 += end - start;
|
||||
|
||||
/* Measure fwq + futex time */
|
||||
syscall(701, 1 | 2 | 0x80000000);
|
||||
pthread_barrier_wait(&bar);
|
||||
start = rdtsc_light();
|
||||
|
||||
for (i = 0; i < nloop; i++) {
|
||||
start2 = rdtsc_light();
|
||||
start = rdtsc_light();
|
||||
|
||||
fwq(blocktime);
|
||||
|
||||
end2 = rdtsc_light();
|
||||
t_fwq += end2 - start2;
|
||||
end = rdtsc_light();
|
||||
t_fwq += end - start;
|
||||
|
||||
if ((ret = syscall(__NR_futex, &sem, FUTEX_WAKE, 1, NULL, NULL, 0)) != 1) {
|
||||
printf("Error: futex wake failed (%d,%s)\n", ret, strerror(errno));
|
||||
sem = i + 1;
|
||||
if ((ret = syscall(__NR_futex, &sem, FUTEX_WAKE, 1,
|
||||
NULL, NULL, 0)) != 1) {
|
||||
printf("Error: futex wake: %d,%d\n", ret, errno);
|
||||
}
|
||||
|
||||
//pthread_barrier_wait(&bar);
|
||||
|
||||
}
|
||||
end = rdtsc_light();
|
||||
t_futex_wake += end - start;
|
||||
|
||||
syscall(701, 4 | 8 | 0x80000000);
|
||||
|
||||
ret = 0;
|
||||
fn_fail:
|
||||
return NULL;
|
||||
}
|
||||
@ -81,26 +73,29 @@ static struct option options[] = {
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i, j;
|
||||
int i;
|
||||
int ret;
|
||||
long start, end;
|
||||
long start, end;
|
||||
cpu_set_t cpuset;
|
||||
pthread_attr_t attr;
|
||||
pthread_barrierattr_t bar_attr;
|
||||
struct sched_param param = { .sched_priority = 99 };
|
||||
int opt;
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "+b:", options, NULL)) != -1) {
|
||||
while ((opt = getopt_long(argc, argv, "+b:l", options, NULL)) != -1) {
|
||||
switch (opt) {
|
||||
case 'b':
|
||||
blocktime = atoi(optarg);
|
||||
break;
|
||||
default: /* '?' */
|
||||
printf("unknown option %c\n", optopt);
|
||||
exit(1);
|
||||
case 'b':
|
||||
blocktime = atoi(optarg);
|
||||
break;
|
||||
case 'l':
|
||||
linux_run = 1;
|
||||
break;
|
||||
default: /* '?' */
|
||||
printf("unknown option %c\n", optopt);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
nloop = 10 * 1000000000UL / blocktime;
|
||||
nloop = (10 * 1000000000UL) / blocktime;
|
||||
printf("[INFO] nloop=%ld,blocktime=%ld\n", nloop, blocktime);
|
||||
|
||||
|
||||
@ -117,14 +112,8 @@ int main(int argc, char **argv)
|
||||
pthread_barrierattr_init(&bar_attr);
|
||||
pthread_barrier_init(&bar, &bar_attr, 2);
|
||||
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret != -1, "Master thread is running on McKernel\n");
|
||||
|
||||
ret = syscall(731, 1, NULL);
|
||||
OKNGNOJUMP(ret != -1, "util_indicate_clone\n");
|
||||
|
||||
if ((ret = pthread_attr_init(&attr))) {
|
||||
printf("Error: pthread_attr_init failed: %s\n", strerror(errno));
|
||||
printf("Error: pthread_attr_init: %s\n", strerror(errno));
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
@ -136,32 +125,45 @@ int main(int argc, char **argv)
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
if (!linux_run) {
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret != -1, "Master thread is running on McKernel\n");
|
||||
|
||||
ret = syscall(731, 1, NULL);
|
||||
OKNGNOJUMP(ret != -1, "util_indicate_clone\n");
|
||||
}
|
||||
|
||||
if ((ret = pthread_create(&thr, &attr, util_fn, NULL))) {
|
||||
printf("Error: pthread_create: %s\n", strerror(errno));
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
if ((ret = sched_setscheduler(0, SCHED_FIFO, ¶m))) {
|
||||
printf("Error: sched_setscheduler: %s\n", strerror(errno));
|
||||
goto fn_fail;
|
||||
printf("Warning: sched_setscheduler: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
if (!linux_run) {
|
||||
syscall(701, 1 | 2);
|
||||
}
|
||||
pthread_barrier_wait(&bar);
|
||||
start = rdtsc_light();
|
||||
for (i = 0; i < nloop; i++) {
|
||||
|
||||
if ((ret = syscall(__NR_futex, &sem, FUTEX_WAIT, 0, NULL, NULL, 0))) {
|
||||
printf("Error: futex wait: %s\n", strerror(errno));
|
||||
if ((ret = syscall(__NR_futex, &sem, FUTEX_WAIT, i, NULL, NULL, 0))) {
|
||||
printf("Error: futex wait failed (%s)\n", strerror(errno));
|
||||
}
|
||||
|
||||
//pthread_barrier_wait(&bar);
|
||||
//pthread_barrier_wait(&bar); /* 2nd futex */
|
||||
}
|
||||
end = rdtsc_light();
|
||||
t_futex_wait += end - start;
|
||||
if (!linux_run) {
|
||||
syscall(701, 4 | 8);
|
||||
}
|
||||
|
||||
pthread_join(thr, NULL);
|
||||
printf("[INFO] compute: %ld, wake: %ld, wait: %ld, wake - compute: %ld, wait - compute: %ld (cycles)\n", t_fwq, t_futex_wake, t_futex_wait, (t_futex_wake - t_fwq) / nloop, (t_futex_wait - t_fwq) / nloop);
|
||||
printf("[INFO] waiter: %ld cycles, waker: %ld cycles, (waiter - waker) / nloop: %ld cycles\n", t_futex_wait, t_fwq, (t_futex_wait - t_fwq) / nloop);
|
||||
|
||||
ret = 0;
|
||||
fn_fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1,93 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
bn=`basename $0`
|
||||
fn=`echo $bn | sed 's/.sh//'`
|
||||
|
||||
stop=0
|
||||
reboot=0
|
||||
go=0
|
||||
mck=0
|
||||
NNODES=1
|
||||
NPROC=$((1 * NNODES))
|
||||
LASTNODE=8200
|
||||
use_hfi=0
|
||||
|
||||
while getopts srgmh:N:P:L: OPT
|
||||
do
|
||||
case ${OPT} in
|
||||
s) stop=1
|
||||
;;
|
||||
r) reboot=1
|
||||
;;
|
||||
g) go=1
|
||||
;;
|
||||
m) mck=1
|
||||
;;
|
||||
h) use_hfi=1
|
||||
;;
|
||||
N) NNODES=$OPTARG
|
||||
;;
|
||||
P) NPROC=$OPTARG
|
||||
;;
|
||||
L) LASTNODE=$OPTARG
|
||||
;;
|
||||
*) echo "invalid option -${OPT}" >&2
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
|
||||
MYHOME=/work/gg10/e29005
|
||||
ABS_SRCDIR=${MYHOME}/project/os/mckernel/test/uti
|
||||
MCK=${MYHOME}/project/os/install
|
||||
|
||||
nodes=`echo $(seq -s ",c" $(($LASTNODE + 1 - $NNODES)) $LASTNODE) | sed 's/^/c/'`
|
||||
PPN=$((NPROC / NNODES))
|
||||
echo NPROC=$NPROC NNODES=$NNODES PPN=$PPN nodes=$nodes
|
||||
|
||||
if [ "`cat /etc/mtab | while read line; do cut -d" " -f 2; done | grep /work`" == "" ]; then
|
||||
PDSH_SSH_ARGS_APPEND="-tt -q" pdsh -t 2 -w $nodes sudo mount /work
|
||||
fi
|
||||
|
||||
if [ ${mck} -eq 1 ]; then
|
||||
MCEXEC="${MCK}/bin/mcexec"
|
||||
mcexecopt="--enable-uti"
|
||||
if [ ${use_hfi} -eq 1 ]; then
|
||||
mcexecopt="--enable-hfi1 $mcexecopt"
|
||||
fi
|
||||
else
|
||||
MCEXEC=
|
||||
mcexecopt=
|
||||
fi
|
||||
|
||||
if [ ${stop} -eq 1 ]; then
|
||||
if [ ${mck} -eq 1 ]; then
|
||||
PDSH_SSH_ARGS_APPEND="-tt -q" pdsh -t 2 -w $nodes \
|
||||
/sbin/pidof mcexec \| xargs -r kill -9
|
||||
PDSH_SSH_ARGS_APPEND="-tt -q" pdsh -t 2 -w $nodes \
|
||||
sudo ${MCK}/sbin/mcstop+release.sh
|
||||
else
|
||||
:
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ${reboot} -eq 1 ]; then
|
||||
if [ ${mck} -eq 1 ]; then
|
||||
PDSH_SSH_ARGS_APPEND="-tt -q" pdsh -t 2 -w $nodes \
|
||||
sudo ${MCK}/sbin/mcreboot.sh -c 2-17,70-85,138-153,206-221,20-35,88-103,156-171,224-239,36-51,104-119,172-187,240-255,52-67,120-135,188-203,256-271 -r 2-5,70-73,138-141,206-209:0+6-9,74-77,142-145,210-213:1+10-13,78-81,146-149,214-217:68+14-17,82-85,150-153,218-221:69+20-23,88-91,156-159,224-227:136+24-27,92-95,160-163,228-231:137+28-31,96-99,164-167,232-235:204+32-35,100-103,168-171,236-239:205+36-39,104-107,172-175,240-243:18+40-43,108-111,176-179,244-247:19+44-47,112-115,180-183,248-251:86+48-51,116-119,184-187,252-255:87+52-55,120-123,188-191,256-259:154+56-59,124-127,192-195,260-263:155+60-63,128-131,196-199,264-267:222+64-67,132-135,200-203,268-271:223 -m 32G@0,12G@1
|
||||
else
|
||||
:
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ${go} -eq 1 ]; then
|
||||
cd $ABS_SRCDIR
|
||||
make $fn
|
||||
|
||||
PDSH_SSH_ARGS_APPEND="-tt -q" pdsh -t 2 -w $nodes \
|
||||
ulimit -u 16384;
|
||||
PDSH_SSH_ARGS_APPEND="-tt -q" pdsh -t 2 -w $nodes \
|
||||
ulimit -s unlimited
|
||||
|
||||
sudo $MCEXEC $mcexecopt ./$fn
|
||||
fi
|
||||
|
||||
176
test/uti/CT34.c
176
test/uti/CT34.c
@ -1,62 +1,168 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sched.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <linux/futex.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdint.h>
|
||||
#include "util.h"
|
||||
|
||||
#define WAITER_CPU 0
|
||||
#define WAKER_CPU 1
|
||||
|
||||
int sem;
|
||||
pthread_barrier_t bar;
|
||||
int flag;
|
||||
pthread_t thr;
|
||||
long t_futex_wait, t_fwq;
|
||||
long nloop;
|
||||
long blocktime = 10L * 1000 * 1000;
|
||||
int linux_run;
|
||||
|
||||
void *util_fn(void *arg)
|
||||
{
|
||||
int i;
|
||||
int ret;
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret == -1, "Utility thread is running on Linux\n");
|
||||
long start, end;
|
||||
int testid = 32101;
|
||||
|
||||
print_cpu_last_executed_on("Utility thread");
|
||||
|
||||
if (!linux_run) {
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret == -1, "Utility thread is running on Linux\n");
|
||||
}
|
||||
|
||||
pthread_barrier_wait(&bar);
|
||||
start = rdtsc_light();
|
||||
for (i = 0; i < nloop; i++) {
|
||||
|
||||
if ((ret = syscall(__NR_futex, &sem, FUTEX_WAIT, i, NULL, NULL, 0))) {
|
||||
printf("Error: futex wait failed (%s)\n", strerror(errno));
|
||||
}
|
||||
|
||||
//pthread_barrier_wait(&bar); /* 2nd futex */
|
||||
}
|
||||
end = rdtsc_light();
|
||||
t_futex_wait += end - start;
|
||||
|
||||
ret = 0;
|
||||
fn_fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int my_thread_create()
|
||||
static struct option options[] = {
|
||||
/* end */
|
||||
{ NULL, 0, NULL, 0, }
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
pthread_t thr;
|
||||
int ret = 0;
|
||||
int i;
|
||||
int ret;
|
||||
long start, end;
|
||||
cpu_set_t cpuset;
|
||||
pthread_attr_t attr;
|
||||
pthread_barrierattr_t bar_attr;
|
||||
struct sched_param param = { .sched_priority = 99 };
|
||||
int opt;
|
||||
|
||||
ret = syscall(731, 1, NULL);
|
||||
OKNGNOJUMP(ret == 0, "util_indicate_clone,ret=%d,errno=%d\n", ret, errno);
|
||||
|
||||
if ((ret = pthread_create(&thr, NULL, util_fn, NULL))) {
|
||||
printf("Error: pthread_create: %s\n", strerror(errno));
|
||||
while ((opt = getopt_long(argc, argv, "+b:l", options, NULL)) != -1) {
|
||||
switch (opt) {
|
||||
case 'b':
|
||||
blocktime = atoi(optarg);
|
||||
break;
|
||||
case 'l':
|
||||
linux_run = 1;
|
||||
break;
|
||||
default: /* '?' */
|
||||
printf("unknown option %c\n", optopt);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
nloop = (10 * 1000000000UL) / blocktime;
|
||||
printf("[INFO] nloop=%ld,blocktime=%ld\n", nloop, blocktime);
|
||||
|
||||
|
||||
if ((ret = pthread_join(thr, NULL))) {
|
||||
printf("Error: pthread_join: %s\n", strerror(errno));
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(WAKER_CPU, &cpuset);
|
||||
if ((ret = sched_setaffinity(0, sizeof(cpu_set_t), &cpuset))) {
|
||||
printf("Error: sched_setaffinity: %s\n", strerror(errno));
|
||||
goto fn_fail;
|
||||
}
|
||||
print_cpu_last_executed_on("Master thread");
|
||||
|
||||
fwq_init();
|
||||
|
||||
pthread_barrierattr_init(&bar_attr);
|
||||
pthread_barrier_init(&bar, &bar_attr, 2);
|
||||
|
||||
if ((ret = pthread_attr_init(&attr))) {
|
||||
printf("Error: pthread_attr_init: %s\n", strerror(errno));
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
fn_exit:
|
||||
return ret;
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(WAITER_CPU, &cpuset);
|
||||
|
||||
fn_fail:
|
||||
ret = -1;
|
||||
goto fn_exit;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if ((ret = my_thread_create())) {
|
||||
printf("Error: my_thread_create,ret=%d\n", ret);
|
||||
if ((ret = pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset))) {
|
||||
printf("Error: pthread_attr_setaffinity_np: %s\n", strerror(errno));
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
fn_exit:
|
||||
return ret;
|
||||
if (!linux_run) {
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret != -1, "Master thread is running on McKernel\n");
|
||||
|
||||
ret = syscall(731, 1, NULL);
|
||||
OKNGNOJUMP(ret != -1, "util_indicate_clone\n");
|
||||
}
|
||||
|
||||
if ((ret = pthread_create(&thr, &attr, util_fn, NULL))) {
|
||||
printf("Error: pthread_create: %s\n", strerror(errno));
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
if ((ret = sched_setscheduler(0, SCHED_FIFO, ¶m))) {
|
||||
printf("Warning: sched_setscheduler: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
if (!linux_run) {
|
||||
syscall(701, 1 | 2);
|
||||
}
|
||||
pthread_barrier_wait(&bar);
|
||||
for (i = 0; i < nloop; i++) {
|
||||
start = rdtsc_light();
|
||||
|
||||
fwq(blocktime);
|
||||
|
||||
end = rdtsc_light();
|
||||
t_fwq += end - start;
|
||||
|
||||
sem = i + 1;
|
||||
if ((ret = syscall(__NR_futex, &sem, FUTEX_WAKE, 1,
|
||||
NULL, NULL, 0)) != 1) {
|
||||
printf("Error: futex wake: %d, %d\n", ret, errno);
|
||||
}
|
||||
|
||||
//pthread_barrier_wait(&bar);
|
||||
}
|
||||
if (!linux_run) {
|
||||
syscall(701, 4 | 8);
|
||||
}
|
||||
|
||||
pthread_join(thr, NULL);
|
||||
printf("[INFO] waiter: %ld cycles, waker: %ld cycles, (waiter - waker) / nloop: %ld cycles\n", t_futex_wait, t_fwq, (t_futex_wait - t_fwq) / nloop);
|
||||
|
||||
ret = 0;
|
||||
fn_fail:
|
||||
ret = -1;
|
||||
goto fn_exit;
|
||||
return ret;
|
||||
}
|
||||
|
||||
62
test/uti/CT35.c
Normal file
62
test/uti/CT35.c
Normal file
@ -0,0 +1,62 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sched.h>
|
||||
#include "util.h"
|
||||
|
||||
void *util_fn(void *arg)
|
||||
{
|
||||
int ret;
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret == -1, "Utility thread is running on Linux\n");
|
||||
fn_fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int my_thread_create()
|
||||
{
|
||||
pthread_t thr;
|
||||
int ret = 0;
|
||||
|
||||
ret = syscall(731, 1, NULL);
|
||||
OKNGNOJUMP(ret == 0, "util_indicate_clone,ret=%d,errno=%d\n", ret, errno);
|
||||
|
||||
if ((ret = pthread_create(&thr, NULL, util_fn, NULL))) {
|
||||
printf("Error: pthread_create: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
if ((ret = pthread_join(thr, NULL))) {
|
||||
printf("Error: pthread_join: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
fn_exit:
|
||||
return ret;
|
||||
|
||||
fn_fail:
|
||||
ret = -1;
|
||||
goto fn_exit;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if ((ret = my_thread_create())) {
|
||||
printf("Error: my_thread_create,ret=%d\n", ret);
|
||||
}
|
||||
|
||||
fn_exit:
|
||||
return ret;
|
||||
|
||||
fn_fail:
|
||||
ret = -1;
|
||||
goto fn_exit;
|
||||
}
|
||||
@ -1,13 +1,14 @@
|
||||
.SUFFIXES: # Disable implicit rules
|
||||
|
||||
SYSCALLL_INTERCEPT_DIR=$(HOME)/usr
|
||||
UTI_DIR=$(HOME)/project/uti/install
|
||||
SYSCALLL_INTERCEPT_DIR=$(MCK_DIR)
|
||||
include $(HOME)/.mck_test_config.mk
|
||||
|
||||
CC = gcc
|
||||
|
||||
CPPFLAGS = -I$(UTI_DIR)/include
|
||||
CCFLAGS = -g -O0
|
||||
LDFLAGS = -L$(UTI_DIR)/lib -Wl,-rpath,$(UTI_DIR)/lib -luti -lpthread -lrt
|
||||
LDFLAGS = -L$(UTI_DIR)/lib -Wl,-rpath,$(UTI_DIR)/lib -luti -lpthread -lrt
|
||||
LDFLAGS2 = -lpthread -lrt
|
||||
|
||||
SRCS = $(shell ls CT*.c)
|
||||
EXES = $(SRCS:.c=)
|
||||
@ -27,9 +28,21 @@ file::
|
||||
CT30.o:: CT30.c
|
||||
icc $(CCFLAGS) -qopenmp $(CPPFLAGS) -c $<
|
||||
|
||||
CT30: CT30.o
|
||||
CT30: CT30.o util.o
|
||||
icc -o $@ $^ $(LDFLAGS) -qopenmp
|
||||
|
||||
CT31: CT31.o util.o
|
||||
$(CC) -o $@ $^ $(LDFLAGS2) $(CPPFLAGS)
|
||||
|
||||
CT32: CT32.o util.o
|
||||
$(CC) -o $@ $^ $(LDFLAGS2) $(CPPFLAGS)
|
||||
|
||||
CT33: CT33.o util.o
|
||||
$(CC) -o $@ $^ $(LDFLAGS2) $(CPPFLAGS)
|
||||
|
||||
CT34: CT34.o util.o
|
||||
$(CC) -o $@ $^ $(LDFLAGS2) $(CPPFLAGS)
|
||||
|
||||
%.o:: %.c
|
||||
$(CC) $(CCFLAGS) $(CPPFLAGS) -c $<
|
||||
|
||||
|
||||
@ -338,14 +338,46 @@ CT29 no reverse offload
|
||||
CT30 CT21にopenmpスレッドを追加したテスト
|
||||
|
||||
CT31 pthread_cond_waitオーバーヘッド測定
|
||||
* waiterとwakerのCPUは、それぞれ、WAITER_CPU、WAKER_CPUで設定
|
||||
* Linuxがwaker、McKernelがwaiter
|
||||
|
||||
CT32 futex waitオーバーヘッド測定
|
||||
* waiterとwakerのCPUは、それぞれ、WAITER_CPU、WAKER_CPUで設定
|
||||
CT32 pthread_cond_waitオーバーヘッド測定
|
||||
* Linuxがwaiter、McKernelがwaker
|
||||
|
||||
CT33 futex wakeオーバーヘッド測定
|
||||
* waiterとwakerのCPUは、それぞれ、WAITER_CPU、WAKER_CPUで設定
|
||||
CT33 Main threadでfutex_wait, UTI threadでfutex_wakeをした場合のオーバーヘッド測定
|
||||
* Linuxがwaker、McKernelがwaiter
|
||||
|
||||
CT34 繰り返しpthread_create
|
||||
CT34 UTI threadでfutex_wait, Main threadでfutex_wakeをした場合のオーバーヘッド測定
|
||||
* Linuxがwaiter、McKernelがwaker
|
||||
|
||||
CT35 LD_PRELOADでsyscall_interceptを用いたsoをつけた場合のテスト
|
||||
CT35 繰り返しpthread_create
|
||||
|
||||
CT36 LD_PRELOADでsyscall_interceptを用いたsoをつけた場合のテスト
|
||||
|
||||
|
||||
==========
|
||||
How to run
|
||||
==========
|
||||
|
||||
Prepare $HOME/.mck_test_config. Example:
|
||||
|
||||
# Config file for McKernel tests
|
||||
MCK_DIR=/home/m-takagi/project/os/install
|
||||
BIN=/home/m-takagi/project/os/install/bin
|
||||
SBIN=/home/m-takagi/project/os/install/sbin
|
||||
: ${OSTEST:=/home/m-takagi/project/src/ostest}
|
||||
: ${LTP:=/home/m-takagi/project/src/ltp/install}
|
||||
BOOTPARAM="-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"
|
||||
: ${MCKERNEL_VERSION:=1.5.0}
|
||||
|
||||
Prepare $HOME/.mck_test_config.mk. Example:
|
||||
|
||||
# Config file for McKernel tests
|
||||
BIN ?= /home/m-takagi/project/os/install/bin
|
||||
SBIN ?= /home/m-takagi/project/os/install/sbin
|
||||
OSTEST ?=
|
||||
LTP ?=
|
||||
BOOTPARAM ?= -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
|
||||
MCK_DIR ?= /home/m-takagi/project/os/install
|
||||
ARCH ?= x86_64
|
||||
TARGET ?= smp-x86
|
||||
UTI_DIR ?= /home/m-takagi/project/uti/install_mckernel
|
||||
|
||||
171
test/uti/arm64/CT31.c
Normal file
171
test/uti/arm64/CT31.c
Normal file
@ -0,0 +1,171 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/mman.h>
|
||||
#include <signal.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include "util.h"
|
||||
|
||||
#define WAITER_CPU 0
|
||||
#define WAKER_CPU 1
|
||||
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t cond;
|
||||
pthread_barrier_t bar;
|
||||
int flag;
|
||||
pthread_t thr;
|
||||
long t_cond_wait, t_fwq;
|
||||
long nloop;
|
||||
long blocktime = 10L * 1000 * 1000;
|
||||
int linux_run;
|
||||
|
||||
void *util_fn(void *arg)
|
||||
{
|
||||
int i;
|
||||
int ret;
|
||||
long start, end;
|
||||
unsigned long mem;
|
||||
|
||||
print_cpu_last_executed_on("Utility thread");
|
||||
|
||||
if (!linux_run) {
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret == -1, "Utility thread is running on Linux\n");
|
||||
}
|
||||
|
||||
pthread_barrier_wait(&bar);
|
||||
for (i = 0; i < nloop; i++) {
|
||||
start = rdtsc_light();
|
||||
|
||||
fwq(blocktime, &mem);
|
||||
|
||||
end = rdtsc_light();
|
||||
t_fwq += end - start;
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
flag = 1;
|
||||
pthread_cond_signal(&cond);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
}
|
||||
|
||||
fn_fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct option options[] = {
|
||||
/* end */
|
||||
{ NULL, 0, NULL, 0, }
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int ret;
|
||||
long start, end;
|
||||
cpu_set_t cpuset;
|
||||
pthread_attr_t attr;
|
||||
pthread_barrierattr_t bar_attr;
|
||||
struct sched_param param = { .sched_priority = 99 };
|
||||
int opt;
|
||||
unsigned long mem;
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "+b:l", options, NULL)) != -1) {
|
||||
switch (opt) {
|
||||
case 'b':
|
||||
blocktime = atoi(optarg);
|
||||
break;
|
||||
case 'l':
|
||||
linux_run = 1;
|
||||
break;
|
||||
default: /* '?' */
|
||||
printf("unknown option %c\n", optopt);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
nloop = (10 * 1000000000UL) / blocktime;
|
||||
printf("[INFO] nloop=%ld,blocktime=%ld\n", nloop, blocktime);
|
||||
|
||||
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(WAITER_CPU, &cpuset);
|
||||
if ((ret = sched_setaffinity(0, sizeof(cpu_set_t), &cpuset))) {
|
||||
printf("Error: sched_setaffinity: %s\n", strerror(errno));
|
||||
goto fn_fail;
|
||||
}
|
||||
print_cpu_last_executed_on("Master thread");
|
||||
|
||||
fwq_init(&mem);
|
||||
|
||||
pthread_mutex_init(&mutex, NULL);
|
||||
pthread_cond_init(&cond, NULL);
|
||||
|
||||
pthread_barrierattr_init(&bar_attr);
|
||||
pthread_barrier_init(&bar, &bar_attr, 2);
|
||||
|
||||
if (!linux_run) {
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret != -1, "Master thread is running on McKernel\n");
|
||||
|
||||
ret = syscall(731, 1, NULL);
|
||||
OKNGNOJUMP(ret != -1, "util_indicate_clone\n");
|
||||
}
|
||||
|
||||
if ((ret = pthread_attr_init(&attr))) {
|
||||
printf("%s: Error: pthread_attr_init failed (%d)\n", __FUNCTION__, ret);
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(WAKER_CPU, &cpuset);
|
||||
|
||||
if ((ret = pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset))) {
|
||||
printf("%s: Error: pthread_attr_setaffinity_np failed (%d)\n", __FUNCTION__, ret);
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
if ((ret = pthread_create(&thr, &attr, util_fn, NULL))) {
|
||||
fprintf(stderr, "Error: pthread_create failed (%d)\n", ret);
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
if ((ret = sched_setscheduler(0, SCHED_FIFO, ¶m))) {
|
||||
fprintf(stderr, "Warning: sched_setscheduler: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
if (!linux_run) {
|
||||
syscall(701, 1 | 2);
|
||||
}
|
||||
pthread_barrier_wait(&bar);
|
||||
for (i = 0; i < nloop; i++) {
|
||||
start = rdtsc_light();
|
||||
|
||||
pthread_mutex_lock(&mutex); /* no futex */
|
||||
while(!flag) {
|
||||
pthread_cond_wait(&cond, &mutex); /* 1st futex */
|
||||
}
|
||||
flag = 0;
|
||||
pthread_mutex_unlock(&mutex); /* 2nd futex */
|
||||
|
||||
end = rdtsc_light();
|
||||
t_cond_wait += end - start;
|
||||
}
|
||||
if (!linux_run) {
|
||||
syscall(701, 4 | 8);
|
||||
}
|
||||
|
||||
pthread_join(thr, NULL);
|
||||
printf("[INFO] waker: %ld nsec, waiter: %ld nsec, (waiter - waker) / nloop: %ld nsec\n", t_fwq * 10, t_cond_wait * 10, (t_cond_wait - t_fwq) * 10 / nloop);
|
||||
|
||||
ret = 0;
|
||||
fn_fail:
|
||||
return ret;
|
||||
}
|
||||
171
test/uti/arm64/CT32.c
Normal file
171
test/uti/arm64/CT32.c
Normal file
@ -0,0 +1,171 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/mman.h>
|
||||
#include <signal.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include "util.h"
|
||||
|
||||
#define WAITER_CPU 0
|
||||
#define WAKER_CPU 1
|
||||
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t cond;
|
||||
pthread_barrier_t bar;
|
||||
int flag;
|
||||
pthread_t thr;
|
||||
long t_cond_wait, t_fwq;
|
||||
long nloop;
|
||||
long blocktime = 10L * 1000 * 1000;
|
||||
int linux_run;
|
||||
|
||||
void *util_fn(void *arg)
|
||||
{
|
||||
int i;
|
||||
int ret;
|
||||
long start, end;
|
||||
unsigned long mem;
|
||||
|
||||
print_cpu_last_executed_on("Utility thread");
|
||||
|
||||
if (!linux_run) {
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret == -1, "Utility thread is running on Linux\n");
|
||||
}
|
||||
|
||||
pthread_barrier_wait(&bar);
|
||||
for (i = 0; i < nloop; i++) {
|
||||
start = rdtsc_light();
|
||||
|
||||
pthread_mutex_lock(&mutex); /* no futex */
|
||||
while(!flag) {
|
||||
pthread_cond_wait(&cond, &mutex); /* 1st futex */
|
||||
}
|
||||
flag = 0;
|
||||
pthread_mutex_unlock(&mutex); /* 2nd futex */
|
||||
|
||||
end = rdtsc_light();
|
||||
t_cond_wait += end - start;
|
||||
}
|
||||
|
||||
fn_fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct option options[] = {
|
||||
/* end */
|
||||
{ NULL, 0, NULL, 0, }
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int ret;
|
||||
long start, end;
|
||||
cpu_set_t cpuset;
|
||||
pthread_attr_t attr;
|
||||
pthread_barrierattr_t bar_attr;
|
||||
struct sched_param param = { .sched_priority = 99 };
|
||||
int opt;
|
||||
unsigned long mem;
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "+b:l", options, NULL)) != -1) {
|
||||
switch (opt) {
|
||||
case 'b':
|
||||
blocktime = atoi(optarg);
|
||||
break;
|
||||
case 'l':
|
||||
linux_run = 1;
|
||||
break;
|
||||
default: /* '?' */
|
||||
printf("unknown option %c\n", optopt);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
nloop = (10 * 1000000000UL) / blocktime;
|
||||
printf("[INFO] nloop=%ld,blocktime=%ld\n", nloop, blocktime);
|
||||
|
||||
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(WAITER_CPU, &cpuset);
|
||||
if ((ret = sched_setaffinity(0, sizeof(cpu_set_t), &cpuset))) {
|
||||
printf("Error: sched_setaffinity: %s\n", strerror(errno));
|
||||
goto fn_fail;
|
||||
}
|
||||
print_cpu_last_executed_on("Master thread");
|
||||
|
||||
fwq_init(&mem);
|
||||
|
||||
pthread_mutex_init(&mutex, NULL);
|
||||
pthread_cond_init(&cond, NULL);
|
||||
|
||||
pthread_barrierattr_init(&bar_attr);
|
||||
pthread_barrier_init(&bar, &bar_attr, 2);
|
||||
|
||||
if (!linux_run) {
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret != -1, "Master thread is running on McKernel\n");
|
||||
|
||||
ret = syscall(731, 1, NULL);
|
||||
OKNGNOJUMP(ret != -1, "util_indicate_clone\n");
|
||||
}
|
||||
|
||||
if ((ret = pthread_attr_init(&attr))) {
|
||||
printf("%s: Error: pthread_attr_init failed (%d)\n", __FUNCTION__, ret);
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(WAKER_CPU, &cpuset);
|
||||
|
||||
if ((ret = pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset))) {
|
||||
printf("%s: Error: pthread_attr_setaffinity_np failed (%d)\n", __FUNCTION__, ret);
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
if ((ret = pthread_create(&thr, &attr, util_fn, NULL))) {
|
||||
fprintf(stderr, "Error: pthread_create failed (%d)\n", ret);
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
if ((ret = sched_setscheduler(0, SCHED_FIFO, ¶m))) {
|
||||
fprintf(stderr, "Warning: sched_setscheduler: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
if (!linux_run) {
|
||||
syscall(701, 1 | 2);
|
||||
}
|
||||
pthread_barrier_wait(&bar);
|
||||
for (i = 0; i < nloop; i++) {
|
||||
start = rdtsc_light();
|
||||
|
||||
fwq(blocktime, &mem);
|
||||
|
||||
end = rdtsc_light();
|
||||
t_fwq += end - start;
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
flag = 1;
|
||||
pthread_cond_signal(&cond);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
}
|
||||
if (!linux_run) {
|
||||
syscall(701, 4 | 8);
|
||||
}
|
||||
|
||||
pthread_join(thr, NULL);
|
||||
printf("[INFO] waker: %ld nsec, waiter: %ld nsec, (waiter - waker) / nloop: %ld nsec\n", t_fwq * 10, t_cond_wait * 10, (t_cond_wait - t_fwq) * 10 / nloop);
|
||||
|
||||
ret = 0;
|
||||
fn_fail:
|
||||
return ret;
|
||||
}
|
||||
171
test/uti/arm64/CT33.c
Normal file
171
test/uti/arm64/CT33.c
Normal file
@ -0,0 +1,171 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <linux/futex.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdint.h>
|
||||
#include "util.h"
|
||||
|
||||
#define WAITER_CPU 0
|
||||
#define WAKER_CPU 1
|
||||
|
||||
int sem;
|
||||
pthread_barrier_t bar;
|
||||
int flag;
|
||||
pthread_t thr;
|
||||
long t_futex_wait, t_fwq;
|
||||
long nloop;
|
||||
long blocktime = 10L * 1000 * 1000;
|
||||
int linux_run;
|
||||
|
||||
void *util_fn(void *arg)
|
||||
{
|
||||
int i;
|
||||
int ret;
|
||||
long start, end;
|
||||
int testid = 32101;
|
||||
unsigned long mem;
|
||||
|
||||
print_cpu_last_executed_on("Utility thread");
|
||||
|
||||
if (!linux_run) {
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret == -1, "Utility thread is running on Linux\n");
|
||||
}
|
||||
|
||||
pthread_barrier_wait(&bar);
|
||||
|
||||
for (i = 0; i < nloop; i++) {
|
||||
start = rdtsc_light();
|
||||
|
||||
fwq(blocktime, &mem);
|
||||
|
||||
end = rdtsc_light();
|
||||
t_fwq += end - start;
|
||||
|
||||
sem = i + 1;
|
||||
if ((ret = syscall(__NR_futex, &sem, FUTEX_WAKE, 1,
|
||||
NULL, NULL, 0)) != 1) {
|
||||
printf("Error: futex wake: %d,%d\n", ret, errno);
|
||||
}
|
||||
|
||||
//pthread_barrier_wait(&bar);
|
||||
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
fn_fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct option options[] = {
|
||||
/* end */
|
||||
{ NULL, 0, NULL, 0, }
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int ret;
|
||||
long start, end;
|
||||
cpu_set_t cpuset;
|
||||
pthread_attr_t attr;
|
||||
pthread_barrierattr_t bar_attr;
|
||||
struct sched_param param = { .sched_priority = 99 };
|
||||
int opt;
|
||||
unsigned long mem;
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "+b:l", options, NULL)) != -1) {
|
||||
switch (opt) {
|
||||
case 'b':
|
||||
blocktime = atoi(optarg);
|
||||
break;
|
||||
case 'l':
|
||||
linux_run = 1;
|
||||
break;
|
||||
default: /* '?' */
|
||||
printf("unknown option %c\n", optopt);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
nloop = (10 * 1000000000UL) / blocktime;
|
||||
printf("[INFO] nloop=%ld,blocktime=%ld\n", nloop, blocktime);
|
||||
|
||||
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(WAITER_CPU, &cpuset);
|
||||
if ((ret = sched_setaffinity(0, sizeof(cpu_set_t), &cpuset))) {
|
||||
printf("Error: sched_setaffinity: %s\n", strerror(errno));
|
||||
goto fn_fail;
|
||||
}
|
||||
print_cpu_last_executed_on("Master thread");
|
||||
|
||||
fwq_init(&mem);
|
||||
|
||||
pthread_barrierattr_init(&bar_attr);
|
||||
pthread_barrier_init(&bar, &bar_attr, 2);
|
||||
|
||||
if ((ret = pthread_attr_init(&attr))) {
|
||||
printf("Error: pthread_attr_init: %s\n", strerror(errno));
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(WAKER_CPU, &cpuset);
|
||||
|
||||
if ((ret = pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset))) {
|
||||
printf("Error: pthread_attr_setaffinity_np: %s\n", strerror(errno));
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
if (!linux_run) {
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret != -1, "Master thread is running on McKernel\n");
|
||||
|
||||
ret = syscall(731, 1, NULL);
|
||||
OKNGNOJUMP(ret != -1, "util_indicate_clone\n");
|
||||
}
|
||||
|
||||
if ((ret = pthread_create(&thr, &attr, util_fn, NULL))) {
|
||||
printf("Error: pthread_create: %s\n", strerror(errno));
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
if ((ret = sched_setscheduler(0, SCHED_FIFO, ¶m))) {
|
||||
printf("Warning: sched_setscheduler: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
if (!linux_run) {
|
||||
syscall(701, 1 | 2);
|
||||
}
|
||||
pthread_barrier_wait(&bar);
|
||||
start = rdtsc_light();
|
||||
for (i = 0; i < nloop; i++) {
|
||||
if ((ret = syscall(__NR_futex, &sem, FUTEX_WAIT, i, NULL, NULL, 0))) {
|
||||
printf("Error: futex wait failed (%s)\n", strerror(errno));
|
||||
}
|
||||
|
||||
//pthread_barrier_wait(&bar); /* 2nd futex */
|
||||
}
|
||||
end = rdtsc_light();
|
||||
t_futex_wait += end - start;
|
||||
if (!linux_run) {
|
||||
syscall(701, 4 | 8);
|
||||
}
|
||||
|
||||
pthread_join(thr, NULL);
|
||||
printf("[INFO] waiter: %ld nsec, waker: %ld nsec, (waiter - waker) / nloop: %ld nsec\n", t_futex_wait * 10, t_fwq * 10, (t_futex_wait - t_fwq) * 10 / nloop);
|
||||
|
||||
ret = 0;
|
||||
fn_fail:
|
||||
return ret;
|
||||
}
|
||||
170
test/uti/arm64/CT34.c
Normal file
170
test/uti/arm64/CT34.c
Normal file
@ -0,0 +1,170 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <linux/futex.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdint.h>
|
||||
#include "util.h"
|
||||
|
||||
#define WAITER_CPU 0
|
||||
#define WAKER_CPU 1
|
||||
|
||||
int sem;
|
||||
pthread_barrier_t bar;
|
||||
int flag;
|
||||
pthread_t thr;
|
||||
long t_futex_wait, t_fwq;
|
||||
long nloop;
|
||||
long blocktime = 10L * 1000 * 1000;
|
||||
int linux_run;
|
||||
|
||||
void *util_fn(void *arg)
|
||||
{
|
||||
int i;
|
||||
int ret;
|
||||
long start, end;
|
||||
int testid = 32101;
|
||||
unsigned long mem;
|
||||
|
||||
print_cpu_last_executed_on("Utility thread");
|
||||
|
||||
if (!linux_run) {
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret == -1, "Utility thread is running on Linux\n");
|
||||
}
|
||||
|
||||
pthread_barrier_wait(&bar);
|
||||
start = rdtsc_light();
|
||||
for (i = 0; i < nloop; i++) {
|
||||
|
||||
if ((ret = syscall(__NR_futex, &sem, FUTEX_WAIT, i, NULL, NULL, 0))) {
|
||||
printf("Error: futex wait failed (%s)\n", strerror(errno));
|
||||
}
|
||||
|
||||
//pthread_barrier_wait(&bar); /* 2nd futex */
|
||||
}
|
||||
end = rdtsc_light();
|
||||
t_futex_wait += end - start;
|
||||
|
||||
ret = 0;
|
||||
fn_fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct option options[] = {
|
||||
/* end */
|
||||
{ NULL, 0, NULL, 0, }
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int ret;
|
||||
long start, end;
|
||||
cpu_set_t cpuset;
|
||||
pthread_attr_t attr;
|
||||
pthread_barrierattr_t bar_attr;
|
||||
struct sched_param param = { .sched_priority = 99 };
|
||||
int opt;
|
||||
unsigned long mem;
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "+b:l", options, NULL)) != -1) {
|
||||
switch (opt) {
|
||||
case 'b':
|
||||
blocktime = atoi(optarg);
|
||||
break;
|
||||
case 'l':
|
||||
linux_run = 1;
|
||||
break;
|
||||
default: /* '?' */
|
||||
printf("unknown option %c\n", optopt);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
nloop = (10 * 1000000000UL) / blocktime;
|
||||
printf("[INFO] nloop=%ld,blocktime=%ld\n", nloop, blocktime);
|
||||
|
||||
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(WAKER_CPU, &cpuset);
|
||||
if ((ret = sched_setaffinity(0, sizeof(cpu_set_t), &cpuset))) {
|
||||
printf("Error: sched_setaffinity: %s\n", strerror(errno));
|
||||
goto fn_fail;
|
||||
}
|
||||
print_cpu_last_executed_on("Master thread");
|
||||
|
||||
fwq_init(&mem);
|
||||
|
||||
pthread_barrierattr_init(&bar_attr);
|
||||
pthread_barrier_init(&bar, &bar_attr, 2);
|
||||
|
||||
if ((ret = pthread_attr_init(&attr))) {
|
||||
printf("Error: pthread_attr_init: %s\n", strerror(errno));
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(WAITER_CPU, &cpuset);
|
||||
|
||||
if ((ret = pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset))) {
|
||||
printf("Error: pthread_attr_setaffinity_np: %s\n", strerror(errno));
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
if (!linux_run) {
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret != -1, "Master thread is running on McKernel\n");
|
||||
|
||||
ret = syscall(731, 1, NULL);
|
||||
OKNGNOJUMP(ret != -1, "util_indicate_clone\n");
|
||||
}
|
||||
|
||||
if ((ret = pthread_create(&thr, &attr, util_fn, NULL))) {
|
||||
printf("Error: pthread_create: %s\n", strerror(errno));
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
if ((ret = sched_setscheduler(0, SCHED_FIFO, ¶m))) {
|
||||
printf("Warning: sched_setscheduler: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
if (!linux_run) {
|
||||
syscall(701, 1 | 2);
|
||||
}
|
||||
pthread_barrier_wait(&bar);
|
||||
for (i = 0; i < nloop; i++) {
|
||||
start = rdtsc_light();
|
||||
|
||||
fwq(blocktime, &mem);
|
||||
|
||||
end = rdtsc_light();
|
||||
t_fwq += end - start;
|
||||
|
||||
sem = i + 1;
|
||||
if ((ret = syscall(__NR_futex, &sem, FUTEX_WAKE, 1,
|
||||
NULL, NULL, 0)) != 1) {
|
||||
printf("Error: futex wake: %d, %d\n", ret, errno);
|
||||
}
|
||||
|
||||
//pthread_barrier_wait(&bar);
|
||||
}
|
||||
if (!linux_run) {
|
||||
syscall(701, 4 | 8);
|
||||
}
|
||||
|
||||
pthread_join(thr, NULL);
|
||||
printf("[INFO] waiter: %ld nsec, waker: %ld nsec, (waiter - waker) / nloop: %ld nsec\n", t_futex_wait * 10, t_fwq * 10, (t_futex_wait - t_fwq) * 10 / nloop);
|
||||
|
||||
ret = 0;
|
||||
fn_fail:
|
||||
return ret;
|
||||
}
|
||||
@ -1,6 +1,9 @@
|
||||
# Makefile COPYRIGHT FUJITSU LIMITED 2019
|
||||
CC = gcc
|
||||
LDFLAGS = -Wall -lpthread
|
||||
LDFLAGS = -Wall -lpthread
|
||||
|
||||
CCFLAGS = -g -O0
|
||||
CPPFLAGS =
|
||||
|
||||
SRCS = $(shell ls CT*.c)
|
||||
TARGET = $(SRCS:.c=)
|
||||
@ -10,5 +13,23 @@ all: $(TARGET)
|
||||
test: all
|
||||
./run.sh
|
||||
|
||||
%.o:: %.c
|
||||
$(CC) $(CCFLAGS) $(CPPFLAGS) -c $<
|
||||
|
||||
util.o:: util.c
|
||||
$(CC) $(CCFLAGS) $(CPPFLAGS) -c $<
|
||||
|
||||
CT31: CT31.o util.o
|
||||
$(CC) -o $@ $^ $(LDFLAGS) $(CPPFLAGS)
|
||||
|
||||
CT32: CT32.o util.o
|
||||
$(CC) -o $@ $^ $(LDFLAGS) $(CPPFLAGS)
|
||||
|
||||
CT33: CT33.o util.o
|
||||
$(CC) -o $@ $^ $(LDFLAGS) $(CPPFLAGS)
|
||||
|
||||
CT34: CT34.o util.o
|
||||
$(CC) -o $@ $^ $(LDFLAGS) $(CPPFLAGS)
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET)
|
||||
rm -f $(TARGET) *.o
|
||||
|
||||
122
test/uti/arm64/util.c
Normal file
122
test/uti/arm64/util.c
Normal file
@ -0,0 +1,122 @@
|
||||
#define _GNU_SOURCE /* See feature_test_macros(7) */
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h> /* For SYS_xxx definitions */
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sched.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include "util.h"
|
||||
|
||||
#define TS2NS(sec, nsec) \
|
||||
((unsigned long)(sec) * 1000000000ULL + \
|
||||
(unsigned long)(nsec))
|
||||
|
||||
#define N_INIT 10000000
|
||||
|
||||
static inline void FIXED_SIZE_WORK(unsigned long *ptr)
|
||||
{
|
||||
asm volatile("mov %x0, x20\n"
|
||||
"add x20, x20, #1\n"
|
||||
"mov x20, %x0\n"
|
||||
: "+rm" (*ptr)
|
||||
:
|
||||
: "x20", "cc", "memory");
|
||||
}
|
||||
|
||||
static inline void BULK_FSW(unsigned long n,
|
||||
unsigned long *ptr)
|
||||
{
|
||||
int j;
|
||||
|
||||
for (j = 0; j < (n); j++) {
|
||||
FIXED_SIZE_WORK(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
double nspw; /* nsec per work */
|
||||
unsigned long nsec;
|
||||
|
||||
void fwq_init(unsigned long *mem)
|
||||
{
|
||||
struct timespec start, end;
|
||||
unsigned long nsec;
|
||||
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
|
||||
BULK_FSW(N_INIT, mem);
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end);
|
||||
nsec = (TS2NS(end.tv_sec, end.tv_nsec) -
|
||||
TS2NS(start.tv_sec, start.tv_nsec));
|
||||
nspw = nsec / (double)N_INIT;
|
||||
printf("nsec=%ld, nspw=%f\n", nsec, nspw);
|
||||
}
|
||||
|
||||
void fwq(long delay_nsec, unsigned long *mem)
|
||||
{
|
||||
BULK_FSW(delay_nsec / nspw, mem);
|
||||
}
|
||||
|
||||
int print_cpu_last_executed_on(const char *name) {
|
||||
char fn[256];
|
||||
char* result;
|
||||
pid_t tid = syscall(SYS_gettid);
|
||||
int fd;
|
||||
int offset;
|
||||
int mpi_errno = 0;
|
||||
|
||||
sprintf(fn, "/proc/%d/task/%d/stat", getpid(), (int)tid);
|
||||
//printf("fn=%s\n", fn);
|
||||
fd = open(fn, O_RDONLY);
|
||||
if(fd == -1) {
|
||||
printf("open() failed\n");
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
result = malloc(65536);
|
||||
if(result == NULL) {
|
||||
printf("malloc() failed");
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
int amount = 0;
|
||||
offset = 0;
|
||||
while(1) {
|
||||
amount = read(fd, result + offset, 65536);
|
||||
// printf("amount=%d\n", amount);
|
||||
if(amount == -1) {
|
||||
printf("read() failed");
|
||||
goto fn_fail;
|
||||
}
|
||||
if(amount == 0) {
|
||||
goto eof;
|
||||
}
|
||||
offset += amount;
|
||||
}
|
||||
eof:;
|
||||
//printf("result:%s\n", result);
|
||||
|
||||
char* next_delim = result;
|
||||
char* field;
|
||||
int i;
|
||||
for(i = 0; i < 39; i++) {
|
||||
field = strsep(&next_delim, " ");
|
||||
}
|
||||
|
||||
int cpu = sched_getcpu();
|
||||
if(cpu == -1) {
|
||||
printf("getcpu() failed\n");
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
printf("[INFO] %s (tid: %d) is running on %02d,%02d\n", name, tid, atoi(field), cpu);
|
||||
fn_exit:
|
||||
free(result);
|
||||
return mpi_errno;
|
||||
fn_fail:
|
||||
mpi_errno = -1;
|
||||
goto fn_exit;
|
||||
}
|
||||
|
||||
70
test/uti/arm64/util.h
Normal file
70
test/uti/arm64/util.h
Normal file
@ -0,0 +1,70 @@
|
||||
#ifndef __UTIL_H_INCLUDED__
|
||||
#define __UTIL_H_INCLUDED__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define isb() asm volatile("isb" : : : "memory")
|
||||
|
||||
#define DEBUG
|
||||
|
||||
#ifdef DEBUG
|
||||
#define dprintf(...) do { \
|
||||
char msg[1024]; \
|
||||
sprintf(msg, __VA_ARGS__); \
|
||||
fprintf(stderr, "%s,%s", __func__, msg); \
|
||||
} while (0)
|
||||
#else
|
||||
#define dprintf(...) do { } while (0)
|
||||
#endif
|
||||
|
||||
#define eprintf(...) do { \
|
||||
char msg[1024]; \
|
||||
sprintf(msg, __VA_ARGS__); \
|
||||
fprintf(stderr, "%s,%s", __func__, msg); \
|
||||
} while (0)
|
||||
|
||||
#define CHKANDJUMP(cond, err, ...) do { \
|
||||
if (cond) { \
|
||||
eprintf(__VA_ARGS__); \
|
||||
ret = err; \
|
||||
goto fn_fail; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define _OKNG(verb, jump, cond, fmt, args...) do { \
|
||||
if (cond) { \
|
||||
if (verb) \
|
||||
printf("[ OK ] " fmt, ##args); \
|
||||
} else { \
|
||||
printf("[ NG ] " fmt, ##args); \
|
||||
if (jump) \
|
||||
goto fn_fail; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define OKNG(args...) _OKNG(1, 1, ##args)
|
||||
#define NG(args...) _OKNG(0, 1, ##args)
|
||||
#define OKNGNOJUMP(args...) _OKNG(1, 0, ##args)
|
||||
|
||||
#define DIFFNSEC(end, start) ((end.tv_sec - start.tv_sec) * 1000000000UL + (end.tv_nsec - start.tv_nsec))
|
||||
#define TIMER_KIND CLOCK_MONOTONIC_RAW /* CLOCK_THREAD_CPUTIME_ID */
|
||||
|
||||
static inline uint64_t rdtsc_light(void )
|
||||
{
|
||||
unsigned long cval;
|
||||
|
||||
isb();
|
||||
asm volatile("mrs %0, cntvct_el0" : "=r" (cval));
|
||||
|
||||
return cval;
|
||||
}
|
||||
|
||||
extern double nspw; /* nsec per work */
|
||||
extern unsigned long nsec;
|
||||
|
||||
void fwq_init(unsigned long *mem);
|
||||
void fwq(long delay_nsec, unsigned long *mem);
|
||||
int print_cpu_last_executed_on(const char *name);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user