Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Aug 2009 08:31:28 -0700
From:      Julian Elischer <julian@elischer.org>
To:        Andrew Thompson <andy@fud.org.nz>
Cc:        "current@freebsd.org" <current@freebsd.org>, Andrew Thompson <thompsa@FreeBSD.org>, Hans Petter Selasky <hselasky@c2i.net>
Subject:   Re: usb kthreads
Message-ID:  <4A8EBDD0.2030604@elischer.org>
In-Reply-To: <1503C8A3-8B3C-4AE3-BC11-5A0B30F91121@fud.org.nz>
References:  <20090813073002.GA66860@citylink.fud.org.nz>	<4A84452B.4070306@elischer.org> <1503C8A3-8B3C-4AE3-BC11-5A0B30F91121@fud.org.nz>

next in thread | previous in thread | raw e-mail | index | archive | help
Andrew Thompson wrote:
> On 13/08/2009, at 18:54, Julian Elischer <julian@elischer.org> 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.

just make the last one out clear the proc pointer.

> 
> Andrew
> _______________________________________________
> 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"




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4A8EBDD0.2030604>