]> granicus.if.org Git - strace/commit
Implement queueing of threads before dispatching them
authorEugene Syromyatnikov <evgsyr@gmail.com>
Wed, 8 Aug 2018 19:41:39 +0000 (21:41 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 19 Aug 2018 10:26:18 +0000 (10:26 +0000)
commit82f7fea5220992e1538200564cf7021bb3f39b5b
tree4b21af9f65f88357550a4ff00690d0b71a86be53
parent49dbd3792d19fb0450150412849e8447942db269
Implement queueing of threads before dispatching them

It is possible that some tracees call a lot of cheap syscalls too fast,
and that can lead to starvation to the point some tracees are not served
for indefinite amount of time.  In order to solve that unfairness, try
to collect all the pending tracees first (along with the relevant
information) and only then dispatch the events.

* defs.h: Include "list.h".
(struct tcb): Add wait_data_idx, wait_extra_data_idx, wait_list fields.
* strace.c (tcb_wait_tab): New variable.
(expand_tcbtab): Resize tcb_wait_tab along with tcbtab, provide
an additional slot for extra event.
(droptcb): Remove tcp from wait_list.
(maybe_switch_tcbs): Get old pid from
tcb_wait_tab[tcp->wait_data_idx].msg.
(next_event): Add pending_tcps, extra_tcp, wait_nohang, elem, and
wait_tab_pos variables; check for elements in pending_tcps and skip
waiting if the list is not empty; check for extra_tcp and skip waiting
along with swapping wait_data_idx with wait_extra_data_idx;
after the initial wait, call wait4() in loop with WNOHANG flag set;
fetch siginfo on signal and eventmsg on PTRACE_EVENT_EXEC;
return the first tcp in pending_tcps list.
* tests/Makefile.am (XFAIL_TEST): Remove looping_threads.test.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=478419
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=526740
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=851457
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1609318
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1610774
Co-Authored-by: Dmitry Vlasenko <dvlasenk@redhat.com>
Co-Authored-by: Andreas Schwab <aschwab@redhat.com>
Co-Authored-by: Jeff Law <law@redhat.com>
Co-Authored-by: DJ Delorie <dj@redhat.com>
defs.h
strace.c
tests/Makefile.am