From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Rick Tao <tao_rick@yahoo.com>
Cc: linuxppc-dev@lists.ozlabs.org
Subject: Re: Possible kernel stack overflow due to fast interrupts
Date: Fri, 15 Oct 2010 10:57:13 +1100 [thread overview]
Message-ID: <1287100633.2205.80.camel@pasglop> (raw)
In-Reply-To: <174398.42321.qm@web50405.mail.re2.yahoo.com>
On Thu, 2010-10-14 at 13:45 -0700, Rick Tao wrote:
> Hi, all,
.../...
> In the context of task A
> a. NIP would point to the instruction after switch_to().
> b. MSR_EE is enabled in the call trace (finish_task_switch -->finish_lock_switch-->spin_unlock_irq)
> c. do something that would trigger an interrupt later on (such as timer)
> d. call schedule() for context switch to task B.
> In this step,
> task B's stack is popped INT_FRAME_SIZE size for context restore.
> Note that task B's ksp = X - INT_FRAME_SIZE
>
> In the context of task B again
> a1. similar to step "a" above
>
> b1. similar to step "b" above
> c1. interrupt occurs, go to step "1" above, and repeat!!!
>
> As you can see, task B's kernel stack space is reduced by INT_FRAME_SIZE
> on each loop. It will eventually overflow.
So if I follow you correctly, you are worried that by the time execution
resumes in B, and before it pops the second frame off, it might get
another interrupt and re-preempt...
Now unless I missed something, that cannot happen because
preempt_schedule_irq() does increment the preempt count:
add_preempt_count(PREEMPT_ACTIVE);
local_irq_enable();
schedule();
local_irq_disable();
sub_preempt_count(PREEMPT_ACTIVE);
Which means that it won't preempt again in finish_task_switch, and so
will eventually come back, turn EE back off, and pop off the stack
frame.
Or am I missing something ?
Cheers,
Ben.
next prev parent reply other threads:[~2010-10-14 23:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-14 20:45 Possible kernel stack overflow due to fast interrupts Rick Tao
2010-10-14 23:57 ` Benjamin Herrenschmidt [this message]
2010-10-15 19:13 ` Rick Tao
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=1287100633.2205.80.camel@pasglop \
--to=benh@kernel.crashing.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=tao_rick@yahoo.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).