From owner-freebsd-current@FreeBSD.ORG Sat Aug 1 04:30:27 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D519F1065670; Sat, 1 Aug 2009 04:30:27 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe13.swip.net [212.247.155.129]) by mx1.freebsd.org (Postfix) with ESMTP id DCCE88FC13; Sat, 1 Aug 2009 04:30:26 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.0 c=1 a=MnI1ikcADjEx7bvsp0jZvQ==:17 a=8kQB0OdkAAAA:8 a=qEcMWUDgfxFaQRTBXzsA:9 a=RX0rIitqhay-q9UQlykA:7 a=WKOd1NfXfDEs-i0xZgw_Qs78o3cA:4 a=9aOQ2cSd83gA:10 a=F3mTYvap6oFrulBc:21 a=_Q7Bef1J11YbE_uE:21 Received: from [188.126.201.140] (account mc467741@c2i.net HELO laptop.adsl.tele2.no) by mailfe13.swip.net (CommuniGate Pro SMTP 5.2.13) with ESMTPA id 900305645; Sat, 01 Aug 2009 06:30:25 +0200 From: Hans Petter Selasky To: freebsd-current@freebsd.org Date: Sat, 1 Aug 2009 06:30:19 +0200 User-Agent: KMail/1.11.4 (FreeBSD/8.0-BETA2; KDE/4.2.4; i386; ; ) References: <3bbf2fe10907310759o3be1f565t4122fcd66c4531f4@mail.gmail.com> <200907311919.26913.hselasky@c2i.net> <4e6cba830907311917j5d3c0eb6u7f7b1099d3acd504@mail.gmail.com> In-Reply-To: <4e6cba830907311917j5d3c0eb6u7f7b1099d3acd504@mail.gmail.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200908010630.21366.hselasky@c2i.net> Cc: Attilio Rao , Peter Holm , Giovanni Trematerra Subject: Re: [PATCH] Newbus locking X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Aug 2009 04:30:28 -0000 On Saturday 01 August 2009 04:17:42 Giovanni Trematerra wrote: > > On Fri, Jul 31, 2009 at 7:19 PM, Hans Petter Selasky > > wrote: > > > > > > I'm not saying that your approach will not work or that it is wrong. I'm > > saying that it is not fast enough. Your patch affects the boottime, in a > > negative way. > > I tested a patch for a while. I didn't notice any slow down in boot time. > Well, I haven't measured it but I can't see any noticeable difference > even booting from an USB key. Hi, We are talking about some seconds. Store the "ticks" varible in "usb_attach()" in sys/dev/usb/controller/usb_controller.c and print out the difference every time "usb_bus_explore()" is called having "if (bus->bus_roothold != NULL)". Different motherboards have different number of ports. Some have just two ports others have seven or more. The boot time is after the proposed newbus lock patch, proportional to the total number of ports including HUBs. I'm gone for the weekend and back on Sunday evening. No e-mails will be answered until then. Attilio: Your newbus_lock() must be moved into usb_probe_and_attach(), and maybe in usb_suspend_resume(). newbus_lock() should be locked always after "udev->default_sx + 1" in usb_device.c. "udev->default_sx + 1" is the lock protecting enumeration on a per-device level. Try on a usb device: usbconfig -u XXX -a YYY set_config 255 Then: usbconfig -u XXX -a YYY set_config 0 And I think you will have a prompt panic, because the newbus lock is not locked. > > I have to be honest, I don't understand the patch but any comments on > performance without an evident profiling seems to me a > "premature optimization" that is known to be the root of all devils (D. > Knuth) BTW: Why do none of the device_get_xxx() functions not have newbus lock assertions in them? --HPS