From owner-freebsd-smp Thu Dec 7 19:11:20 2000 From owner-freebsd-smp@FreeBSD.ORG Thu Dec 7 19:11:18 2000 Return-Path: Delivered-To: freebsd-smp@freebsd.org Received: from smtp05.primenet.com (smtp05.primenet.com [206.165.6.135]) by hub.freebsd.org (Postfix) with ESMTP id 7B55437B400; Thu, 7 Dec 2000 19:11:18 -0800 (PST) Received: (from daemon@localhost) by smtp05.primenet.com (8.9.3/8.9.3) id UAA14568; Thu, 7 Dec 2000 20:07:52 -0700 (MST) Received: from usr08.primenet.com(206.165.6.208) via SMTP by smtp05.primenet.com, id smtpdAAAiKaGBC; Thu Dec 7 20:07:45 2000 Received: (from tlambert@localhost) by usr08.primenet.com (8.8.5/8.8.5) id UAA02374; Thu, 7 Dec 2000 20:11:08 -0700 (MST) From: Terry Lambert Message-Id: <200012080311.UAA02374@usr08.primenet.com> Subject: Re: Netgraph and SMP To: brian@Awfulhak.org (Brian Somers) Date: Fri, 8 Dec 2000 03:11:08 +0000 (GMT) Cc: julian@elischer.org (Julian Elischer), brian@Awfulhak.org (Brian Somers), smp@FreeBSD.ORG, archie@FreeBSD.ORG In-Reply-To: <200012070201.eB721Yt44116@hak.lan.Awfulhak.org> from "Brian Somers" at Dec 07, 2000 02:01:33 AM X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: tlambert@usr08.primenet.com Sender: owner-freebsd-smp@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org > > > Inside it's own lock (preventing any other dependent modules from > > > appearing), it asks the module if it's ok to unload. > > > > > > This is obviously more tricky than it sounds. We've got to ensure > > > that if any character device entry points have been created > > > (make_dev() etc), we block the relevant entry points so that we can > > > ENODEV if the MOD_UNLOAD works. > > > > but what if the process has already entered the driver? > > Then it should hold a lock that fails in the kldload syscall when it > does a mutex_trylock() on it. Again, this is somewhere that a read/ > write mutex would be handy. kldunload ends up trying for the write > lock while driver entry points try for the read lock. In Solaris, the entry into the driver would hold a reference, which would result in the reference count being incremented. Only modules with a 0 reference count can be unloaded. This same mechanism is used for vnodes, and for modules on which other modules depend. It works well, ans is very light weight. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message