From owner-cvs-src@FreeBSD.ORG Wed Feb 15 23:52:01 2006 Return-Path: X-Original-To: cvs-src@FreeBSD.org Delivered-To: cvs-src@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E5C4216A420; Wed, 15 Feb 2006 23:52:01 +0000 (GMT) (envelope-from davidxu@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7A52043D46; Wed, 15 Feb 2006 23:52:01 +0000 (GMT) (envelope-from davidxu@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k1FNq1s6056134; Wed, 15 Feb 2006 23:52:01 GMT (envelope-from davidxu@repoman.freebsd.org) Received: (from davidxu@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k1FNq1KU056133; Wed, 15 Feb 2006 23:52:01 GMT (envelope-from davidxu) Message-Id: <200602152352.k1FNq1KU056133@repoman.freebsd.org> From: David Xu Date: Wed, 15 Feb 2006 23:52:01 +0000 (UTC) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Cc: Subject: cvs commit: src/sys/sys proc.h sleepqueue.h src/sys/kern kern_condvar.c kern_kse.c kern_sig.c kern_synch.c kern_thread.c subr_sleepqueue.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Feb 2006 23:52:02 -0000 davidxu 2006-02-15 23:52:01 UTC FreeBSD src repository Modified files: sys/sys proc.h sleepqueue.h sys/kern kern_condvar.c kern_kse.c kern_sig.c kern_synch.c kern_thread.c subr_sleepqueue.c Log: Fix a long standing race between sleep queue and thread suspension code. When a thread A is going to sleep, it calls sleepq_catch_signals() to detect any pending signals or thread suspension request, if nothing happens, it returns without holding process lock or scheduler lock, this opens a race window which allows thread B to come in and do process suspension work, however since A is still at running state, thread B can do nothing to A, thread A continues, and puts itself into actually sleeping state, but B has never seen it, and it sits there forever until B is woken up by other threads sometimes later(this can be very long delay or never happen). Fix this bug by forcing sleepq_catch_signals to return with scheduler lock held. Fix sleepq_abort() by passing it an interrupted code, previously, it worked as wakeup_one(), and the interruption can not be identified correctly by sleep queue code when the sleeping thread is resumed. Let thread_suspend_check() returns EINTR or ERESTART, so sleep queue no longer has to use SIGSTOP as a hack to build a return value. Reviewed by: jhb MFC after: 1 week Revision Changes Path 1.54 +2 -9 src/sys/kern/kern_condvar.c 1.222 +1 -1 src/sys/kern/kern_kse.c 1.323 +11 -6 src/sys/kern/kern_sig.c 1.276 +2 -8 src/sys/kern/kern_synch.c 1.229 +4 -4 src/sys/kern/kern_thread.c 1.24 +76 -81 src/sys/kern/subr_sleepqueue.c 1.453 +1 -1 src/sys/sys/proc.h 1.7 +2 -4 src/sys/sys/sleepqueue.h