Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: --cpuclock-test fails on HP workstation with 32 cores (2 socket) #479

Closed
bcran opened this issue Oct 14, 2017 · 15 comments
Closed

Comments

@bcran
Copy link
Contributor

bcran commented Oct 14, 2017

On my HP Z820 workstation, FIO 3.0 running on Windows fails the cpuclock-test, reporting:

...
cs: CPU clock mismatch (diff=2):
         CPU 14: TSC=692869176424707, SEQ=8312573
         CPU 15: TSC=692869176424705, SEQ=8312574
cs: CPU clock mismatch (diff=2):
         CPU 14: TSC=692869176425439, SEQ=8312589
         CPU 15: TSC=692869176425437, SEQ=8312590
cs: CPU clock mismatch (diff=5):
         CPU 14: TSC=692869176573058, SEQ=8314218
         CPU 15: TSC=692869176573053, SEQ=8314219
cs: CPU clock mismatch (diff=5):
         CPU 14: TSC=692869176702281, SEQ=8315615
         CPU 15: TSC=692869176702276, SEQ=8315616
cs: CPU clock mismatch (diff=5):
         CPU 14: TSC=692869176702833, SEQ=8315631
         CPU 15: TSC=692869176702828, SEQ=8315632
cs: CPU clock mismatch (diff=2):
         CPU 14: TSC=692869176703270, SEQ=8315643
         CPU 15: TSC=692869176703268, SEQ=8315644
cs: CPU clock mismatch (diff=2):
         CPU 14: TSC=692869176703568, SEQ=8315651
         CPU 15: TSC=692869176703566, SEQ=8315652
cs: CPU clock mismatch (diff=2):
         CPU 14: TSC=692869176832103, SEQ=8317036
         CPU 15: TSC=692869176832101, SEQ=8317037
cs: CPU clock mismatch (diff=5):
         CPU 14: TSC=692869176976504, SEQ=8318620
         CPU 15: TSC=692869176976499, SEQ=8318621
cs: CPU clock mismatch (diff=5):
         CPU 14: TSC=692869176976740, SEQ=8318626
         CPU 15: TSC=692869176976735, SEQ=8318627
cs: CPU clock mismatch (diff=5):
         CPU 14: TSC=692869177078556, SEQ=8319747
         CPU 15: TSC=692869177078551, SEQ=8319748
cs: Failed: 25318
@sitsofe
Copy link
Collaborator

sitsofe commented Oct 14, 2017

@bcran Do you have hyperthreading turned on?

@bcran
Copy link
Contributor Author

bcran commented Oct 14, 2017

@sitsofe Yes, I do. The CPU configuration is:

	Number of cores		8 (max 8)
	Number of threads	16 (max 16)
	Name			Intel Xeon E5 2687W
	Codename		Sandy Bridge-EP/EX
	Specification		Intel(R) Xeon(R) CPU E5-2687W 0 @ 3.10GHz
	Package (platform ID)	Socket 2011 LGA (0x0)
	CPUID			6.D.7
	Extended CPUID		6.2D
	Core Stepping		C2
	Technology		32 nm
	TDP Limit		150.0 Watts
	Tjmax			92.0 °C
	Core Speed		3490.4 MHz
	Multiplier x Bus Speed	35.0 x 99.7 MHz
	Rated Bus speed		3989.0 MHz
	Stock frequency		3100 MHz
	Instructions sets	MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, EM64T, VT-x, AES, AVX
	L1 Data cache		8 x 32 KBytes, 8-way set associative, 64-byte line size
	L1 Instruction cache	8 x 32 KBytes, 8-way set associative, 64-byte line size
	L2 cache		8 x 256 KBytes, 8-way set associative, 64-byte line size
	L3 cache		20 MBytes, 20-way set associative, 64-byte line size
	Max CPUID level		0000000Dh
	Max CPUID ext. level	80000008h
	Cache descriptor	Level 1, D, 32 KB, 2 thread(s)
	Cache descriptor	Level 1, I, 32 KB, 2 thread(s)
	Cache descriptor	Level 2, U, 256 KB, 2 thread(s)
	Cache descriptor	Level 3, U, 20 MB, 32 thread(s)
	FID/VID Control		yes

@sitsofe
Copy link
Collaborator

sitsofe commented Oct 14, 2017

Can you include the first few lines of cpuclock-test that talk about whether reliable_tsc is yes or no?

@bcran
Copy link
Contributor Author

bcran commented Oct 15, 2017

cs: reliable_tsc: yes
...
cs: Testing 32 CPUs
cs: cpu 30: 482045631 clocks seen, first 781860601663043
cs: cpu 25: 517951112 clocks seen, first 781860600429191
cs: cpu 24: 527388014 clocks seen, first 781860600260528
cs: cpu 21: 561430587 clocks seen, first 781860599799415
cs: cpu 26: 566856836 clocks seen, first 781860600566208
cs: cpu 27: 567955476 clocks seen, first 781860600764701
cs: cpu 29: 570438854 clocks seen, first 781860601223275
cs: cpu 28: 571304911 clocks seen, first 781860600892701
cs: cpu 20: 590085230 clocks seen, first 781860599597046
cs: cpu 31: 470144099 clocks seen, first 781860721893516
cs: cpu 17: 595590266 clocks seen, first 781860599016974
cs: cpu 19: 595545700 clocks seen, first 781860599427562
cs: cpu 18: 596322495 clocks seen, first 781860599213531
cs: cpu 16: 598410097 clocks seen, first 781860598765454
cs: cpu 23: 597406890 clocks seen, first 781860600107847
cs: cpu 22: 597636219 clocks seen, first 781860599928106
cs: cpu 11: 867388125 clocks seen, first 781860597183359
cs: cpu 13: 876457987 clocks seen, first 781860597615213
cs: cpu 10: 881324131 clocks seen, first 781860596858673
cs: cpu 15: 890661688 clocks seen, first 781860598594096
cs: cpu 12: 895911169 clocks seen, first 781860597384801
cs: cpu 14: 907898243 clocks seen, first 781860598006249
cs: cpu  3: 937044907 clocks seen, first 781860593099862
cs: cpu  2: 939007077 clocks seen, first 781860592725417
cs: cpu  1: 940324144 clocks seen, first 781860592116906
cs: cpu  0: 945839445 clocks seen, first 781860591614617
cs: cpu  4: 946174362 clocks seen, first 781860593499790
cs: cpu  5: 945259406 clocks seen, first 781860594496926
cs: cpu  7: 945756981 clocks seen, first 781860595489191
cs: cpu  6: 947376861 clocks seen, first 781860595066787
cs: cpu  8: 946507278 clocks seen, first 781860595972986
cs: cpu  9: 946232944 clocks seen, first 781860596380291
cs: CPU clock mismatch (diff=4):
         CPU 16: TSC=781860599035112, SEQ=89366
         CPU 17: TSC=781860599035108, SEQ=89367
cs: CPU clock mismatch (diff=7):
         CPU 16: TSC=781860599063142, SEQ=89556
         CPU 17: TSC=781860599063135, SEQ=89557
cs: CPU clock mismatch (diff=1):
         CPU 16: TSC=781860599071264, SEQ=89608
         CPU 17: TSC=781860599071263, SEQ=89609
cs: CPU clock mismatch (diff=4):
         CPU 16: TSC=781860599092350, SEQ=89752
         CPU 17: TSC=781860599092346, SEQ=89753
...

@bcran
Copy link
Contributor Author

bcran commented Oct 15, 2017

Disabling hyperthreading causes it to pass most times, but it still occasionally fails (twice in twenty runs just now).

@bcran
Copy link
Contributor Author

bcran commented Oct 15, 2017

I've also run fio-3.0 on the same hardware under Linux (openSUSE). In that environment, it passes every time.

@sitsofe
Copy link
Collaborator

sitsofe commented Oct 15, 2017

I'm starting to wonder if it's got something to do with the number of CPUs being used and the scheduling order created by the OS' scheduler. Across multiple runs do you find it is always the same CPUs (e.g. CPU 16/CPU 17) that the failure is reported on?

sitsofe added a commit to sitsofe/fio that referenced this issue Oct 15, 2017
fio on Windows with a large number of CPUs/cores frequently fails while running

./fio --cpuclock-test

even though "reliable_tsc: yes" is reported. Using clang's thread sanitizer via

CC=clang ./configure --extra-cflags="-fsanitize=thread"

and running the same on Linux also generates multiple warnings similar to the
following on a VM with 16 cores:

WARNING: ThreadSanitizer: data race (pid=23780)
  Atomic write of size 4 at 0x7ffecb865a3c by thread T15 (mutexes: write M169):
    #0 __tsan_atomic32_fetch_add /home/clang-3.9/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:591 (fio+0x000000471505)
    axboe#1 atomic32_inc_return /home/fio/gettime.c:567:13 (fio+0x0000004c56c1)
    axboe#2 clock_thread_fn /home/fio/gettime.c:607 (fio+0x0000004c56c1)

  Previous read of size 4 at 0x7ffecb865a3c by thread T4 (mutexes: write M147):
    #0 clock_thread_fn /home/fio/gettime.c:611:19 (fio+0x0000004c56e2)

  Location is stack of main thread.

  Mutex M169 (0x7d700000f6a0) created at:
    #0 pthread_mutex_init /home/clang-3.9/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:1119 (fio+0x00000043b695)
    axboe#1 fio_monotonic_clocktest /home/fio/gettime.c:694:3 (fio+0x0000004c4c12)
    axboe#2 parse_cmd_line /home/fio/init.c:2710:15 (fio+0x0000004ce8e5)
    axboe#3 parse_options /home/fio/init.c:2828:14 (fio+0x0000004cf3da)
    axboe#4 main /home/fio/fio.c:47:6 (fio+0x00000054b991)

  Mutex M147 (0x7d700000f178) created at:
    #0 pthread_mutex_init /home/clang-3.9/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:1119 (fio+0x00000043b695)
    axboe#1 fio_monotonic_clocktest /home/fio/gettime.c:694:3 (fio+0x0000004c4c12)
    axboe#2 parse_cmd_line /home/fio/init.c:2710:15 (fio+0x0000004ce8e5)
    axboe#3 parse_options /home/fio/init.c:2828:14 (fio+0x0000004cf3da)
    axboe#4 main /home/fio/fio.c:47:6 (fio+0x00000054b991)

  Thread T15 (tid=23796, running) created by main thread at:
    #0 pthread_create /home/clang-3.9/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:902 (fio+0x00000042c9a6)
    axboe#1 fio_monotonic_clocktest /home/fio/gettime.c:697:7 (fio+0x0000004c4c38)
    axboe#2 parse_cmd_line /home/fio/init.c:2710:15 (fio+0x0000004ce8e5)
    axboe#3 parse_options /home/fio/init.c:2828:14 (fio+0x0000004cf3da)
    axboe#4 main /home/fio/fio.c:47:6 (fio+0x00000054b991)

  Thread T4 (tid=23785, finished) created by main thread at:
    #0 pthread_create /home/clang-3.9/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:902 (fio+0x00000042c9a6)
    axboe#1 fio_monotonic_clocktest /home/fio/gettime.c:697:7 (fio+0x0000004c4c38)
    axboe#2 parse_cmd_line /home/fio/init.c:2710:15 (fio+0x0000004ce8e5)
    axboe#3 parse_options /home/fio/init.c:2828:14 (fio+0x0000004cf3da)
    axboe#4 main /home/fio/fio.c:47:6 (fio+0x00000054b991)

SUMMARY: ThreadSanitizer: data race /home/fio/gettime.c:567:13 in atomic32_inc_return

Avoid accessing t->seq directly and use __sync_val_compare_and_swap to
get at it. This shuts up the sanitizer, makes the test work on Windows
and hopefully means the appropriate memory fencing will be in place
preventing unwanted compiler or CPU reordering.

Fixes: axboe#479

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
@sitsofe
Copy link
Collaborator

sitsofe commented Oct 15, 2017

@bcran could you see if https://github.com/sitsofe/fio/tree/cycletest is any good for you? If so I'll open a pull request.

@sitsofe
Copy link
Collaborator

sitsofe commented Oct 15, 2017

Note that the branch changes the logic associated with seq wraparound - it could be I've misinterpreted how to cope with that...

@bcran
Copy link
Contributor Author

bcran commented Oct 16, 2017

That branch does seem to fix the problem - I saw no failures on over 25 runs.
Thanks!

@sitsofe
Copy link
Collaborator

sitsofe commented Oct 16, 2017

Frustratingly the branch doesn't seem to fix the problem, only make it less frequent. Using the following shows the problem is still there (but it can take over 30 iterations before the problem appears):

cls; $c=0; $LASTEXITCODE=0; while ($LASTEXITCODE -eq 0) { fio.exe --cpuclock-test; $c+=1 }; write-host $c

@axboe
Copy link
Owner

axboe commented Oct 17, 2017

Looks to me like all that's missing is actually a memory syncronization at the end of the while loop. But I think the compare-and-exchange is a better approach, so we should switch to that.

Can both of you try my cpuclock-test branch? It's just this single patch on top of master:

http://git.kernel.dk/cgit/fio/commit/?h=cpuclock-test&id=a250edd0678ac6aef34bfbd01423a7b87a1d5f8d

I've tested it on my laptop, test box, and two development skylake boxes. Don't see any failures, but on the other hand, neither of them had any failures with the existing code... So that may not mean a lot.

@sitsofe
Copy link
Collaborator

sitsofe commented Oct 17, 2017

@axboe Kudos to you Jens - your solution is both faster AND more correct than my attempts. I'm above 600 runs and no problems reported.

@axboe
Copy link
Owner

axboe commented Oct 17, 2017

Thanks for testing! I'm going to pull this in.

@bcran
Copy link
Contributor Author

bcran commented Oct 17, 2017

Work here too. Thanks!

@bcran bcran closed this as completed Oct 17, 2017
sitsofe added a commit to sitsofe/fio that referenced this issue Oct 17, 2017
fio on Windows with a 16 or 32 CPUs frequently fails while running

./fio --cpuclock-test

even though "reliable_tsc: yes" is reported. Using clang's thread sanitizer via

CC=clang ./configure --extra-cflags="-fsanitize=thread"

and running the same on Linux also generates multiple warnings similar to the
following on a VM with 16 cores:

WARNING: ThreadSanitizer: data race (pid=23780)
  Atomic write of size 4 at 0x7ffecb865a3c by thread T15 (mutexes: write M169):
    #0 __tsan_atomic32_fetch_add /home/clang-3.9/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc:591 (fio+0x000000471505)
    axboe#1 atomic32_inc_return /home/fio/gettime.c:567:13 (fio+0x0000004c56c1)
    axboe#2 clock_thread_fn /home/fio/gettime.c:607 (fio+0x0000004c56c1)

  Previous read of size 4 at 0x7ffecb865a3c by thread T4 (mutexes: write M147):
    #0 clock_thread_fn /home/fio/gettime.c:611:19 (fio+0x0000004c56e2)

  Location is stack of main thread.

  Mutex M169 (0x7d700000f6a0) created at:
    #0 pthread_mutex_init /home/clang-3.9/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:1119 (fio+0x00000043b695)
    axboe#1 fio_monotonic_clocktest /home/fio/gettime.c:694:3 (fio+0x0000004c4c12)
    axboe#2 parse_cmd_line /home/fio/init.c:2710:15 (fio+0x0000004ce8e5)
    axboe#3 parse_options /home/fio/init.c:2828:14 (fio+0x0000004cf3da)
    axboe#4 main /home/fio/fio.c:47:6 (fio+0x00000054b991)

  Mutex M147 (0x7d700000f178) created at:
    #0 pthread_mutex_init /home/clang-3.9/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:1119 (fio+0x00000043b695)
    axboe#1 fio_monotonic_clocktest /home/fio/gettime.c:694:3 (fio+0x0000004c4c12)
    axboe#2 parse_cmd_line /home/fio/init.c:2710:15 (fio+0x0000004ce8e5)
    axboe#3 parse_options /home/fio/init.c:2828:14 (fio+0x0000004cf3da)
    axboe#4 main /home/fio/fio.c:47:6 (fio+0x00000054b991)

  Thread T15 (tid=23796, running) created by main thread at:
    #0 pthread_create /home/clang-3.9/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:902 (fio+0x00000042c9a6)
    axboe#1 fio_monotonic_clocktest /home/fio/gettime.c:697:7 (fio+0x0000004c4c38)
    axboe#2 parse_cmd_line /home/fio/init.c:2710:15 (fio+0x0000004ce8e5)
    axboe#3 parse_options /home/fio/init.c:2828:14 (fio+0x0000004cf3da)
    axboe#4 main /home/fio/fio.c:47:6 (fio+0x00000054b991)

  Thread T4 (tid=23785, finished) created by main thread at:
    #0 pthread_create /home/clang-3.9/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:902 (fio+0x00000042c9a6)
    axboe#1 fio_monotonic_clocktest /home/fio/gettime.c:697:7 (fio+0x0000004c4c38)
    axboe#2 parse_cmd_line /home/fio/init.c:2710:15 (fio+0x0000004ce8e5)
    axboe#3 parse_options /home/fio/init.c:2828:14 (fio+0x0000004cf3da)
    axboe#4 main /home/fio/fio.c:47:6 (fio+0x00000054b991)

SUMMARY: ThreadSanitizer: data race /home/fio/gettime.c:567:13 in atomic32_inc_return

Fix the above by doing the following:

- Add a configure check for __sync_val_compare_and_swap and add a helper
  atomic32_cas_return that uses it.
- Add comments noting that the atomic32_* functions act as full
  barriers.
- Don't access t->seq directly when protecting a critical region and
  instead use the atomic32_* helpers to update/read it.

The above fixes the sanitizer warnings and makes the test pass on
Windows.

Fixes: axboe#479

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
sitsofe referenced this issue in sitsofe/fio Mar 7, 2018
Compiling with
CC=clang ./configure --extra-cflags='-fsanitize=thread'
make
and then running
./fio --cpuclock-test
generates warnings like

WARNING: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) (pid=324)
    #0 pthread_mutex_unlock <null> (fio+0x44ce3e)
    axboe#1 clock_thread_fn gettime.c:604:2 (fio+0x4d16c6)

  Location is heap block of size 480 at 0x7b5000000000 allocated by main thread:
    #0 malloc <null> (fio+0x42ea4b)
    axboe#1 fio_monotonic_clocktest gettime.c:690:13 (fio+0x4d0b1a)
    axboe#2 parse_cmd_line init.c:2792:15 (fio+0x4dad0b)
    axboe#3 parse_options init.c:2920:14 (fio+0x4db7b7)
    axboe#4 main fio.c:47 (fio+0x4247fa)

  Mutex M142 (0x7b5000000038) created at:
    #0 pthread_mutex_init <null> (fio+0x42f6ba)
    axboe#1 fio_monotonic_clocktest gettime.c:706:3 (fio+0x4d0c03)
    axboe#2 parse_cmd_line init.c:2792:15 (fio+0x4dad0b)
    axboe#3 parse_options init.c:2920:14 (fio+0x4db7b7)
    axboe#4 main fio.c:47 (fio+0x4247fa)

SUMMARY: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) (fio+0x44ce3e) in __interceptor_pthread_mutex_unlock

valgrind --tool=helgrind ./fio --cpuclock-test
shows a similar warning:

==6607== Thread axboe#3 unlocked lock at 0x639A730 currently held by thread axboe#1
==6607==    at 0x4C3233B: mutex_unlock_WRK (hg_intercepts.c:1094)
==6607==    by 0x4C35CE7: pthread_mutex_unlock (hg_intercepts.c:1115)
==6607==    by 0x41B872: clock_thread_fn (gettime.c:604)
==6607==    by 0x4C349E1: mythread_wrapper (hg_intercepts.c:389)
==6607==    by 0x59A836C: start_thread (in /usr/lib64/libpthread-2.25.so)
==6607==    by 0x5ED4B4E: clone (in /usr/lib64/libc-2.25.so)
==6607==  Lock at 0x639A730 was first observed
==6607==    at 0x4C35CA3: pthread_mutex_init (hg_intercepts.c:787)
==6607==    by 0x41D2DA: fio_monotonic_clocktest (gettime.c:706)
==6607==    by 0x4232EC: parse_cmd_line (init.c:2792)
==6607==    by 0x424372: parse_options (init.c:2920)
==6607==    by 0x40E2EA: main (fio.c:47)
==6607==  Address 0x639a730 is 176 bytes inside a block of size 480 alloc'd
==6607==    at 0x4C2EF7B: malloc (vg_replace_malloc.c:299)
==6607==    by 0x41D227: fio_monotonic_clocktest (gettime.c:690)
==6607==    by 0x4232EC: parse_cmd_line (init.c:2792)
==6607==    by 0x424372: parse_options (init.c:2920)
==6607==    by 0x40E2EA: main (fio.c:47)
==6607==  Block was alloc'd by thread axboe#1

This first issue ("unlock of an unlocked mutex (or by a wrong thread)
t->started") occurs because fio uses a mutexes to arrange for all the
cycle measurement threads to start their timing together but
http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_mutex_lock.html
warns: "If a thread attempts to unlock a mutex that it has not locked or
a mutex which is unlocked, undefined behavior results". Address this by
reworking fio to use a condition plus a condition variable to signal all
threads when its safe to proceed.

ThreadSanitizer has a second warning too:

==================
WARNING: ThreadSanitizer: data race (pid=324)
  Read of size 4 at 0x7ffffceafdf4 by thread T2 (mutexes: write M143):
    #0 clock_thread_fn gettime.c:614:10 (fio+0x4d1743)

  Previous atomic write of size 4 at 0x7ffffceafdf4 by thread T1 (mutexes: write M141):
    #0 __tsan_atomic32_compare_exchange_val <null> (fio+0x479237)
    axboe#1 atomic32_compare_and_swap gettime.c:576:9 (fio+0x4d1785)
    axboe#2 clock_thread_fn gettime.c:619 (fio+0x4d1785)

  Location is stack of main thread.

  Mutex M143 (0x7b5000000088) created at:
    #0 pthread_mutex_init <null> (fio+0x42f6ba)
    axboe#1 fio_monotonic_clocktest gettime.c:705:3 (fio+0x4d0bf7)
    axboe#2 parse_cmd_line init.c:2792:15 (fio+0x4dad0b)
    axboe#3 parse_options init.c:2920:14 (fio+0x4db7b7)
    axboe#4 main fio.c:47 (fio+0x4247fa)

  Mutex M141 (0x7b5000000010) created at:
    #0 pthread_mutex_init <null> (fio+0x42f6ba)
    axboe#1 fio_monotonic_clocktest gettime.c:705:3 (fio+0x4d0bf7)
    axboe#2 parse_cmd_line init.c:2792:15 (fio+0x4dad0b)
    axboe#3 parse_options init.c:2920:14 (fio+0x4db7b7)
    axboe#4 main fio.c:47 (fio+0x4247fa)

  Thread T2 (tid=327, running) created by main thread at:
    #0 pthread_create <null> (fio+0x42f3c6)
    axboe#1 fio_monotonic_clocktest gettime.c:708:7 (fio+0x4d0c20)
    axboe#2 parse_cmd_line init.c:2792:15 (fio+0x4dad0b)
    axboe#3 parse_options init.c:2920:14 (fio+0x4db7b7)
    axboe#4 main fio.c:47 (fio+0x4247fa)

  Thread T1 (tid=326, running) created by main thread at:
    #0 pthread_create <null> (fio+0x42f3c6)
    axboe#1 fio_monotonic_clocktest gettime.c:708:7 (fio+0x4d0c20)
    axboe#2 parse_cmd_line init.c:2792:15 (fio+0x4dad0b)
    axboe#3 parse_options init.c:2920:14 (fio+0x4db7b7)
    axboe#4 main fio.c:47 (fio+0x4247fa)

SUMMARY: ThreadSanitizer: data race gettime.c:614:10 in clock_thread_fn

The second issue ("t->seq data race") seems to be because mixing atomic
and non-atomic operations on the same address might not be safe (e.g.
the compiler may be allowed to make dangerous optimisations). Fix this
waring by using a __sync_fetch_and_add() to do the read and remove the
no longer needed __sync_synchronize().

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants