From owner-freebsd-current Sun Jul 28 5:53: 2 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D980237B400 for ; Sun, 28 Jul 2002 05:53:00 -0700 (PDT) Received: from silver.carrots.uucp.r.dl.itc.u-tokyo.ac.jp (IP1A0644.kng.mesh.ad.jp [211.13.34.138]) by mx1.FreeBSD.org (Postfix) with ESMTP id 014F943E65 for ; Sun, 28 Jul 2002 05:52:59 -0700 (PDT) (envelope-from tanimura@r.dl.itc.u-tokyo.ac.jp) Received: from silver.carrots.uucp.r.dl.itc.u-tokyo.ac.jp (localhost [127.0.0.1]) by silver.carrots.uucp.r.dl.itc.u-tokyo.ac.jp (8.12.5/3.7W-carrots-Keikyu-Kurihama) with ESMTP id g6SCpvSH064272 ; Sun, 28 Jul 2002 21:52:17 +0900 (JST) Message-Id: <200207281252.g6SCpvSH064272@silver.carrots.uucp.r.dl.itc.u-tokyo.ac.jp> Date: Sun, 28 Jul 2002 21:51:57 +0900 From: Seigo Tanimura To: current@FreeBSD.org Subject: A fix of recent bugs in swapping in/out a process Cc: Seigo Tanimura User-Agent: Wanderlust/2.8.1 (Something) SEMI/1.14.3 (Ushinoya) FLIM/1.14.3 (=?ISO-8859-1?Q?Unebigory=F2mae?=) APEL/10.3 MULE XEmacs/21.1 (patch 14) (Cuyahoga Valley) (i386--freebsd) Organization: Digital Library Research Division, Information Techinology Centre, The University of Tokyo MIME-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG If you are having a trouble of a broken thread state (eg a thread with TDS_RUNQ on no run queue) or a mysterious page fault on a kernel memory (probably in mi_switch()), you may want to try my patch at: http://people.FreeBSD.org/~tanimura/patches/procswap.diff.gz In a nutshell, this patch fixes three bugs: 1. a thread with TDS_RUNQ on no run queue. This is due to wakeup() and wakeup_one() setting the state to a thread to TDS_RUNQ even if the thread has been swapped out. As a thread being or having been swapped out cannot be scheduled immediately, introduce a new thread state TDS_SWAPPED to note that. 2. a possible race condition for multiple threads to swap in a single process. Since faultin() may block (and likely to do so) without leaving any flags for a process being swapped in, more than one threads can call faultin() for the same process. Avoid this by adding a new process state flag PS_SWAPPINGIN to a process being swapped in. 3. a running thread being swapped out. Swapout_procs() and swapout() do not check the states of the threads in a process about to be swapped out. This causes the pcb and the kernel stack of a running thread being unmapped, resulting in a page fault in cpu_switch(). Do not swap out a process unless all of its threads are either in a run queue or sleeping. Eventually, it may become our option to swap out only threads that are safe to do so. -- Seigo Tanimura To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message