From owner-freebsd-current@FreeBSD.ORG Thu Aug 13 16:54:05 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 0951B106566C for ; Thu, 13 Aug 2009 16:54:05 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outV.internet-mail-service.net (outv.internet-mail-service.net [216.240.47.245]) by mx1.freebsd.org (Postfix) with ESMTP id E36D78FC48 for ; Thu, 13 Aug 2009 16:54:04 +0000 (UTC) Received: from idiom.com (mx0.idiom.com [216.240.32.160]) by out.internet-mail-service.net (Postfix) with ESMTP id 7AB76240D; Thu, 13 Aug 2009 09:54:05 -0700 (PDT) X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e Received: from julian-mac.elischer.org (home.elischer.org [216.240.48.38]) by idiom.com (Postfix) with ESMTP id 1FAFE2D601D; Thu, 13 Aug 2009 09:54:04 -0700 (PDT) Message-ID: <4A84452B.4070306@elischer.org> Date: Thu, 13 Aug 2009 09:54:03 -0700 From: Julian Elischer User-Agent: Thunderbird 2.0.0.22 (Macintosh/20090605) MIME-Version: 1.0 To: Andrew Thompson References: <20090813073002.GA66860@citylink.fud.org.nz> In-Reply-To: <20090813073002.GA66860@citylink.fud.org.nz> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: 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: Thu, 13 Aug 2009 16:54:05 -0000 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] > > After the patch they can be seen as kernel threads. > > PID TID COMM TDNAME CPU PRI STATE WCHAN > 0 100000 kernel swapper 0 68 sleep sched > 0 100009 kernel firmware taskq 0 92 sleep - > 0 100020 kernel kqueue taskq 0 92 sleep - > 0 100021 kernel acpi_task_0 0 92 sleep - > 0 100022 kernel acpi_task_1 0 92 sleep - > 0 100023 kernel acpi_task_2 0 92 sleep - > 0 100027 kernel thread taskq 0 92 sleep - > 0 100031 kernel bwi0 taskq 0 16 sleep - > 0 100032 kernel bwi0 taskq 0 16 sleep - > 0 100106 kernel usbus0 0 20 sleep wmsg > 0 100107 kernel usbus0 0 16 sleep wmsg > 0 100108 kernel usbus0 0 20 sleep wmsg > 0 100109 kernel usbus0 0 20 sleep wmsg > [ ... ] > 0 100127 kernel usbus4 0 20 sleep wmsg > > > Andrew 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.) > > > > Index: dev/usb/usb_process.c > =================================================================== > --- dev/usb/usb_process.c (revision 196086) > +++ dev/usb/usb_process.c (working copy) > @@ -64,9 +64,9 @@ > > #if (__FreeBSD_version >= 800000) > #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) > + kthread_add((f), (s), NULL, (p), 0, 0, __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__) > Index: dev/usb/usb_process.h > =================================================================== > --- dev/usb/usb_process.h (revision 196086) > +++ dev/usb/usb_process.h (working copy) > @@ -49,7 +49,7 @@ struct usb_process { > struct cv up_cv; > struct cv up_drain; > > - struct proc *up_ptr; > + struct thread *up_ptr; > struct thread *up_curtd; > struct mtx *up_mtx; > > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"