kernel thread creation cleanup

Kostik Belousov kostikbel at gmail.com
Wed Apr 6 10:21:49 UTC 2011


On Tue, Apr 05, 2011 at 06:16:01PM -0700, Julian Elischer wrote:
> I was just looking in the thread creation code after most of a decade  
> NOT looking at it..
> boy we really need to go through there with a broom.. the cobwebs are 
> getting thick.
> Like we always call the code to put an upcall, even though we don't 
> have upcalls any more,
cpu_set_upcall() probably could be renamed to cpu_init_thread(),
and cpu_set_upcall_kse() is better named cpu_init_thread_for_user().

IMO, rename would only add a code churn.
> and we always create an trap frame on the stack even when we are 
> making kernel threads
> that don't need it, actually, come to think of it DOES fork even need 
> it? (need to go look)
Trap frame for the new thread that is going to usermode after fork is
definitely needed. Having fork trampoline executed for all threads is
good, because it provides a convenient single point which is passed by
all new threads.

> and we go through the fork trampoline even when we are doing kthread 
> creation and could just as well go
> directly to the final function directly.  (All of the above on amd64)..
> May be slighly different on other hardware, though much of it is 
> encoded in MI code so probably not.
> 
> 
> 
> This came from looking to see if I could somehow munge the stack to 
> convince kgdb to damn well stop at
> that point (still failed.  if anyone has ideas... :-)
Was it for amd64 ? I think the issue with kgdb is lack of the proper
dwarf annotations for trampoline.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20110406/c88b544e/attachment.pgp


More information about the freebsd-current mailing list