From owner-freebsd-current@FreeBSD.ORG Fri Aug 14 15:54:04 2009 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ECDE5106568C for ; Fri, 14 Aug 2009 15:54:03 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from pele.citylink.co.nz (pele.citylink.co.nz [202.8.44.226]) by mx1.freebsd.org (Postfix) with ESMTP id 8CE768FC69 for ; Fri, 14 Aug 2009 15:54:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by pele.citylink.co.nz (Postfix) with ESMTP id 60A20FFB9; Sat, 15 Aug 2009 03:54:02 +1200 (NZST) X-Virus-Scanned: Debian amavisd-new at citylink.co.nz Received: from pele.citylink.co.nz ([127.0.0.1]) by localhost (pele.citylink.co.nz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Bliits5-Hyic; Sat, 15 Aug 2009 03:53:57 +1200 (NZST) Received: from citylink.fud.org.nz (unknown [202.8.44.45]) by pele.citylink.co.nz (Postfix) with ESMTP; Sat, 15 Aug 2009 03:53:57 +1200 (NZST) Received: by citylink.fud.org.nz (Postfix, from userid 1001) id 6764911432; Sat, 15 Aug 2009 03:53:57 +1200 (NZST) Date: Fri, 14 Aug 2009 08:53:57 -0700 From: Andrew Thompson To: Julian Elischer Message-ID: <20090814155357.GA67039@citylink.fud.org.nz> References: <20090813073002.GA66860@citylink.fud.org.nz> <4A84452B.4070306@elischer.org> <1280352d0908140845j2709fdcfme317fab916606209@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1280352d0908140845j2709fdcfme317fab916606209@mail.gmail.com> User-Agent: Mutt/1.5.17 (2007-11-01) Cc: Kostik Belousov , current@freebsd.org, Hans Petter Selasky Subject: Re: usb kthreads 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: Fri, 14 Aug 2009 15:54:04 -0000 Julian Elischer wrote: > Andrew Thompson wrote: > > > > Hi, > > > > > > Here is an aesthetic patch to change the usb kernel processes to threads, > > this hides them from the usual 'ps' output. Please test and review. > > > > ?1290 ??? ?DL ? ? 0:00.00 [usbus0] > > ?[lots and lots more...] > > ?1309 ??? ?DL ? ? 0:00.00 [usbus4] > > > > use kproc_kthread_add() > to create a seoarate usb process and make all the threads belong to > that process. > (kproc_kthread_add() will create a new process the first time > and add more threads to it the more it is run.) Patch updated with the various feedback. PID TT STAT TIME COMMAND 0 ?? DLs 0:00.38 [kernel] 1 ?? ILs 0:00.01 /sbin/init -- 2 ?? DL 0:09.66 [g_event] 3 ?? DL 0:00.20 [g_up] 4 ?? DL 0:00.20 [g_down] ... 18 ?? DL 0:00.06 [acpi_thermal] 19 ?? DL 0:00.04 [usb] % procstat -t 19 PID TID COMM TDNAME CPU PRI STATE WCHAN 19 100040 usb usbus0 0 20 sleep - 19 100041 usb usbus0 0 16 sleep - 19 100042 usb usbus0 0 20 sleep - 19 100043 usb usbus0 0 20 sleep - Andrew Index: usb_process.c =================================================================== --- usb_process.c (revision 196086) +++ usb_process.c (working copy) @@ -63,10 +63,12 @@ #endif #if (__FreeBSD_version >= 800000) +static struct proc *usbproc; #define USB_THREAD_CREATE(f, s, p, ...) \ - kproc_create((f), (s), (p), RFHIGHPID, 0, __VA_ARGS__) -#define USB_THREAD_SUSPEND(p) kproc_suspend(p,0) -#define USB_THREAD_EXIT(err) kproc_exit(err) + kproc_kthread_add((f), (s), &usbproc, (p), RFHIGHPID, \ + 0, "usb", __VA_ARGS__) +#define USB_THREAD_SUSPEND(p) kthread_suspend(p,0) +#define USB_THREAD_EXIT(err) kthread_exit() #else #define USB_THREAD_CREATE(f, s, p, ...) \ kthread_create((f), (s), (p), RFHIGHPID, 0, __VA_ARGS__) @@ -207,8 +209,8 @@ usb_proc_create(struct usb_process *up, struct mtx TAILQ_INIT(&up->up_qhead); - cv_init(&up->up_cv, "wmsg"); - cv_init(&up->up_drain, "dmsg"); + cv_init(&up->up_cv, "-"); + cv_init(&up->up_drain, "usbdrain"); if (USB_THREAD_CREATE(&usb_process, up, &up->up_ptr, pmesg)) { Index: usb_process.h =================================================================== --- usb_process.h (revision 196086) +++ usb_process.h (working copy) @@ -49,7 +49,11 @@ struct usb_process { struct cv up_cv; struct cv up_drain; +#if (__FreeBSD_version >= 800000) + struct thread *up_ptr; +#else struct proc *up_ptr; +#endif struct thread *up_curtd; struct mtx *up_mtx;