1. 27 Feb, 2008 2 commits
    • Jeremy Kerr's avatar
      [POWERPC] spufs: fix invalid scheduling of forgotten contexts · 0111a701
      Jeremy Kerr authored
      At present, we have a situation where a context with no owner is
      re-scheduled by spu_forget:
      
      	Thread 1: reading regs file	Thread 2: context owner
      
      					spu_forget()
      						- ctx->owner = NULL
      						- set SPU_SCHED_WAS_ACTIVE
      
      	spu_acquire_saved()
      	- context is in saved state
      
      	spu_release_saved()
      	- SPU_SCHED_WAS_ACTIVE is set,
      	  so spu_activate() the context,
      	  which now has no owner
      
      In spu_forget(), we shouldn't be requesting a re-schedule by setting
      SPU_SCHED_WAS_ACTIVE. This change removes the set_bit in spu_forget(),
      so that spu_release_saved() doesn't reinsert this destroyed context on
      to the run queue.
      Signed-off-by: default avatarJeremy Kerr <jk@ozlabs.org>
      0111a701
    • Jeremy Kerr's avatar
      [POWERPC] spufs: fix context destruction during psmap fault · d5883137
      Jeremy Kerr authored
      We have a small window where a spu context may be destroyed while
      we're servicing a page fault (from another thread) to the context's
      problem state mapping.
      
      After we up_read() the mmap_sem, it's possible that the context is
      destroyed by its owning thread, and so the later references to ctx
      are invalid. This can maifest as a deadlock on the (now free()-ed)
      context state mutex.
      
      This change adds a reference to the context before we release the
      mmap_sem, so that the context cannot be destroyed.
      Signed-off-by: default avatarJeremy Kerr <jk@ozlabs.org>
      d5883137
  2. 20 Feb, 2008 1 commit
  3. 18 Feb, 2008 1 commit
    • Jeremy Kerr's avatar
      [POWERPC] spufs: fix scheduler starvation by idle contexts · 4ef11014
      Jeremy Kerr authored
      2.6.25 has a regression where we can starve the scheduler by creating
      (N_SPES+1) contexts, then running them one at a time.
      
      The final context will never be run, as the other contexts are loaded on
      the SPEs, none of which are repoted as free (ie, spu->alloc_state !=
      SPU_FREE), so spu_get_idle() doesn't give us a spu to run on. Because
      all of the contexts are stopped, none are descheduled by the scheduler
      tick, as spusched_tick returns if spu_stopped(ctx).
      
      This change replaces the spu_stopped() check with checking for SCHED_IDLE
      in ctx->policy. We set a context's policy to SCHED_IDLE when we're not
      in spu_run(). We also favour SCHED_IDLE contexts when looking for contexts
      to unbind, but leave their timeslice intact for later resumption.
      
      This patch fixes the following test in the spufs-testsuite:
        tests/20-scheduler/02-yield-starvation
      Signed-off-by: default avatarJeremy Kerr <jk@ozlabs.org>
      4ef11014
  4. 15 Feb, 2008 36 commits