From owner-freebsd-smp Mon Nov 27 10:33: 7 2000 Delivered-To: freebsd-smp@freebsd.org Received: from pike.osd.bsdi.com (pike.osd.bsdi.com [204.216.28.222]) by hub.freebsd.org (Postfix) with ESMTP id 18A3337B4D7 for ; Mon, 27 Nov 2000 10:32:59 -0800 (PST) Received: from laptop.baldwin.cx (john@jhb-laptop.osd.bsdi.com [204.216.28.241]) by pike.osd.bsdi.com (8.11.1/8.9.3) with ESMTP id eARIWlC39789; Mon, 27 Nov 2000 10:32:51 -0800 (PST) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20001126110554.H69183@prism.flugsvamp.com> Date: Mon, 27 Nov 2000 10:32:59 -0800 (PST) From: John Baldwin To: Jonathan Lemon Subject: RE: patch to make bpf mpsafe Cc: smp@FreeBSD.org Sender: owner-freebsd-smp@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On 26-Nov-00 Jonathan Lemon wrote: > Attached is a patch to make bpf mpsafe (and also cleans up some cruft). > BPF happened to be the first subsystem called by ether_input, so was the > first thing that I looked at. > > 3 levels of mutexes are added: > > bpf_mtx - global to BPF, protects BPF interface list, device open > (bif_next, bif_ifp) > bpf interface mtx - protects per-interface descriptor list > (bd_next, bd_bif, ifp->if_bpf) > bpf descriptor mtx - protects fields in the individual descriptor. > > Locking order is top to bottom, but the hierarchy can be entered at > any point. > > Network drivers start by locking the interface mutex, then walking the > list, locking each descriptor as it is manipulated. > > User level code reading from the bpf descriptor sleeps on the descriptor > mutex. This has been lightly tested with an mpsafe network driver. > Comments welcome. Couple of things: - need to add the explicit lock order to the witness code :) - go ahead and kill the splimp()'s. If this is all they are protecting and they are now protected by mutexes, the spl()'s can die. They just obfuscate the code otherwise. -- John Baldwin -- http://www.FreeBSD.org/~jhb/ PGP Key: http://www.baldwin.cx/~john/pgpkey.asc "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message