Discussion:
Valgrind: r16251 - /trunk/gdbserver_tests/
(too old to reply)
s***@valgrind.org
2017-02-19 11:23:46 UTC
Permalink
Raw Message
Author: philippe
Date: Sun Feb 19 11:23:46 2017
New Revision: 16251

Log:
modifty sleepers to have easier evaluation of interaction between cpu freq scaling
and scheduler lock (pipe based or futex based)

See http://www.valgrind.org/docs/manual/manual-core.html#manual-core.pthreads_perf_sched
for background info about cpu freq scaling and valgrind thread scheduler.

To reproduce the interaction, do:
for sched in --fair-sched=yes --fair-sched=no
do
for affinity in 0 1
do
echo $sched $affinity
time ./vg-in-place $sched -q ./gdbserver_tests/sleepers 1000000 0 1000 B-B-B-B- $affinity
done
done

which gives the below output (intel core i5-6402P, debian 8, kernel 3.16.0).
In summary: the fair scheduler is fair, the pipe based scheduler
can be really unfair (e.g. with --fair-sched=no and no affinity,
2 threads are finishing their work, while the 2 other threads are
starting their work only after the first 2 have fully finished).
The difference in timing is significant : 1m14s versus around 47 seconds.

Note: If the governor is set to performance, strangely, the time needed for
--fair-sched=no increases slighltly (to around 48 seconds).
The time for --fair-sched=yes with or without affinity is then also
to around 48 seconds.

Below is timing with on-demand governor:

--fair-sched=yes 0
loops/sleep_ms/burn/threads_spec/affinity: 1000000 0 1000 B-B-B-B- 0
Brussels ready to sleep and/or burn
London ready to sleep and/or burn
Petaouchnok ready to sleep and/or burn
main ready to sleep and/or burn
Brussels finished to sleep and/or burn
London finished to sleep and/or burn
Petaouchnok finished to sleep and/or burn
main finished to sleep and/or burn

real 1m14.582s
user 1m14.348s
sys 0m0.204s
--fair-sched=yes 1
loops/sleep_ms/burn/threads_spec/affinity: 1000000 0 1000 B-B-B-B- 1
Brussels ready to sleep and/or burn
London ready to sleep and/or burn
Petaouchnok ready to sleep and/or burn
main ready to sleep and/or burn
main finished to sleep and/or burn
Brussels finished to sleep and/or burn
Petaouchnok finished to sleep and/or burn
London finished to sleep and/or burn

real 0m46.785s
user 0m46.756s
sys 0m0.032s
--fair-sched=no 0
loops/sleep_ms/burn/threads_spec/affinity: 1000000 0 1000 B-B-B-B- 0
Brussels ready to sleep and/or burn
Brussels finished to sleep and/or burn
London ready to sleep and/or burn
London finished to sleep and/or burn
Petaouchnok ready to sleep and/or burn
main ready to sleep and/or burn
Petaouchnok finished to sleep and/or burn
main finished to sleep and/or burn

real 0m47.742s
user 0m48.224s
sys 0m0.084s
--fair-sched=no 1
loops/sleep_ms/burn/threads_spec/affinity: 1000000 0 1000 B-B-B-B- 1
Brussels ready to sleep and/or burn
London ready to sleep and/or burn
Petaouchnok ready to sleep and/or burn
main ready to sleep and/or burn
Brussels finished to sleep and/or burn
London finished to sleep and/or burn
main finished to sleep and/or burn
Petaouchnok finished to sleep and/or burn

real 0m46.601s
user 0m46.568s
sys 0m0.036s


Modified:
trunk/gdbserver_tests/mcinfcallRU.stderr.exp
trunk/gdbserver_tests/mcinfcallRU.vgtest
trunk/gdbserver_tests/mcinfcallWSRU.stderr.exp
trunk/gdbserver_tests/mcinfcallWSRU.vgtest
trunk/gdbserver_tests/mcinvokeRU.vgtest
trunk/gdbserver_tests/nlcontrolc.stderr.exp
trunk/gdbserver_tests/nlcontrolc.vgtest
trunk/gdbserver_tests/nlsigvgdb.vgtest
trunk/gdbserver_tests/nlvgdbsigqueue.stderr.exp
trunk/gdbserver_tests/nlvgdbsigqueue.vgtest
trunk/gdbserver_tests/sleepers.c

Modified: trunk/gdbserver_tests/mcinfcallRU.stderr.exp
==============================================================================
--- trunk/gdbserver_tests/mcinfcallRU.stderr.exp (original)
+++ trunk/gdbserver_tests/mcinfcallRU.stderr.exp Sun Feb 19 11:23:46 2017
@@ -1,4 +1,4 @@
-loops/sleep_ms/burn/threads_spec: 1 0 2000000000 ------B-
+loops/sleep_ms/burn/threads_spec/affinity: 1 0 2000000000 ------B- 1
main ready to sleep and/or burn
pid .... Thread .... inferior call pushed from gdb in mcinfcallRU.stdinB.gdb
Reset valgrind output to log (orderly_finish)

Modified: trunk/gdbserver_tests/mcinfcallRU.vgtest
==============================================================================
--- trunk/gdbserver_tests/mcinfcallRU.vgtest (original)
+++ trunk/gdbserver_tests/mcinfcallRU.vgtest Sun Feb 19 11:23:46 2017
@@ -2,7 +2,7 @@
prog: sleepers
# We would like to use B-B-B-B- instead of ------B- but this gives
# too much dependencies to the scheduler fairness.
-args: 1 0 2000000000 ------B-
+args: 1 0 2000000000 ------B- 1
vgopts: --tool=memcheck --vgdb=yes --vgdb-error=0 --vgdb-prefix=./vgdb-prefix-mcinfcallRU
# filter_gdb to replace pid and Thread numbers in the output of the program:
stderr_filter: filter_gdb

Modified: trunk/gdbserver_tests/mcinfcallWSRU.stderr.exp
==============================================================================
--- trunk/gdbserver_tests/mcinfcallWSRU.stderr.exp (original)
+++ trunk/gdbserver_tests/mcinfcallWSRU.stderr.exp Sun Feb 19 11:23:46 2017
@@ -1,4 +1,4 @@
-loops/sleep_ms/burn/threads_spec: 100 100000000 1000000000 -S-S-SB-
+loops/sleep_ms/burn/threads_spec/affinity: 100 100000000 1000000000 -S-S-SB- 1
Brussels ready to sleep and/or burn
London ready to sleep and/or burn
Petaouchnok ready to sleep and/or burn

Modified: trunk/gdbserver_tests/mcinfcallWSRU.vgtest
==============================================================================
--- trunk/gdbserver_tests/mcinfcallWSRU.vgtest (original)
+++ trunk/gdbserver_tests/mcinfcallWSRU.vgtest Sun Feb 19 11:23:46 2017
@@ -3,7 +3,7 @@
prog: sleepers
# We would like to have two threads running (i.e. -S-SB-B-)
# but this introduces too much dependencies to scheduler fairness.
-args: 100 100000000 1000000000 -S-S-SB-
+args: 100 100000000 1000000000 -S-S-SB- 1
vgopts: --tool=memcheck --vgdb=yes --vgdb-error=0 --vgdb-prefix=./vgdb-prefix-mcinfcallWSRU
# We need a non buggy gdb.step on arm thumb.
# Disable on Darwin: inferior call rejected as it cannot find malloc.

Modified: trunk/gdbserver_tests/mcinvokeRU.vgtest
==============================================================================
--- trunk/gdbserver_tests/mcinvokeRU.vgtest (original)
+++ trunk/gdbserver_tests/mcinvokeRU.vgtest Sun Feb 19 11:23:46 2017
@@ -1,7 +1,7 @@
# test that vgdb can invoke a process when all threads are in Runnable or Yielding mode
# If the test goes wrong, it might consume CPU during a long time.
prog: sleepers
-args: 1 0 1000000000 B-B-B-B-
+args: 1 0 1000000000 B-B-B-B- 1
vgopts: --tool=memcheck --vgdb=yes --vgdb-prefix=./vgdb-prefix-mcinvokeRU
stderr_filter: filter_make_empty
# as the Valgrind process is always busy, we do not need the vgdb.invoker prereq.

Modified: trunk/gdbserver_tests/nlcontrolc.stderr.exp
==============================================================================
--- trunk/gdbserver_tests/nlcontrolc.stderr.exp (original)
+++ trunk/gdbserver_tests/nlcontrolc.stderr.exp Sun Feb 19 11:23:46 2017
@@ -3,7 +3,7 @@
(action at startup) vgdb me ...


-loops/sleep_ms/burn/threads_spec: 1000000000 1000000000 1000000000 BSBSBSBS
+loops/sleep_ms/burn/threads_spec/affinity: 1000000000 1000000000 1000000000 BSBSBSBS 1
Brussels ready to sleep and/or burn
London ready to sleep and/or burn
Petaouchnok ready to sleep and/or burn

Modified: trunk/gdbserver_tests/nlcontrolc.vgtest
==============================================================================
--- trunk/gdbserver_tests/nlcontrolc.vgtest (original)
+++ trunk/gdbserver_tests/nlcontrolc.vgtest Sun Feb 19 11:23:46 2017
@@ -9,7 +9,7 @@
# This test is disabled on Solaris because modifying select/poll/ppoll timeout
# has no effect if a thread is already blocked in that syscall.
prog: sleepers
-args: 1000000000 1000000000 1000000000 BSBSBSBS
+args: 1000000000 1000000000 1000000000 BSBSBSBS 1
vgopts: --tool=none --vgdb=yes --vgdb-error=0 --vgdb-prefix=./vgdb-prefix-nlcontrolc
stderr_filter: filter_stderr
# Bug 338633 nlcontrol hangs on arm64 currently.

Modified: trunk/gdbserver_tests/nlsigvgdb.vgtest
==============================================================================
--- trunk/gdbserver_tests/nlsigvgdb.vgtest (original)
+++ trunk/gdbserver_tests/nlsigvgdb.vgtest Sun Feb 19 11:23:46 2017
@@ -4,7 +4,7 @@
# But if this signal is masked, then vgdb does not recuperate the control
# and Valgrind dies. See function give_control_back_to_vgdb in m_gdbserver.c
prog: sleepers
-args: 1 10000000 0 -S-S-S-S
+args: 1 10000000 0 -S-S-S-S 1
vgopts: --tool=none --vgdb=yes --vgdb-error=0 --vgdb-prefix=./vgdb-prefix-nlsigvgdb
stderr_filter: filter_stderr
prereq: test -e gdb -a -f vgdb.invoker

Modified: trunk/gdbserver_tests/nlvgdbsigqueue.stderr.exp
==============================================================================
--- trunk/gdbserver_tests/nlvgdbsigqueue.stderr.exp (original)
+++ trunk/gdbserver_tests/nlvgdbsigqueue.stderr.exp Sun Feb 19 11:23:46 2017
@@ -3,7 +3,7 @@
(action at startup) vgdb me ...


-loops/sleep_ms/burn/threads_spec: 1000000000 1000000000 1 BSBSBSBS
+loops/sleep_ms/burn/threads_spec/affinity: 1000000000 1000000000 1 BSBSBSBS 1
Brussels ready to sleep and/or burn
London ready to sleep and/or burn
Petaouchnok ready to sleep and/or burn

Modified: trunk/gdbserver_tests/nlvgdbsigqueue.vgtest
==============================================================================
--- trunk/gdbserver_tests/nlvgdbsigqueue.vgtest (original)
+++ trunk/gdbserver_tests/nlvgdbsigqueue.vgtest Sun Feb 19 11:23:46 2017
@@ -3,7 +3,7 @@
# vgdb must queue these signals and deliver them before PTRACE_DETACHing.
# sleepers is started with argument so that it will mostly sleep.
prog: sleepers
-args: 1000000000 1000000000 1 BSBSBSBS
+args: 1000000000 1000000000 1 BSBSBSBS 1
vgopts: --tool=none --vgdb=yes --vgdb-error=0 --vgdb-prefix=./vgdb-prefix-nlvgdbsigqueue
stderr_filter: filter_stderr
prereq: test -e gdb -a -f vgdb.invoker

Modified: trunk/gdbserver_tests/sleepers.c
==============================================================================
--- trunk/gdbserver_tests/sleepers.c (original)
+++ trunk/gdbserver_tests/sleepers.c Sun Feb 19 11:23:46 2017
@@ -137,7 +137,7 @@
pthread_t ebbr, egll, zzzz;
struct spec b, l, p, m;
char *some_mem __attribute__((unused)) = malloc(100);
- setaffinity();
+ if (argc > 5 && atoi(argv[5])) setaffinity();
setup_sigusr_handler();
if (argc > 1)
loops = atoi(argv[1]);
@@ -153,8 +153,8 @@
else
threads_spec = "BSBSBSBS";

- fprintf(stderr, "loops/sleep_ms/burn/threads_spec: %d %d %d %s\n",
- loops, sleepms, burn, threads_spec);
+ fprintf(stderr, "loops/sleep_ms/burn/threads_spec/affinity: %d %d %d %s %d\n",
+ loops, sleepms, burn, threads_spec, argc > 5 && atoi(argv[5]));
fflush(stderr);

b.name = "Brussels";

Loading...