Review Board 2.0.15


sim: stopgap for race-conditions when using multiple EventQueues

Review Request #2320 - Created Aug. 1, 2014 and updated

Information
Martin Brown
gem5
default
Reviewers
Default
Changeset 10264:c3977836244e
---------------------------
sim: stopgap for race-conditions when using multiple EventQueues

This patch fixes several race conditions that appear in multi-
threaded mode. Currently the decode cache race condition is
fixed only for x86, and in a temporary non-optimal fashion. We
still need to decide on a more optimal solution for the decode
cache and apply it to all the ISAs.

- Quick regression tests on x86, arm, alpha
- Made sure that sparc, power, mips can be built with this patch
- Tested using up to 28 EventQueues (28 threads)

Issue Summary

2 2 0 0
Review request changed
Updated (Aug. 1, 2014, 12:04 p.m.)

Description:

   

Changeset 10264:c3977836244e

   
   

sim: stopgap for race-conditions when using multiple EventQueues

   
   

This patch fixes several race conditions that appear in multi-

    threaded mode. Currently the decode cache race condition is
    fixed only for x86, and in a temporary non-optimal fashion. We
    still need to decide on a more optimal solution for the decode
    cache and apply it to all the ISAs.

Posted (Aug. 1, 2014, 1:46 p.m.)
Thanks. I think the non decoder stuff is fine to commit, but I'm not sure how we go about selecting a long term solution
src/arch/x86/decoder.cc (Diff revision 1)
 
 
You've used Mtx and Mutex as a suffix for a lock. I don't know that we have a particular coding style, but in the places we've used a mutex in the code so far we used mutex, so unless there are any strong objections I vote to stick with that 
src/arch/x86/decoder.cc (Diff revision 1)
 
 
There is a 5th option:
A thread-local instCachMap which is probably superior to #1 assuming you have more that one simulated cpu per physical cpu. 
There is shared_lock in c++14 and the implementation is pretty simple based on mutex and condition variables:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2406.html#shared_mutex
Posted (Aug. 4, 2014, 2:06 a.m.)
Out of curiosity, is there any performance impact for the single-threaded case?
Posted (Aug. 12, 2014, 6:07 a.m.)
I doubt it is a big issue at this point, but for sake of argument, the random number generation is also not thread safe.