From owner-freebsd-current Mon Jul 29 11:20:17 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 C7C9237B400 for ; Mon, 29 Jul 2002 11:20:11 -0700 (PDT) Received: from sccrmhc02.attbi.com (sccrmhc02.attbi.com [204.127.202.62]) by mx1.FreeBSD.org (Postfix) with ESMTP id 359A143E4A for ; Mon, 29 Jul 2002 11:20:11 -0700 (PDT) (envelope-from julian@elischer.org) Received: from InterJet.elischer.org ([12.232.206.8]) by sccrmhc02.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020729182010.GIPE221.sccrmhc02.attbi.com@InterJet.elischer.org>; Mon, 29 Jul 2002 18:20:10 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id LAA29162; Mon, 29 Jul 2002 11:07:34 -0700 (PDT) Date: Mon, 29 Jul 2002 11:07:34 -0700 (PDT) From: Julian Elischer To: Mark Santcroos Cc: Seigo Tanimura , current@FreeBSD.ORG Subject: Re: A fix of recent bugs in swapping in/out a process In-Reply-To: <20020729121728.GA537@laptop.6bone.nl> Message-ID: MIME-Version: 1.0 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 great.. looks like it's a commit... On Mon, 29 Jul 2002, Mark Santcroos wrote: > Hi, > > Just want to let you know that this patch fixes the 'fault on nofault > entry' panics I had. > > It was very easily reproducable with: > --- > char *buf; int n=0; > buf=(char *)malloc(1); > for(;;) > buf=(char *)realloc(buf,n++*1024*1024); > --- > > Ran some tests now and as said it didn't happen again. > > Thanks alot. > > Mark > > > On Sun, Jul 28, 2002 at 09:51:57PM +0900, Seigo Tanimura wrote: > > 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 > > -- > Mark Santcroos RIPE Network Coordination Centre > http://www.ripe.net/home/mark/ New Projects Group/TTM > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-current" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message