sim-se: factor out FutexMap::suspend and FutexMap::suspend_bitset
authorCiro Santilli <ciro.santilli@arm.com>
Thu, 19 Dec 2019 19:04:32 +0000 (19:04 +0000)
committerCiro Santilli <ciro.santilli@arm.com>
Mon, 10 Aug 2020 08:52:03 +0000 (08:52 +0000)
Both methods do basically the same, especially since they don't handle the
timeout which is basically the only difference between both modes of the
syscall (one uses absolute and the other relative time).

Remove the WaiterState::WaiterState(ThreadContext* _tc) constructor,
since the only calls were from FutexMap::suspend which does not use them
anymore. Instead, set the magic 0xffffffff constant as a parameter to
suspend_bitset.

Change-Id: I69d86bad31d63604657a3c71cf07e5623f0ea639
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/29776
Reviewed-by: Brandon Potter <Brandon.Potter@amd.com>
Maintainer: Brandon Potter <Brandon.Potter@amd.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/sim/futex_map.cc
src/sim/futex_map.hh

index e2880aaeb237ccdab94799a7c3e2ccbe355a3c90..f7dde9cc5f964f6c07163c70c60eea04859401cf 100644 (file)
@@ -26,7 +26,6 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <debug/Thread.hh>
 #include <sim/futex_map.hh>
 
 FutexKey::FutexKey(uint64_t addr_in, uint64_t tgid_in)
@@ -53,9 +52,6 @@ namespace std {
 WaiterState::WaiterState(ThreadContext* _tc, int _bitmask)
       : tc(_tc), bitmask(_bitmask) { }
 
-WaiterState::WaiterState(ThreadContext* _tc)
-      : tc(_tc), bitmask(0xffffffff) { }
-
 bool
 WaiterState::checkMask(int wakeup_bitmask) const
 {
@@ -65,18 +61,7 @@ WaiterState::checkMask(int wakeup_bitmask) const
 void
 FutexMap::suspend(Addr addr, uint64_t tgid, ThreadContext *tc)
 {
-    FutexKey key(addr, tgid);
-    auto it = find(key);
-
-    if (it == end()) {
-        WaiterList waiterList {WaiterState(tc)};
-        insert({key, waiterList});
-    } else {
-        it->second.push_back(WaiterState(tc));
-    }
-
-    /** Suspend the thread context */
-    tc->suspend();
+    suspend_bitset(addr, tgid, tc, 0xffffffff);
 }
 
 int
index 025d324296d65cdee36630aaeca36c80f1eeef1e..13caa1291ae6164331bdff54a8881831c0e812f8 100644 (file)
@@ -74,11 +74,6 @@ class WaiterState {
      */
     WaiterState(ThreadContext* _tc, int _bitmask);
 
-    /**
-     * if bitset is not defined, just set bitmask to 0xffffffff
-     */
-    WaiterState(ThreadContext* _tc);
-
     /**
      * return true if the bit-wise AND of the wakeup_bitmask given by
      * a waking thread and this thread's internal bitmask is non-zero