kern_yield vs ukbd_yield

Andriy Gapon avg at FreeBSD.org
Tue Dec 13 08:17:47 UTC 2011


on 13/12/2011 00:21 Andriy Gapon said the following:
> on 12/12/2011 21:09 Hans Petter Selasky said the following:
>> On Monday 12 December 2011 20:05:38 John Baldwin wrote:
>>>> Hi,
>>>>
>>>>
>>>>
>>>>> hselasky@ or someone else familiar with the various usb threads would
>>>>> have to answer that.
>>>>
>>>>
>>>>
>>>> The problem is only during init() where the init thread has highest
>>>> priority  and that doesn't allow other threads to run even if the
>>>> scheduler is
>>>
>>> running!
>>>
>>> Hmm, that should be fixed by lowering the relevant thread's priority.
>>> Do you mean thread0 (the one doing all the SYSINIT's or thread we create
>>> for init (pid 1) before it executes init?
>>
>> Yes, thread0. Correct!
> 
> Mmm, my short debugging session with qemu shows that it is actually pid 1:

And in the view of the below data I would like us to revisit this problem.
I looked over usb code and it seems that all usb threads are created with
priorities of either USB_PRI_MED or USB_PRI_HIGH, which translates to
PI_SWI(SWI_CAMBIO) and PI_SWI(SWI_NET).  These priorities should be in the
ithread range, so it's kind of surprising that the init thread (with PVM
priority) can cause troubles for them.

> Breakpoint 1, ukbd_do_poll (sc=0xffffff8000764000, wait=0 '\0') at
> /usr/src/sys/dev/usb/input/ukbd.c:403
> 403     {
> (kgdb) bt
> #0  ukbd_do_poll (sc=0xffffff8000764000, wait=0 '\0') at
> /usr/src/sys/dev/usb/input/ukbd.c:403
> #1  0xffffffff803ee57e in ukbd_check (kbd=Variable "kbd" is not available.
> ) at /usr/src/sys/dev/usb/input/ukbd.c:1418
> #2  0xffffffff803ee674 in ukbd_check_char (kbd=0xffffff8000764000) at
> /usr/src/sys/dev/usb/input/ukbd.c:1450
> #3  0xffffffff8035c794 in kbdmux_read_char (kbd=0xfffffe00021d2c00,
> wait=Variable "wait" is not available.
> ) at /usr/src/sys/dev/kbdmux/kbdmux.c:665
> #4  0xffffffff803bf4aa in scgetc (sc=0xffffffff81835dc0, flags=Variable "flags"
> is not available.
> ) at /usr/src/sys/dev/syscons/syscons.c:3373
> #5  0xffffffff803c2d03 in sc_cngetc (cd=Variable "cd" is not available.
> ) at /usr/src/sys/dev/syscons/syscons.c:1753
> #6  0xffffffff804ae489 in cncheckc () at /usr/src/sys/kern/kern_cons.c:402
> #7  0xffffffff804ae4c7 in cngetc () at /usr/src/sys/kern/kern_cons.c:383
> #8  0xffffffff804ae9a7 in cngets (cp=0xffffff8000326aa0 "", size=80, visible=1)
> at /usr/src/sys/kern/kern_cons.c:421
> #9  0xffffffff80594d4e in vfs_mountroot () at /usr/src/sys/kern/vfs_mountroot.c:490
> #10 0xffffffff804a6e65 in start_init (dummy=Variable "dummy" is not available.
> ) at /usr/src/sys/kern/init_main.c:683
> #11 0xffffffff804c5a9a in fork_exit (callout=0xffffffff804a6e00 <start_init>,
> arg=0x0, frame=0xffffff8000326c50) at /usr/src/sys/kern/kern_fork.c:995
> #12 0xffffffff806bb72e in fork_trampoline () at
> /usr/src/sys/amd64/amd64/exception.S:602
> #13 0x0000000000000000 in ?? ()
> (kgdb) p td->td_proc->p_pid
> $7 = 1
> (kgdb) p td->td_proc->p_comm
> $8 = "kernel", '\0' <repeats 13 times>
> (kgdb) p td->td_tid
> $9 = 100002
> 
> Also:
> (kgdb) p/d td->td_user_pri
> $10 = 139
> (kgdb) p/d td->td_base_pri
> $11 = 84
> 


-- 
Andriy Gapon


More information about the freebsd-usb mailing list