linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Richard B. Johnson" <root@chaos.analogic.com>
To: Roland Dreier <roland@topspin.com>
Cc: "Jonathan Lundell" <linux@lundell-bros.com>,
	"Jörn Engel" <joern@wohnheim.fh-wedel.de>,
	"Linux kernel" <linux-kernel@vger.kernel.org>
Subject: Re: top stack (l)users for 2.5.69
Date: Wed, 7 May 2003 15:30:40 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.53.0305071523010.13724@chaos> (raw)
In-Reply-To: <52bryeppb3.fsf@topspin.com>

On Wed, 7 May 2003, Roland Dreier wrote:

> >>>>> "Richard" == Richard B Johnson <root@chaos.analogic.com> writes:
>
>     Richard> On Wed, 7 May 2003, Roland Dreier wrote: The kernel
>     Richard> stack, at least for ix86, is only one, set upon startup
>     Richard> at 8192 bytes above a label called init_task_unit. The
>     Richard> kernel must have a separate stack and, contrary to what
>     Richard> I've been reading on this list, it can't have more kernel
>     Richard> stacks than CPUs and, I don't see a separate stack
>     Richard> allocated for different CPUs.
>
>     Roland> This is total nonsense.  Please don't confuse matters by
>     Roland> spreading misinformation like this.  Every task has a
>     Roland> separate (8K) kernel stack.  Look at the implementation of
>     Roland> do_fork() and in particular alloc_task_struct().
>
>     Roland> If there were only one kernel stack, what do you think
>     Roland> would happen if a process went to sleep in kernel code?
>
>     Richard> No, No. That is a process stack. Every process has it's
>     Richard> own, entirely seperate stack. This stack is used only in
>     Richard> user mode. The kernel has it's own stack. Every time you
>     Richard> switch to kernel mode either by calling the kernel or by
>     Richard> a hardware interrupt, the kernel's stack is used.
>
> Again, this is nonsense and misinformation.  Look at do_fork() and
> alloc_task_struct().  Do you see how alloc_task_struct() is just
> defined to be __get_free_pages(GFP_KERNEL,1) for i386?  Do you
> understand that that just allocates two pages (8K) of kernel memory?
> Do you see that it is never mapped into userspace, and that anyway
> a userspace process can use far more than 8K of stack?
>
> That 8K of memory is used for the kernel stack for a particular
> process.  When a process makes a system call, that specific stack is
> used as the kernel stack.

I haven't got a clue why and when that code got added. It is
absolutely positively wasted and is not required for kernel system
calls nor interrupts since they all must operate in kernel mode
and, therefore, use the kernel stack.

>
>     Richard> When a task sleeps, it sleeps in kernel mode. The kernel
>     Richard> schedules other tasks until the sleeper has been
>     Richard> satisfied either by time or by event.
>
> Right.  Now think about where the kernel stack for the process that is
> sleeping in the kernel is kept.
>

It's the kernel, of course. The scheduler runs in the kernel under
the kernel stack, with the kernel data. It has nothing to do with
the original user once the user sleeps. The user's context was
saved, the kernel was set up, and the kernel will schedule other
tasks until the sleep time or the sleep_on even is complete.
At that time, (or thereafter), the kernel will schedule
the previously sleeping task, its context will be restored, and
it continues execution.

The context of a task (see entry.S) is completely defined by
its registers, including the hidden part of the segments
(selectors) that define priviledge.

>  - Roland
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
Why is the government concerned about the lunatic fringe? Think about it.


  reply	other threads:[~2003-05-07 19:15 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-07 13:20 top stack (l)users for 2.5.69 Jörn Engel
2003-05-07 13:45 ` Richard B. Johnson
2003-05-07 13:56   ` Jörn Engel
2003-05-07 14:16     ` Richard B. Johnson
2003-05-07 17:13       ` Jonathan Lundell
2003-05-07 17:40         ` Richard B. Johnson
2003-05-07 18:12           ` Roland Dreier
2003-05-07 18:28             ` Richard B. Johnson
2003-05-07 18:44               ` Timothy Miller
2003-05-07 18:46               ` Roland Dreier
2003-05-07 19:30                 ` Richard B. Johnson [this message]
2003-05-07 19:42                   ` Roland Dreier
2003-05-07 20:04                     ` Richard B. Johnson
2003-05-07 20:23                       ` Roland Dreier
2003-05-07 20:42                       ` Timothy Miller
2003-05-08  9:06                         ` Jörn Engel
2003-05-08 11:33                         ` Richard B. Johnson
2003-05-08 12:00                           ` Helge Hafting
2003-05-08 15:42                           ` Timothy Miller
2003-05-09  8:57                             ` Miles Bader
2003-05-09 16:50                               ` Timothy Miller
2003-05-08 16:47                           ` Davide Libenzi
2003-05-07 18:51               ` Davide Libenzi
2003-05-07 19:22                 ` Richard B. Johnson
2003-05-07 19:31                   ` Davide Libenzi
2003-05-07 19:39                   ` Hua Zhong
2003-05-07 21:47                 ` Martin J. Bligh
2003-05-08 10:29           ` David Howells
2003-05-07 17:55         ` Jörn Engel
2003-05-07 16:20           ` Martin J. Bligh
2003-05-07 19:01         ` Dave Hansen
2003-05-07 20:06           ` Jörn Engel
2003-05-07 20:14             ` Dave Hansen
2003-05-08  8:41               ` Jörn Engel
2003-05-08 16:51                 ` Dave Hansen
2003-05-08 22:12                   ` Jörn Engel
2003-05-07 21:30         ` Jesse Pollard
2003-05-07 21:54           ` Timothy Miller
2003-05-07 22:01             ` Jesse Pollard
2003-05-07 14:33     ` Torsten Landschoff
2003-05-07 14:47       ` William Lee Irwin III
2003-05-07 15:04         ` Torsten Landschoff
2003-05-07 16:01           ` William Lee Irwin III
2003-05-08 15:36             ` Ingo Oeser
2003-05-08 18:04               ` William Lee Irwin III
2003-05-07 15:23         ` Timothy Miller
2003-05-07 15:47           ` William Lee Irwin III
2003-05-07 16:49         ` Jörn Engel
2003-05-07 17:18           ` Davide Libenzi
2003-05-07 17:40             ` Jörn Engel
2003-05-07 18:35               ` Davide Libenzi
2003-05-07 19:45                 ` Jörn Engel
2003-05-07 18:23             ` William Lee Irwin III
2003-05-07 17:38           ` William Lee Irwin III
2003-05-07 17:47             ` Jörn Engel
2003-05-07 14:49       ` Richard B. Johnson
2003-05-07 18:36   ` Linus Torvalds
2003-05-07 19:17     ` Jeff Garzik
2003-05-07 20:38       ` Randy.Dunlap
2003-05-07 21:27         ` Marcus Alanen
2003-05-07 21:27           ` Randy.Dunlap
2003-05-08 15:10         ` Ingo Oeser
2003-05-08 17:12           ` Randy.Dunlap
2003-05-07 19:38 Chuck Ebbert
2003-05-08 14:08 Chuck Ebbert
2003-05-08 18:04 ` Jonathan Lundell
2003-05-08 19:05   ` Timothy Miller
2003-05-08 21:00     ` Jonathan Lundell

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=Pine.LNX.4.53.0305071523010.13724@chaos \
    --to=root@chaos.analogic.com \
    --cc=joern@wohnheim.fh-wedel.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@lundell-bros.com \
    --cc=roland@topspin.com \
    /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;
as well as URLs for NNTP newsgroup(s).