helper_thread: better handle select() return value
authorVincent Fu <vincent.fu@wdc.com>
Tue, 12 May 2020 16:50:25 +0000 (12:50 -0400)
committerVincent Fu <vincent.fu@wdc.com>
Tue, 12 May 2020 16:50:25 +0000 (12:50 -0400)
commit8c55e40e7cf127577fa70adcc6ef1d7f01558f98
tree2e332e79bfaf27d67bd4a8a14df75cf679e76cbb
parent9bc878ed59deb6c4a031f4f3a8d1ff3bbdbbd14d
helper_thread: better handle select() return value

On Windows, the ETA is not updated after ramp_time expires. For example:

C:\fio-dev>fio\fio --name=test --runtime=5s --time_based --ramp_time=5 --size=1M --ioengine=null --thread
test: (g=0): rw=read, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=null, iodepth=1
fio-3.19-54-g9bc8
Starting 1 thread
Jobs: 1 (f=0): [/(1)][-.-%][eta 00m:05s]
test: (groupid=0, jobs=1): err= 0: pid=5344: Tue May 12 10:40:49 2020
  read: IOPS=2535k, BW=9903MiB/s (10.4GB/s)(48.4GiB/5001msec)
    clat (nsec): min=38, max=10680, avg=40.94, stdev= 4.20
     lat (nsec): min=107, max=10751, avg=110.78, stdev= 6.13
...

Notice that the last ETA update line indicates that there are still 5s
of runtime left even though the job has finished. This occurs because
the while loop in helper_thread_main() finishes soon after ramp_time
expires instead of continuing to run until the last job has completed.
The while loop ends because the return value for select() is stored in
ret. select() can return positive values in non-error conditions. The
while loop should not end when select() returns a positive value.

Fixes: 700ad386aa88 ("helper_thread: Complain if select() fails")
helper_thread.c