From owner-freebsd-usb@FreeBSD.ORG Thu Dec 15 14:17:09 2011 Return-Path: Delivered-To: usb@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A6DFC106566B; Thu, 15 Dec 2011 14:17:09 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 3EF748FC0C; Thu, 15 Dec 2011 14:17:07 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id QAA29161; Thu, 15 Dec 2011 16:17:03 +0200 (EET) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1RbC7L-0002Lq-62; Thu, 15 Dec 2011 16:17:03 +0200 Message-ID: <4EEA015D.8020800@FreeBSD.org> Date: Thu, 15 Dec 2011 16:17:01 +0200 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:8.0) Gecko/20111206 Thunderbird/8.0 MIME-Version: 1.0 To: Hans Petter Selasky References: <4EE51CB5.1060505@FreeBSD.org> <4EE70A1F.8040406@FreeBSD.org> <4EE8C2CE.40909@FreeBSD.org> <201112142256.32526.hselasky@c2i.net> In-Reply-To: <201112142256.32526.hselasky@c2i.net> X-Enigmail-Version: undefined Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: usb@FreeBSD.org, freebsd-hackers@FreeBSD.org, John Baldwin , mdf@FreeBSD.org Subject: Re: kern_yield vs ukbd_yield X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Dec 2011 14:17:09 -0000 on 14/12/2011 23:56 Hans Petter Selasky said the following: > On Wednesday 14 December 2011 16:37:50 Andriy Gapon wrote: >> So, Hans Petter, do you recall any details of this problem? >> I am curious about which thread got starved by which. > > From what I know this was 100% reproducible. > > Remove the ukbd_yield() when at the mountroot prompt. Result: cannot type any > keys. No USB devices will enumerate! This hasn't satisfied my curiosity :) >> >> BTW, given your recent improvements to pause(9) what do you think about >> further extending it to also use DELAY(9) when kdb_active is set or when >> SCHEDULER_STOPPED() is true? > > I think this is a good idea. It already checks for "cold". USB usually doesn't > use this function though when polling. > >> Then, probably, pause(9) could be used for >> both branches in ukbd_do_poll and they could be collapsed together. Hmm... I looked at the history of ukbd.c (which I should have done from the very start) and I see two relevant revisions: http://svnweb.freebsd.org/base/head/sys/dev/usb/input/ukbd.c?r1=199816&r2=203896&pathrev=203896 http://svnweb.freebsd.org/base/head/sys/dev/usb/input/ukbd.c?r1=223755&r2=223989&pathrev=223989 So, first use of pause(9) was introduced to work around current broken syscons polling mechanism. Then pause(9) was replaced with the hand-rolled yield to fix a problem at shutdown, which supposedly was caused by times being stopped. None of the commits seems to be directly related to thread priorities. I suspect that even DELAY(9) could have worked in the place of the pause/yield. Also, I do not see any mentioning of the mountroot context in the commits. Not sure why I even assumed that it was relevant. BTW, maybe we should have a 'cold again' flag for late stages of system shutdown? So, all in all, I believe in the following two things: 1. kern_yield can be used instead of ukbd_yield with any argument 1.1. DELAY() can be used instead of ukbd_yield too 2. all that special code should not be needed once I commit the patches that I have recently posted to arch@ (I do intend to commit them). In that case the keyboard drivers would be properly put into the polling mode instead of the current situation where the polling mode is repeatedly entered and exited when kernel needs some input. Maybe you recall/know more than you wrote above and I have missed something obvious that you can point out? -- Andriy Gapon