Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Jul 2002 01:22:35 +0900
From:      Seigo Tanimura <tanimura@r.dl.itc.u-tokyo.ac.jp>
To:        current@FreeBSD.org
Cc:        Seigo Tanimura <tanimura@r.dl.itc.u-tokyo.ac.jp>
Subject:   Re: A fix of recent bugs in swapping in/out a process
Message-ID:  <200207291622.g6TGMZpK037474@silver.carrots.uucp.r.dl.itc.u-tokyo.ac.jp>
In-Reply-To: <200207281252.g6SCpvSH064272@silver.carrots.uucp.r.dl.itc.u-tokyo.ac.jp>
References:  <200207281252.g6SCpvSH064272@silver.carrots.uucp.r.dl.itc.u-tokyo.ac.jp>

next in thread | previous in thread | raw e-mail | index | archive | help
A couple of updates:

- Optimize wakeup() and its friends; if a thread waken up is being
  swapped in, we do not have to ask for the scheduler thread to do
  that.

- Assert that a process is not swapped out in runq functions and
  swapout().


The update patchs is at:

http://people.FreeBSD.org/~tanimura/patches/procswap_2.diff.gz


On Sun, 28 Jul 2002 21:51:57 +0900,
  Seigo Tanimura <tanimura@r.dl.itc.u-tokyo.ac.jp> said:

Seigo> If you are having a trouble of a broken thread state (eg a thread with
Seigo> TDS_RUNQ on no run queue) or a mysterious page fault on a kernel
Seigo> memory (probably in mi_switch()), you may want to try my patch at:

Seigo> http://people.FreeBSD.org/~tanimura/patches/procswap.diff.gz

Seigo> In a nutshell, this patch fixes three bugs:


Seigo> 1. a thread with TDS_RUNQ on no run queue.

Seigo> This is due to wakeup() and wakeup_one() setting the state to a thread
Seigo> to TDS_RUNQ even if the thread has been swapped out.  As a thread
Seigo> being or having been swapped out cannot be scheduled immediately,
Seigo> introduce a new thread state TDS_SWAPPED to note that.


Seigo> 2. a possible race condition for multiple threads to swap in a single
Seigo>    process.

Seigo> Since faultin() may block (and likely to do so) without leaving any
Seigo> flags for a process being swapped in, more than one threads can call
Seigo> faultin() for the same process.  Avoid this by adding a new process
Seigo> state flag PS_SWAPPINGIN to a process being swapped in.


Seigo> 3. a running thread being swapped out.

Seigo> Swapout_procs() and swapout() do not check the states of the threads
Seigo> in a process about to be swapped out.  This causes the pcb and the
Seigo> kernel stack of a running thread being unmapped, resulting in a
Seigo> page fault in cpu_switch().  Do not swap out a process unless all of
Seigo> its threads are either in a run queue or sleeping.

Seigo> Eventually, it may become our option to swap out only threads that are
Seigo> safe to do so.

-- 
Seigo Tanimura <tanimura@r.dl.itc.u-tokyo.ac.jp> <tanimura@FreeBSD.org>

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200207291622.g6TGMZpK037474>