From owner-freebsd-hackers@FreeBSD.ORG Mon Dec 12 08:03:57 2011 Return-Path: Delivered-To: hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CC9D3106564A; Mon, 12 Dec 2011 08:03:57 +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 B56BF8FC13; Mon, 12 Dec 2011 08:03:56 +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 KAA15030; Mon, 12 Dec 2011 10:03:55 +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 1Ra0ra-000Hye-Sz; Mon, 12 Dec 2011 10:03:54 +0200 Message-ID: <4EE5B56A.4000106@FreeBSD.org> Date: Mon, 12 Dec 2011 10:03:54 +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: mdf@FreeBSD.org References: <4EE51CB5.1060505@FreeBSD.org> In-Reply-To: X-Enigmail-Version: undefined Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: usb@FreeBSD.org, hackers@FreeBSD.org Subject: Re: kern_yield vs ukbd_yield X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Dec 2011 08:03:57 -0000 on 11/12/2011 23:48 mdf@FreeBSD.org said the following: > On Sun, Dec 11, 2011 at 1:12 PM, Andriy Gapon wrote: >> >> Does the following change do what I think that it does? >> Thank you! >> >> Author: Andriy Gapon >> Date: Thu Sep 1 16:50:13 2011 +0300 >> >> ukbd: drop local duplicate of kern_yield and use that instead >> >> diff --git a/sys/dev/usb/input/ukbd.c b/sys/dev/usb/input/ukbd.c >> index 086c178..8078cbb 100644 >> --- a/sys/dev/usb/input/ukbd.c >> +++ b/sys/dev/usb/input/ukbd.c >> @@ -399,33 +399,6 @@ ukbd_put_key(struct ukbd_softc *sc, uint32_t key) >> } >> >> static void >> -ukbd_yield(void) >> -{ >> - struct thread *td = curthread; >> - uint32_t old_prio; >> - >> - DROP_GIANT(); >> - >> - thread_lock(td); >> - >> - /* get current priority */ >> - old_prio = td->td_base_pri; >> - >> - /* set new priority */ >> - sched_prio(td, td->td_user_pri); >> - >> - /* cause a task switch */ >> - mi_switch(SW_INVOL | SWT_RELINQUISH, NULL); >> - >> - /* restore priority */ >> - sched_prio(td, old_prio); >> - >> - thread_unlock(td); >> - >> - PICKUP_GIANT(); >> -} >> - >> -static void >> ukbd_do_poll(struct ukbd_softc *sc, uint8_t wait) >> { >> >> @@ -439,7 +412,7 @@ ukbd_do_poll(struct ukbd_softc *sc, uint8_t wait) >> while (sc->sc_inputs == 0) { >> >> /* give USB threads a chance to run */ >> - ukbd_yield(); >> + kern_yield(-1); > > Not quite. > > 1) -1 should be spelled PRI_UNCHANGED, except ukbd_yield() uses > td_user_pri, but then puts it back again, so I think UNCHANGED is what > is meant. > 2) kern_yield() calls it a SW_VOL rather than SW_INVOL, which seems > the desired behaviour here anyways, since this is an explicit (i.e. > voluntary) yield. Thank you for the explanation. So would you say that the patch is OK? -- Andriy Gapon