Skip to content
Snippets Groups Projects
  1. Dec 30, 2013
  2. Dec 26, 2013
  3. Dec 24, 2013
    • Avi Kivity's avatar
      bsd: convert the Xen stuff to C++ · 828ec291
      Avi Kivity authored
      
      Helps making bsd header changes that xen includes.
      
      Signed-off-by: default avatarAvi Kivity <avi@cloudius-systems.com>
      828ec291
    • Nadav Har'El's avatar
      sched: Overhaul sched::thread::attr construction · eb48b150
      Nadav Har'El authored
      
      We use sched::thread::attr to pass parameters to sched::thread creation,
      i.e., create a thread with non-default stack parameters, pinned to a
      particular CPU, or a detached thread.
      
      Previously we had constructors taking many combinations of stack size
      (integer), pinned cpu (cpu*) and detached (boolean), and doing "the
      right thing". However, this makes the code hard to read (what does
      attr(4096) specify?) and the constructors hard to expand with new
      parameters.
      
      Replace the attr() constructors with the so-called "named parameter"
      idiom: attr now only has a null constructor attr(), and one modifies
      it with calls to pin(cpu*), detach(), or stack(size).
      
      For example,
          attr()                                  // default attributes
          attr().pin(sched::cpus[0])              // pin to cpu 0
          attr().stack(4096).pin(sched::cpus[0])  // pin and non-default stack
          and so on.
      
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      Signed-off-by: default avatarAvi Kivity <avi@cloudius-systems.com>
      eb48b150
  4. Dec 20, 2013
  5. Dec 19, 2013
  6. Dec 18, 2013
  7. Dec 17, 2013
  8. Dec 16, 2013
  9. Dec 15, 2013
    • 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
  10. Dec 13, 2013
  11. Dec 12, 2013
  12. Dec 11, 2013
  13. Dec 10, 2013
Loading