Date: Wed, 13 Mar 2002 17:32:31 -0800 (PST) From: Alfred Perlstein <alfred@FreeBSD.org> To: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: cvs commit: src/sys/dev/bktr bktr_core.c src/sys/dev/kbd kbd.c src/sys/dev/snp snp.c src/sys/dev/sound/midi midibuf.c src/sys/dev/sound/pcm channel.c src/sys/dev/usb ums.c src/sys/i386/isa asc.c pcaudio.c src/sys/isa psm.c src/sys/kern ... Message-ID: <200203140132.g2E1WVl65776@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
alfred 2002/03/13 17:32:31 PST Modified files: sys/dev/bktr bktr_core.c sys/dev/kbd kbd.c sys/dev/snp snp.c sys/dev/sound/midi midibuf.c sys/dev/sound/pcm channel.c sys/dev/usb ums.c sys/i386/isa asc.c pcaudio.c sys/isa psm.c sys/kern sys_generic.c tty.c sys/sys proc.h selinfo.h systm.h Log: Fixes to make select/poll mpsafe. Problem: selwakeup required calling pfind which would cause lock order reversals with the allproc_lock and the per-process filedesc lock. Solution: Instead of recording the pid of the select()'ing process into the selinfo structure, actually record a pointer to the thread. To avoid dereferencing a bad address all the selinfo structures that are in use by a thread are kept in a list hung off the thread (protected by sellock). When a selwakeup occurs the selinfo is removed from that threads list, it is also removed on the way out of select or poll where the thread will traverse its list removing all the selinfos from its own list. Problem: Previously the PROC_LOCK was used to provide the mutual exclusion needed to ensure proper locking, this couldn't work because there was a single condvar used for select and poll and condvars can only be used with a single mutex. Solution: Introduce a global mutex 'sellock' which is used to provide mutual exclusion when recording events to wait on as well as performing notification when an event occurs. Interesting note: schedlock is required to manipulate the per-thread TDF_SELECT flag, however if given its own field it would not need schedlock, also because TDF_SELECT is only manipulated under sellock one doesn't actually use schedlock for syncronization, only to protect against corruption. Proc locks are no longer used in select/poll. Portions contributed by: davidc Revision Changes Path 1.118 +2 -2 src/sys/dev/bktr/bktr_core.c 1.28 +1 -3 src/sys/dev/kbd/kbd.c 1.71 +0 -2 src/sys/dev/snp/snp.c 1.6 +2 -2 src/sys/dev/sound/midi/midibuf.c 1.82 +1 -1 src/sys/dev/sound/pcm/channel.c 1.50 +2 -0 src/sys/dev/usb/ums.c 1.52 +1 -4 src/sys/i386/isa/asc.c 1.65 +2 -5 src/sys/i386/isa/pcaudio.c 1.45 +0 -2 src/sys/isa/psm.c 1.93 +112 -114 src/sys/kern/sys_generic.c 1.167 +2 -2 src/sys/kern/tty.c 1.207 +3 -0 src/sys/sys/proc.h 1.13 +8 -3 src/sys/sys/selinfo.h 1.163 +2 -0 src/sys/sys/systm.h To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200203140132.g2E1WVl65776>