public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Brent Baccala <baccala@freesoft.org>
To: Petr Vandrovec <VANDROVE@vc.cvut.cz>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Do kernel threads need their own stack?
Date: Wed, 18 Jul 2001 12:04:52 -0400	[thread overview]
Message-ID: <3B55B3A4.5E266E7D@freesoft.org> (raw)
In-Reply-To: <8F87F416D97@vcnet.vc.cvut.cz>

Petr Vandrovec wrote:
> 
> On 18 Jul 01 at 3:16, Brent Baccala wrote:
> 
> > The first thing I notice is that this function refers not only to the
> > clone flags in ebx, but also to a "newsp" in ecx - and ecx went
> > completely unmentioned in kernel_thread()!  A disassembly of
> >
> > Anyway, I'm confused.  My analysis might be wrong, since I don't spend
> > that much time in the Linux kernel, but bottom line - doesn't
> > kernel_thread() need to allocate stack space for the child?  I mean,
> > even if everything else is shared, doesn't the child at least need it's
> > own stack?
> 
> ecx specifies where userspace stack lives, not kernel space one, and
> each process gets its own kernel stack automagically. As you must not
> ever return to userspace from kernel_thread(), it is not a problem.
> Because of exiting from kernel_thread() to userspace is not trivial
> task, I do not think that is worth of effort.

OK, now I see it.  The kernel stack lives at the top of the task
structure, which is allocated as a full page at the beginning of
do_fork(), then type cast down to a struct task_struct.  The copy_thread
code looks past the end of the task_struct and sets up esp0 to point to
the end of the page.

Thanks.

-- 
                                        -bwb

                                        Brent Baccala
                                        baccala@freesoft.org

==============================================================================
       For news from freesoft.org, subscribe to announce@freesoft.org:
   
mailto:announce-request@freesoft.org?subject=subscribe&body=subscribe
==============================================================================

  reply	other threads:[~2001-07-18 16:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-18 11:57 Do kernel threads need their own stack? Petr Vandrovec
2001-07-18 16:04 ` Brent Baccala [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-07-19 10:57 alad
2001-07-18  7:16 Brent Baccala

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3B55B3A4.5E266E7D@freesoft.org \
    --to=baccala@freesoft.org \
    --cc=VANDROVE@vc.cvut.cz \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox