Bug 301830 - MultiThreadedV (mtV): improve Valgrind so that it runs multiple threads in parallel
Summary: MultiThreadedV (mtV): improve Valgrind so that it runs multiple threads in pa...
Status: CONFIRMED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.7.0
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-13 18:06 UTC by Philippe Waroquiers
Modified: 2016-04-09 19:37 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
document describing the prototype/problems/... (39.70 KB, text/plain)
2012-06-13 18:09 UTC, Philippe Waroquiers
Details
prototype patch (still *plenty* of problems) making core run threads in parallel (124.71 KB, text/plain)
2012-06-13 18:13 UTC, Philippe Waroquiers
Details
patch to implement tls (thread local storage) for Valgrind (29.42 KB, text/plain)
2012-06-13 18:17 UTC, Philippe Waroquiers
Details
patch updated to recent svn version + modified perf tests + doc (187.88 KB, text/plain)
2013-03-03 22:07 UTC, Philippe Waroquiers
Details
patch for mips (12.68 KB, patch)
2013-05-22 14:49 UTC, Fred M
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Waroquiers 2012-06-13 18:06:07 UTC
Bugzilla entry to follow up the prototype of improving the way Valgrind runs threads in parallel
Comment 1 Philippe Waroquiers 2012-06-13 18:09:56 UTC
Created attachment 71802 [details]
document describing the prototype/problems/...
Comment 2 Philippe Waroquiers 2012-06-13 18:13:02 UTC
Created attachment 71803 [details]
prototype patch (still *plenty* of problems) making core run threads in parallel

!!!!! do not use for anything else than prototype evaluation.
There are still *many* ugly things/thread non safe things/ulgy problems not looked at
It only (maybe) compiles on x86 and amd64.
Comment 3 Philippe Waroquiers 2012-06-13 18:17:37 UTC
Created attachment 71804 [details]
patch to implement tls (thread local storage) for Valgrind

prototype on how tls variable (__thread attribute) variable could be supported
in Valgrind
Comment 4 Fred M 2012-06-14 21:41:46 UTC
Is there a possibility to have the Valgrind mutli-core / multi-thread compatible with mipsel ?

Cf "Bug 270777 - Adding MIPS/Linux port to Valgrind  " 

Best Regards,
Comment 5 Philippe Waroquiers 2012-06-14 22:12:19 UTC
(In reply to comment #4)
> Is there a possibility to have the Valgrind mutli-core / multi-thread
> compatible with mipsel ?
At this stage, this bug entry is just a place holder for ideas/discussions and
very partial prototype which is buggy/non fully thread safe/...
This is not at all usable for any work, for many reasons.

But if this results one day in something usable, I do not see why it would not be possible for
mips to use it :
most of the difficulty is in the core of Valgrind and the tools themselves, not
in the arch cpu specific code.
Comment 6 John Reiser 2012-12-31 16:05:40 UTC
The case of internal counters for statistics or performance monitoring is simple to fix.  Change any such counter into a thread-local variable, and add a function which sums the values across all threads.  In many cases the function does not need a big lock, nor exclusive access.  The counters are monotonic, and a sum which may be low by a few counts (a few per thread) usually is just fine.
Comment 7 John Reiser 2012-12-31 16:24:15 UTC
For the specific tool memcheck, it seems that significant pieces of the tool-specific data structures are "monotonic": they only grow, and do not shrink; or the values change only in one direction, at least for relatively long (and demarcated) periods of time, such as from 'malloc' to 'free'.  Exploiting such monotonicity might be helpful.
Comment 8 Philippe Waroquiers 2012-12-31 17:07:43 UTC
(In reply to comment #6)
> The case of internal counters for statistics or performance monitoring is
> simple to fix.  Change any such counter into a thread-local variable, and
> add a function which sums the values across all threads.  In many cases the
> function does not need a big lock, nor exclusive access.  The counters are
> monotonic, and a sum which may be low by a few counts (a few per thread)
> usually is just fine.

I did a trial to use thread local storage (see attachment 3 [details])
 Not trivial to use as Valgrind cannot use any libc support.
So, it was needed to emulate a part of the needed run-time support
expected by the compiler. This proto was working on some platforms (x86/amd64/ppc IIRC.
arm looked more tricky. not looked as s390).

But the main problem (the V bits data structure) cannot be solved by TLS.
Comment 9 Philippe Waroquiers 2013-03-03 22:07:03 UTC
Created attachment 77718 [details]
patch updated to recent svn version + modified perf tests + doc

Documentation has been added in docs/internals/mtV.txt
gdbserver_tests/sleepers now accepts an additional arg 5   -p to make it run on more than 1 CPU
perf/big_parallel_sleepers is burning cpu with bigger code (to shake the translation logic/tables)
Comment 10 Julian Seward 2013-03-27 12:42:24 UTC
(In reply to comment #9)
> Created attachment 77718 [details]
> patch updated to recent svn version + modified perf tests + doc

Committed as r13341, on branches/MTV.  To checkout:
  svn co svn://svn.valgrind.org/valgrind/branches/MTV MTV
  cd MTV
Comment 11 Fred M 2013-05-22 14:49:48 UTC
Created attachment 80023 [details]
patch for mips
Comment 12 Fred M 2013-05-22 14:51:36 UTC
Hi  

In attachment the "patch for mips"  : Addons to compile on mipsel 

At the launch , it crashes , it seems to be caused by the delta between this branch and the main.

Regards,
Frédéric

Something called raise().

valgrind: m_main.c:2678 (abort): the 'impossible' happened.
==2063==    at 0x38034990: report_and_quit (m_libcassert.c:264)
==2063==    by 0x38034B44: vgPlain_assert_fail (m_libcassert.c:344)
==2063==    by 0x3803FEE4: abort (m_main.c:2678)
==2063==    by 0x380828DC: vgPlain_scheduler (scheduler.c:1349)
==2063==    by 0x38096020: run_a_thread_NORETURN (syswrap-linux.c:103)
==2063==    by 0x38096408: vgPlain_main_thread_wrapper_NORETURN (syswrap-linux.c:396)

sched status:

Thread 1: status = VgTs_Runnable slk = VgTs_ReadLock in_gen_code 0
==2063==    at 0x4000ED0: _start (in /lib/ld-uClibc-0.9.33.2.so)
==2063==    by 0x7EF7CBD8: ???