kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: valdis.kletnieks@vt.edu (valdis.kletnieks at vt.edu)
To: kernelnewbies@lists.kernelnewbies.org
Subject: function stack frames in the kernel
Date: Mon, 12 Nov 2018 02:09:32 -0500	[thread overview]
Message-ID: <96662.1542006572@turing-police.cc.vt.edu> (raw)
In-Reply-To: <CALS6=qWeafWvH+HZG=W3ojv8XabS=znXYzuoGYh67htnvQGnfw@mail.gmail.com>

On Mon, 12 Nov 2018 02:00:02 +0800, Carter Cheng said:
> Thanks for the reply but the link doesn't quite answer the question. I am
> wondering how the pointer is handled so that there is one per thread by the
> compiler. I perhaps was under the perhaps mistaken impression that the
> stack pointer frame pointer management inside the compiler makes certain
> assumptions in user space- but i am unsure how this applies to kernel space.

For regular function calls, a kernel stack works exactly the same as a function
stack in userspace (remember, it's the same compiler, and other tools like the
linker and gdb need to be able to understand function calls).

Where things are different are what happens if an interrupt or a call to
schedule() or enter/exit the kernel (or a few other similar situations I can't
remember at 2AM) causes a different thread to start running - for those cases,
there's architecture-dependent shim code (usually involving at least a bit of
assembler) to do the register swapping needed.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 486 bytes
Desc: not available
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20181112/de611c35/attachment.sig>

WARNING: multiple messages have this Message-ID (diff)
From: valdis.kletnieks@vt.edu
To: Carter Cheng <cartercheng@gmail.com>
Cc: augustocaringi@gmail.com, kernelnewbies@kernelnewbies.org
Subject: Re: function stack frames in the kernel
Date: Mon, 12 Nov 2018 02:09:32 -0500	[thread overview]
Message-ID: <96662.1542006572@turing-police.cc.vt.edu> (raw)
Message-ID: <20181112070932.Pgp6WF1kqq-Vu6mQ74euN1CXy4o64Gg5MnsbMpNn3EU@z> (raw)
In-Reply-To: <CALS6=qWeafWvH+HZG=W3ojv8XabS=znXYzuoGYh67htnvQGnfw@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1016 bytes --]

On Mon, 12 Nov 2018 02:00:02 +0800, Carter Cheng said:
> Thanks for the reply but the link doesn't quite answer the question. I am
> wondering how the pointer is handled so that there is one per thread by the
> compiler. I perhaps was under the perhaps mistaken impression that the
> stack pointer frame pointer management inside the compiler makes certain
> assumptions in user space- but i am unsure how this applies to kernel space.

For regular function calls, a kernel stack works exactly the same as a function
stack in userspace (remember, it's the same compiler, and other tools like the
linker and gdb need to be able to understand function calls).

Where things are different are what happens if an interrupt or a call to
schedule() or enter/exit the kernel (or a few other similar situations I can't
remember at 2AM) causes a different thread to start running - for those cases,
there's architecture-dependent shim code (usually involving at least a bit of
assembler) to do the register swapping needed.


[-- Attachment #1.2: Type: application/pgp-signature, Size: 486 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  parent reply	other threads:[~2018-11-12  7:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-11 17:03 function stack frames in the kernel Carter Cheng
2018-11-11 17:03 ` Carter Cheng
2018-11-11 17:55 ` Augusto Mecking Caringi
2018-11-11 17:55   ` Augusto Mecking Caringi
2018-11-11 18:00   ` Carter Cheng
2018-11-11 18:00     ` Carter Cheng
2018-11-12  7:09     ` valdis.kletnieks at vt.edu [this message]
2018-11-12  7:09       ` valdis.kletnieks
2018-11-12 16:43       ` Carter Cheng
2018-11-12 16:43         ` Carter Cheng

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=96662.1542006572@turing-police.cc.vt.edu \
    --to=valdis.kletnieks@vt.edu \
    --cc=kernelnewbies@lists.kernelnewbies.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;
as well as URLs for NNTP newsgroup(s).