From owner-freebsd-current@FreeBSD.ORG Fri Aug 21 12:57:46 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 941A21065690; Fri, 21 Aug 2009 12:57:46 +0000 (UTC) (envelope-from andy@fud.org.nz) Received: from mail-fx0-f210.google.com (mail-fx0-f210.google.com [209.85.220.210]) by mx1.freebsd.org (Postfix) with ESMTP id CBF528FC52; Fri, 21 Aug 2009 12:57:45 +0000 (UTC) Received: by fxm6 with SMTP id 6so423880fxm.43 for ; Fri, 21 Aug 2009 05:57:44 -0700 (PDT) Received: by 10.103.84.25 with SMTP id m25mr456647mul.111.1250859463628; Fri, 21 Aug 2009 05:57:43 -0700 (PDT) Received: from ?27.237.21.69? (93-47-1-139.ip110.fastwebnet.it [93.47.1.139]) by mx.google.com with ESMTPS id y6sm10006113mug.40.2009.08.21.05.57.41 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 21 Aug 2009 05:57:42 -0700 (PDT) From: Andrew Thompson To: Julian Elischer In-Reply-To: <4A84452B.4070306@elischer.org> X-Mailer: iPod Mail (7A341) References: <20090813073002.GA66860@citylink.fud.org.nz> <4A84452B.4070306@elischer.org> Message-Id: <1503C8A3-8B3C-4AE3-BC11-5A0B30F91121@fud.org.nz> Mime-Version: 1.0 (iPod Mail 7A341) Date: Fri, 21 Aug 2009 14:56:27 +0200 X-Mailman-Approved-At: Fri, 21 Aug 2009 14:16:43 +0000 Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: "current@freebsd.org" , Andrew Thompson , 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, 21 Aug 2009 12:57:46 -0000 On 13/08/2009, at 18:54, 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] >> 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.) I have found a problem with this use of kproc_kthread_add where all the threads can exit (unload all hci modules) and the proc exits. On the next thread add it panics on a stale proc pointer. It may be easier just to use kthread_create which adds on proc0. Andrew