龙芯 Linux 内核 VDSO 现状测试

http://ask.loongnix.org/?/article/418

 

好久之前记得龙芯上 VDSO 支持很有问题,前一阵终于获得少量空闲时间,又测了一下,发现还是不行,跑这么一个脚本发现大量 clock_gettime 系统调用。(amd64 上除了用于实现 sleep 的 select 之外没有任何 gettimeofday 或者 clock_gettime 的调用。)

#!/usr/bin/env python3

import time

for i in range(100):
    time.sleep(0.01)
    _ = time.time()


翻 glibc 源码时候 git log 看到一个叫 vdsotest 的工具,于是弄下来跑了一遍。
 
测试环境:

  

clock-gettime-monotonic: syscall: 409 nsec/callclock-gettime-monotonic:    libc: 476 nsec/callclock-gettime-monotonic:    vdso: 462 nsec/callNote: vDSO version of clock_getres not foundclock-getres-monotonic: syscall: 323 nsec/callclock-getres-monotonic:    libc: 346 nsec/callclock-getres-monotonic:    vdso: not testedNote: vDSO version of clock_getres not foundNote: vDSO version of clock_getres not foundclock-gettime-monotonic-coarse: syscall: 374 nsec/callclock-gettime-monotonic-coarse:    libc: 115 nsec/callclock-gettime-monotonic-coarse:    vdso: 98 nsec/callpassing UINTPTR_MAX to clock_gettime (VDSO): terminated by unexpected signal 10clock-gettime-monotonic-coarse/abi: 1 failures/inconsistencies encounteredNote: vDSO version of clock_getres not foundclock-getres-monotonic-coarse: syscall: 357 nsec/callclock-getres-monotonic-coarse:    libc: 379 nsec/callclock-getres-monotonic-coarse:    vdso: not testedNote: vDSO version of clock_getres not foundNote: vDSO version of clock_getres not foundclock-gettime-monotonic-raw: syscall: 406 nsec/callclock-gettime-monotonic-raw:    libc: 455 nsec/callclock-gettime-monotonic-raw:    vdso: 425 nsec/callNote: vDSO version of clock_getres not foundclock-getres-monotonic-raw: syscall: 323 nsec/callclock-getres-monotonic-raw:    libc: 346 nsec/callclock-getres-monotonic-raw:    vdso: not testedNote: vDSO version of clock_getres not foundNote: vDSO version of clock_getres not foundclock-gettime-tai: syscall: 422 nsec/callclock-gettime-tai:    libc: 472 nsec/callclock-gettime-tai:    vdso: 449 nsec/callNote: vDSO version of clock_getres not foundclock-getres-tai: syscall: 323 nsec/callclock-getres-tai:    libc: 345 nsec/callclock-getres-tai:    vdso: not testedNote: vDSO version of clock_getres not foundNote: vDSO version of clock_getres not foundclock-gettime-boottime: syscall: 421 nsec/callclock-gettime-boottime:    libc: 471 nsec/callclock-gettime-boottime:    vdso: 450 nsec/callNote: vDSO version of clock_getres not foundclock-getres-boottime: syscall: 324 nsec/callclock-getres-boottime:    libc: 346 nsec/callclock-getres-boottime:    vdso: not testedNote: vDSO version of clock_getres not foundNote: vDSO version of clock_getres not foundclock-gettime-realtime: syscall: 405 nsec/callclock-gettime-realtime:    libc: 474 nsec/callclock-gettime-realtime:    vdso: 457 nsec/callNote: vDSO version of clock_getres not foundclock-getres-realtime: syscall: 323 nsec/callclock-getres-realtime:    libc: 348 nsec/callclock-getres-realtime:    vdso: not testedNote: vDSO version of clock_getres not foundNote: vDSO version of clock_getres not foundclock-gettime-realtime-coarse: syscall: 367 nsec/callclock-gettime-realtime-coarse:    libc: 114 nsec/callclock-gettime-realtime-coarse:    vdso: 97 nsec/callpassing UINTPTR_MAX to clock_gettime (VDSO): terminated by unexpected signal 10clock-gettime-realtime-coarse/abi: 1 failures/inconsistencies encounteredNote: vDSO version of clock_getres not foundclock-getres-realtime-coarse: syscall: 357 nsec/callclock-getres-realtime-coarse:    libc: 379 nsec/callclock-getres-realtime-coarse:    vdso: not testedNote: vDSO version of clock_getres not foundNote: vDSO version of clock_getres not foundNote: vDSO version of getcpu not foundgetcpu: syscall: 274 nsec/callgetcpu:    libc: 287 nsec/callgetcpu:    vdso: not testedNote: vDSO version of getcpu not foundNote: vDSO version of getcpu not foundgettimeofday: syscall: 406 nsec/callgettimeofday:    libc: 455 nsec/callgettimeofday:    vdso: 440 nsec/callgettimeofday(valid, UINTPTR_MAX) (VDSO): unexpected return value -14, expected -1gettimeofday(valid, UINTPTR_MAX) (VDSO): exited with status 1, expected 0gettimeofday(valid, page (PROT_NONE)) (VDSO): unexpected return value -14, expected -1gettimeofday(valid, page (PROT_NONE)) (VDSO): exited with status 1, expected 0gettimeofday(valid, page (PROT_READ)) (VDSO): unexpected return value -14, expected -1gettimeofday(valid, page (PROT_READ)) (VDSO): exited with status 1, expected 0gettimeofday(NULL, UINTPTR_MAX) (VDSO): unexpected return value -14, expected -1gettimeofday(NULL, UINTPTR_MAX) (VDSO): exited with status 1, expected 0gettimeofday(NULL, page (PROT_NONE)) (VDSO): unexpected return value -14, expected -1gettimeofday(NULL, page (PROT_NONE)) (VDSO): exited with status 1, expected 0gettimeofday(NULL, page (PROT_READ)) (VDSO): unexpected return value -14, expected -1gettimeofday(NULL, page (PROT_READ)) (VDSO): exited with status 1, expected 0gettimeofday(UINTPTR_MAX, valid) (VDSO): unexpected return value -14, expected -1gettimeofday(UINTPTR_MAX, valid) (VDSO): exited with status 1, expected 0gettimeofday(UINTPTR_MAX, NULL) (VDSO): unexpected return value -14, expected -1gettimeofday(UINTPTR_MAX, NULL) (VDSO): exited with status 1, expected 0gettimeofday(UINTPTR_MAX, UINTPTR_MAX) (VDSO): unexpected return value -14, expected -1gettimeofday(UINTPTR_MAX, UINTPTR_MAX) (VDSO): exited with status 1, expected 0gettimeofday(UINTPTR_MAX, page (PROT_NONE)) (VDSO): unexpected return value -14, expected -1gettimeofday(UINTPTR_MAX, page (PROT_NONE)) (VDSO): exited with status 1, expected 0Failure threshold (10) reached; stopping test.gettimeofday(UINTPTR_MAX, page (PROT_READ)) (VDSO): unexpected return value -14, expected -1gettimeofday(UINTPTR_MAX, page (PROT_READ)) (VDSO): exited with status 1, expected 0Failure threshold (10) reached; stopping test.gettimeofday(page (PROT_NONE), valid) (VDSO): unexpected return value -14, expected -1gettimeofday(page (PROT_NONE), valid) (VDSO): exited with status 1, expected 0Failure threshold (10) reached; stopping test.gettimeofday(page (PROT_NONE), NULL) (VDSO): unexpected return value -14, expected -1gettimeofday(page (PROT_NONE), NULL) (VDSO): exited with status 1, expected 0Failure threshold (10) reached; stopping test.gettimeofday(page (PROT_NONE), UINTPTR_MAX) (VDSO): unexpected return value -14, expected -1gettimeofday(page (PROT_NONE), UINTPTR_MAX) (VDSO): exited with status 1, expected 0Failure threshold (10) reached; stopping test.gettimeofday(page (PROT_NONE), page (PROT_NONE)) (VDSO): unexpected return value -14, expected -1gettimeofday(page (PROT_NONE), page (PROT_NONE)) (VDSO): exited with status 1, expected 0Failure threshold (10) reached; stopping test.gettimeofday(page (PROT_NONE), page (PROT_READ)) (VDSO): unexpected return value -14, expected -1gettimeofday(page (PROT_NONE), page (PROT_READ)) (VDSO): exited with status 1, expected 0Failure threshold (10) reached; stopping test.gettimeofday(page (PROT_READ), valid) (VDSO): unexpected return value -14, expected -1gettimeofday(page (PROT_READ), valid) (VDSO): exited with status 1, expected 0Failure threshold (10) reached; stopping test.gettimeofday(page (PROT_READ), NULL) (VDSO): unexpected return value -14, expected -1gettimeofday(page (PROT_READ), NULL) (VDSO): exited with status 1, expected 0Failure threshold (10) reached; stopping test.gettimeofday(page (PROT_READ), UINTPTR_MAX) (VDSO): unexpected return value -14, expected -1gettimeofday(page (PROT_READ), UINTPTR_MAX) (VDSO): exited with status 1, expected 0Failure threshold (10) reached; stopping test.gettimeofday(page (PROT_READ), page (PROT_NONE)) (VDSO): unexpected return value -14, expected -1gettimeofday(page (PROT_READ), page (PROT_NONE)) (VDSO): exited with status 1, expected 0Failure threshold (10) reached; stopping test.gettimeofday(page (PROT_READ), page (PROT_READ)) (VDSO): unexpected return value -14, expected -1gettimeofday(page (PROT_READ), page (PROT_READ)) (VDSO): exited with status 1, expected 0Failure threshold (10) reached; stopping test.gettimeofday/abi: 21 failures/inconsistencies encountered

  这个结果显然有改进空间,主要是 clock_gettime 系统调用在各种程序里用得还是不少的,要求实时性的应用,如音视频应用,使用更多。让获取时间操作开销尽量减少,对系统交互体验一定有所帮助。  2019.01.15 编辑:新增我 MBP 上 Docker for Mac(Linux 虚拟机)以及我一台服务器上的测量结果。  实验表明 amd64 架构的裸金属上,以下这几项的 VDSO 调用是有优化的:

  • clock-gettime-monotonic (约 30ns)
  • clock-gettime-monotonic-coarse (<10ns)
  • clock-gettime-realtime (约 30ns)
  • clock-gettime-realtime-coarse (<10ns)
  • getcpu (约 10ns)
  • gettimeofday (约 30ns)

 
这台机器的 CPU 是 Xeon X3323,标称频率 2.5GHz,可供参考。个人感觉龙芯优化上来了应该完全没问题。
 
MBP Docker for Mac 容器(随便用了个 golang:latest,Debian Stretch):

clock-gettime-monotonic: syscall: 3222 nsec/call
clock-gettime-monotonic:    libc: 3234 nsec/call
clock-gettime-monotonic:    vdso: 3246 nsec/call
Note: vDSO version of clock_getres not found
clock-getres-monotonic: syscall: 282 nsec/call
clock-getres-monotonic:    libc: 286 nsec/call
clock-getres-monotonic:    vdso: not tested
Note: vDSO version of clock_getres not found
Note: vDSO version of clock_getres not found
clock-gettime-monotonic-coarse: syscall: 288 nsec/call
clock-gettime-monotonic-coarse:    libc: 4 nsec/call
clock-gettime-monotonic-coarse:    vdso: 3 nsec/call
Note: vDSO version of clock_getres not found
clock-getres-monotonic-coarse: syscall: 293 nsec/call
clock-getres-monotonic-coarse:    libc: 293 nsec/call
clock-getres-monotonic-coarse:    vdso: not tested
Note: vDSO version of clock_getres not found
Note: vDSO version of clock_getres not found
clock-gettime-monotonic-raw: syscall: 3229 nsec/call
clock-gettime-monotonic-raw:    libc: 3263 nsec/call
clock-gettime-monotonic-raw:    vdso: 3203 nsec/call
Note: vDSO version of clock_getres not found
clock-getres-monotonic-raw: syscall: 282 nsec/call
clock-getres-monotonic-raw:    libc: 282 nsec/call
clock-getres-monotonic-raw:    vdso: not tested
Note: vDSO version of clock_getres not found
Note: vDSO version of clock_getres not found
clock-gettime-tai: syscall: 3209 nsec/call
clock-gettime-tai:    libc: 3246 nsec/call
clock-gettime-tai:    vdso: 3233 nsec/call
Note: vDSO version of clock_getres not found
clock-getres-tai: syscall: 278 nsec/call
clock-getres-tai:    libc: 279 nsec/call
clock-getres-tai:    vdso: not tested
Note: vDSO version of clock_getres not found
Note: vDSO version of clock_getres not found
clock-gettime-boottime: syscall: 3245 nsec/call
clock-gettime-boottime:    libc: 3219 nsec/call
clock-gettime-boottime:    vdso: 3275 nsec/call
Note: vDSO version of clock_getres not found
clock-getres-boottime: syscall: 276 nsec/call
clock-getres-boottime:    libc: 281 nsec/call
clock-getres-boottime:    vdso: not tested
Note: vDSO version of clock_getres not found
Note: vDSO version of clock_getres not found
clock-gettime-realtime: syscall: 3222 nsec/call
clock-gettime-realtime:    libc: 3250 nsec/call
clock-gettime-realtime:    vdso: 3216 nsec/call
Note: vDSO version of clock_getres not found
clock-getres-realtime: syscall: 282 nsec/call
clock-getres-realtime:    libc: 283 nsec/call
clock-getres-realtime:    vdso: not tested
Note: vDSO version of clock_getres not found
Note: vDSO version of clock_getres not found
clock-gettime-realtime-coarse: syscall: 288 nsec/call
clock-gettime-realtime-coarse:    libc: 4 nsec/call
clock-gettime-realtime-coarse:    vdso: 3 nsec/call
Note: vDSO version of clock_getres not found
clock-getres-realtime-coarse: syscall: 290 nsec/call
clock-getres-realtime-coarse:    libc: 291 nsec/call
clock-getres-realtime-coarse:    vdso: not tested
Note: vDSO version of clock_getres not found
Note: vDSO version of clock_getres not found
getcpu: syscall: 277 nsec/call
getcpu:    libc: 11 nsec/call
getcpu:    vdso: 9 nsec/call
gettimeofday: syscall: 3184 nsec/call
gettimeofday:    libc: 3217 nsec/call
gettimeofday:    vdso: 3222 nsec/call
gettimeofday(valid, UINTPTR_MAX) (VDSO): unexpected return value -14, expected -1
gettimeofday(valid, UINTPTR_MAX) (VDSO): exited with status 1, expected 0
gettimeofday(valid, page (PROT_NONE)) (VDSO): unexpected return value -14, expected -1
gettimeofday(valid, page (PROT_NONE)) (VDSO): exited with status 1, expected 0
gettimeofday(valid, page (PROT_READ)) (VDSO): unexpected return value -14, expected -1
gettimeofday(valid, page (PROT_READ)) (VDSO): exited with status 1, expected 0
gettimeofday/abi: 3 failures/inconsistencies encountered


# uname -a
Linux 3054d8c1d709 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018 x86_64 GNU/Linux




我的一台服务器:

clock-gettime-monotonic: syscall: 574 nsec/call
clock-gettime-monotonic:    libc: 34 nsec/call
clock-gettime-monotonic:    vdso: 32 nsec/call
Note: vDSO version of clock_getres not found
clock-getres-monotonic: syscall: 524 nsec/call
clock-getres-monotonic:    libc: 523 nsec/call
clock-getres-monotonic:    vdso: not tested
Note: vDSO version of clock_getres not found
Note: vDSO version of clock_getres not found
clock-gettime-monotonic-coarse: syscall: 541 nsec/call
clock-gettime-monotonic-coarse:    libc: 9 nsec/call
clock-gettime-monotonic-coarse:    vdso: 7 nsec/call
Note: vDSO version of clock_getres not found
clock-getres-monotonic-coarse: syscall: 529 nsec/call
clock-getres-monotonic-coarse:    libc: 527 nsec/call
clock-getres-monotonic-coarse:    vdso: not tested
Note: vDSO version of clock_getres not found
Note: vDSO version of clock_getres not found
clock-gettime-monotonic-raw: syscall: 570 nsec/call
clock-gettime-monotonic-raw:    libc: 579 nsec/call
clock-gettime-monotonic-raw:    vdso: 564 nsec/call
Note: vDSO version of clock_getres not found
clock-getres-monotonic-raw: syscall: 520 nsec/call
clock-getres-monotonic-raw:    libc: 519 nsec/call
clock-getres-monotonic-raw:    vdso: not tested
Note: vDSO version of clock_getres not found
Note: vDSO version of clock_getres not found
clock-gettime-tai: syscall: 592 nsec/call
clock-gettime-tai:    libc: 602 nsec/call
clock-gettime-tai:    vdso: 587 nsec/call
Note: vDSO version of clock_getres not found
clock-getres-tai: syscall: 521 nsec/call
clock-getres-tai:    libc: 519 nsec/call
clock-getres-tai:    vdso: not tested
Note: vDSO version of clock_getres not found
Note: vDSO version of clock_getres not found
clock-gettime-boottime: syscall: 582 nsec/call
clock-gettime-boottime:    libc: 588 nsec/call
clock-gettime-boottime:    vdso: 585 nsec/call
Note: vDSO version of clock_getres not found
clock-getres-boottime: syscall: 520 nsec/call
clock-getres-boottime:    libc: 518 nsec/call
clock-getres-boottime:    vdso: not tested
Note: vDSO version of clock_getres not found
Note: vDSO version of clock_getres not found
clock-gettime-realtime: syscall: 584 nsec/call
clock-gettime-realtime:    libc: 34 nsec/call
clock-gettime-realtime:    vdso: 33 nsec/call
Note: vDSO version of clock_getres not found
clock-getres-realtime: syscall: 525 nsec/call
clock-getres-realtime:    libc: 525 nsec/call
clock-getres-realtime:    vdso: not tested
Note: vDSO version of clock_getres not found
Note: vDSO version of clock_getres not found
clock-gettime-realtime-coarse: syscall: 532 nsec/call
clock-gettime-realtime-coarse:    libc: 9 nsec/call
clock-gettime-realtime-coarse:    vdso: 7 nsec/call
Note: vDSO version of clock_getres not found
clock-getres-realtime-coarse: syscall: 531 nsec/call
clock-getres-realtime-coarse:    libc: 528 nsec/call
clock-getres-realtime-coarse:    vdso: not tested
Note: vDSO version of clock_getres not found
Note: vDSO version of clock_getres not found
getcpu: syscall: 455 nsec/call
getcpu:    libc: 17 nsec/call
getcpu:    vdso: 14 nsec/call
gettimeofday: syscall: 563 nsec/call
gettimeofday:    libc: 34 nsec/call
gettimeofday:    vdso: 34 nsec/call

$ uname -srvmpio
Linux 4.15.0-39-generic #42~16.04.1-Ubuntu SMP Wed Oct 24 17:09:54 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

1.png

附:龙芯Intellij IDEA开发Spring web应用视频 

http://tieba.baidu.com/p/5975179608

猜你喜欢

转载自blog.csdn.net/weixin_40065369/article/details/86561032