Skip to content
Snippets Groups Projects
  1. Dec 18, 2013
  2. Dec 17, 2013
  3. Dec 16, 2013
  4. Dec 15, 2013
    • Avi Kivity's avatar
      build: get rid of libunwind.a · 9ad8663a
      Avi Kivity authored
      
      Now that backtrace() doesn't use libunwind, we can remove it.
      
      Signed-off-by: default avatarAvi Kivity <avi@cloudius-systems.com>
      9ad8663a
    • Nadav Har'El's avatar
      backtrace(): Use libgcc_eh.a instead of libunwind.a. · 1d581c75
      Nadav Har'El authored
      
      This patch changes backtrace() to use the _Unwind_* facilities provided
      by the GCC runtime (libgcc_eh.a), instead of the separate libunwind.a.
      
      After this patch, we don't use libunwind.a in OSv any more, and it can
      be removed (see issue #83).
      
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      Signed-off-by: default avatarAvi Kivity <avi@cloudius-systems.com>
      1d581c75
    • Nadav Har'El's avatar
      Fix race between join() and thread completion · 649654af
      Nadav Har'El authored
      
      thread::destroy() had a "FIXME" comment:
      // FIXME: we have a problem in case of a race between join() and the
      // thread's completion. Here we can see _joiner==0 and not notify
      // anyone, but at the same time join() decided to go to sleep (because
      // status is not yet status::terminated) and we'll never wake it.
      
      This is indeed a bug, which Glauber discovered was hanging the
      tst-threadcomplete.so test once in a while - the test sometimes hangs
      with one thread in the "terminated" state (waiting for someone to join
      it), and a second thread waiting in join() but missed the other thread's
      termination event.
      
      The solution works like this:
      
      join() uses a CAS to set itself as the _joiner. If it succeeded, it
      waits like before for the status to become "terminated". But if the CAS
      failed, it means a concurrent destroy() call beat us at the race, and we
      can just return from join().
      
      destroy() checks (with a CAS) if _joiner was already set - if so we need
      to wake this thread just like in the original code. But if _joiner was
      not yet set, either there is no-one doing join(), or there's a concurrent
      join() call that will soon return (this is what the joiner does when it
      loses the CAS race). In this case, all we need to do is to set the status
      to "terminated" - and we must do it through a _detached_state we saved
      earlier, because if join() already returned the thread may already be
      deleted).
      
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      Signed-off-by: default avatarAvi Kivity <avi@cloudius-systems.com>
      649654af
    • Nadav Har'El's avatar
      Fix wake_with() · a6bbd0e7
      Nadav Har'El authored
      
      wake_with(action) was implemented using thread_handle, as the following:
      
      thread_handle h(handle());
      action();
      h.wake();
      
      This implementation is wrong: It only takes the RCU lock (which prevents
      the destruction of _detached_state) during h.wake(), meaning that if the
      thread is not sleeping, and action() causes it to exit, _detached_state
      may also be destructed, and h.wake() will crash.
      
      thread_handle is simply not needed for wake_with(), and was designed
      with a completely different use case in mind (long-term holding of a
      thread handler). We just need to use, in-line, the appropriate rcu
      lock which keeps _detached_state alive. The resulting code is even
      simpler, and nicely parallels the existing code of wake().
      
      This patch fixes a real bug, but unfortunately we don't have a concrete
      test-case which it is known to fix.
      
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      Signed-off-by: default avatarAvi Kivity <avi@cloudius-systems.com>
      a6bbd0e7
    • Nadav Har'El's avatar
      Add rcu_lock_in_preempt_type · 9f0e1287
      Nadav Har'El authored
      
      Add a new lock, "rcu_read_lock_in_preempt_disabled", which is exactly
      like rcu_read_lock but assuming that preemption is already disabled.
      Because all our rcu_read_lock does is to disable preemption, the new
      lock type currently does absolutely nothing - but in some future
      implementation of RCU it might need to do something.
      
      We'll use the new lock type in the following patch, as an optimization
      over the regular rcu_read_lock.
      
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      Signed-off-by: default avatarAvi Kivity <avi@cloudius-systems.com>
      9f0e1287
    • Glauber Costa's avatar
      enable interrupts during page fault handling · ec7ed8cd
      Glauber Costa authored
      
      Context: going to wait with irqs_disabled is a call for disaster.  While it is
      true that not every time we call wait we actually end up waiting, that should
      be an invalid call, due to the times we may wait. Because of that, it would
      be good to express that nonsense in an assertion.
      
      There is however, places we sleep with irqs disabled currently. Although they
      are technically safe, because we implicitly enable interrupts, they end up
      reaching wait() in a non-safe state. That happens in the page fault handler.
      Explicitly enabling interrupts will allow us to test for valid / invalid wait
      status.
      
      With this test applied, all tests in our whitelist still passes.
      
      Signed-off-by: default avatarGlauber Costa <glommer@cloudius-systems.com>
      Signed-off-by: default avatarAvi Kivity <avi@cloudius-systems.com>
      ec7ed8cd
  5. Dec 13, 2013
  6. Dec 12, 2013
Loading