]> Git Repo - linux.git/commit
perf record: Use an eventfd to wakeup when done
authorAnand K Mistry <[email protected]>
Wed, 13 May 2020 02:20:23 +0000 (12:20 +1000)
committerArnaldo Carvalho de Melo <[email protected]>
Thu, 28 May 2020 13:03:26 +0000 (10:03 -0300)
commitda231338ec9c098707c8a1e4d8a50e2400e2fe17
treee8a83a9a7a96597dbfe94954a1560099fb2672ea
parentba35fe9358dfb961c74f3677a468148add9b23cb
perf record: Use an eventfd to wakeup when done

The setting and checking of 'done' contains a rare race where the signal
handler setting 'done' is run after checking to break the loop, but
before waiting in evlist__poll(). In this case, the main loop won't wake
up until either another signal is sent, or the perf data fd causes a
wake up.

The following simple script can trigger this condition (but you might
need to run it for several hours):

for ((i = 0; i >= 0; i++)) ; do
  echo "Loop $i"
  delay=$(echo "scale=4; 0.1 * $RANDOM/32768" | bc)
  ./perf record -- sleep 30000000 >/dev/null&
  pid=$!
  sleep $delay
  kill -TERM $pid
  echo "PID $pid"
  wait $pid
done

At some point, the loop will stall. Adding logging, even though perf has
received the SIGTERM and set 'done = 1', perf will remain sleeping until
a second signal is sent.

Committer notes:

Make this dependent on HAVE_EVENTFD_SUPPORT, so that we continue
building on older systems without the eventfd syscall.

Signed-off-by: Anand K Mistry <[email protected]>
Acked-by: Jiri Olsa <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lore.kernel.org/lkml/20200513122012.v3.1.I4d7421c6bbb1f83ea58419082481082e19097841@changeid
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/perf/builtin-record.c
This page took 0.052905 seconds and 4 git commands to generate.