From: "Fernando Luis Vázquez Cao" <fernando@oss.ntt.co.jp>
To: Keith Owens <kaos@ocs.com.au>
Cc: akpm@osdl.org, James.Bottomley@steeleye.com,
"Eric W. Biederman" <ebiederm@xmission.com>,
fastboot@lists.osdl.org, linux-kernel@vger.kernel.org,
ak@suse.de
Subject: Re: [Fastboot] [PATCH 1/3] stack overflow safe kdump (2.6.18-rc1-i386) - safe_smp_processor_id
Date: Mon, 10 Jul 2006 19:15:50 +0900 [thread overview]
Message-ID: <1152526550.3003.24.camel@localhost.localdomain> (raw)
In-Reply-To: <5742.1152520068@ocs3.ocs.com.au>
Hi Keith,
Thank you for the comments.
On Mon, 2006-07-10 at 18:27 +1000, Keith Owens wrote:
> Fernando Luis Vazquez Cao (on Mon, 10 Jul 2006 16:50:52 +0900) wrote:
> >On the event of a stack overflow critical data that usually resides at
> >the bottom of the stack is likely to be stomped and, consequently, its
> >use should be avoided.
> >
> >In particular, in the i386 and IA64 architectures the macro
> >smp_processor_id ultimately makes use of the "cpu" member of struct
> >thread_info which resides at the bottom of the stack. x86_64, on the
> >other hand, is not affected by this problem because it benefits from
> >the use of the PDA infrastructure.
> >
> >To circumvent this problem I suggest implementing
> >"safe_smp_processor_id()" (it already exists in x86_64) for i386 and
> >IA64 and use it as a replacement for smp_processor_id in the reboot path
> >to the dump capture kernel. This is a possible implementation for i386.
>
> I agree with avoiding the use of thread_info when the stack might be
> corrupt. However your patch results in reading apic data and scanning
> NR_CPU sized tables for each IPI that is sent, which will slow down the
> sending of all IPIs, not just dump.
This patch only affects IPIs sent using send_IPI_allbutself which is
rarely called, so the impact in performance should be negligible.
> It would be far cheaper to define
> a per-cpu variable containing the logical cpu number, set that variable
> once as each cpu is brought up and just read it in cases where you
> might not trust the integrity of struct thread_info. safe_smp_processor_id()
> resolves to just a read of the per cpu variable.
But to read a per-cpu variable you need to index the corresponding array
with processor id of the current CPU (see code below), but that is
precisely what we are trying to figure out. Anyway as
send_IPI_allbutself is not a fast path (correct if this assumption is
wrong) the current implementation of safe_smp_processor_id should be
fine.
#define get_cpu_var(var) (*({ preempt_disable();
&__get_cpu_var(var); }))
#define __get_cpu_var(var) per_cpu(var, smp_processor_id())
Am I missing something obvious?
Regards,
Fernando
next prev parent reply other threads:[~2006-07-10 10:15 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-10 7:50 [PATCH 1/3] stack overflow safe kdump (2.6.18-rc1-i386) - safe_smp_processor_id Fernando Luis Vázquez Cao
2006-07-10 8:27 ` [Fastboot] " Keith Owens
2006-07-10 10:15 ` Fernando Luis Vázquez Cao [this message]
2006-07-10 11:37 ` Eric W. Biederman
2006-07-11 4:21 ` Fernando Luis Vázquez Cao
2006-07-11 4:44 ` Fernando Luis Vázquez Cao
2006-07-11 4:55 ` Keith Owens
2006-07-11 6:15 ` Fernando Luis Vázquez Cao
2006-07-11 6:25 ` Keith Owens
2006-07-10 12:04 ` Keith Owens
2006-07-11 6:40 ` Fernando Luis Vázquez Cao
2006-07-10 14:16 ` James Bottomley
2006-07-10 18:20 ` Eric W. Biederman
2006-07-10 20:58 ` James Bottomley
2006-07-11 3:42 ` Eric W. Biederman
2006-07-11 12:36 ` James Bottomley
2006-07-11 19:41 ` Eric W. Biederman
2006-07-11 6:21 ` [Fastboot] " Fernando Luis Vázquez Cao
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=1152526550.3003.24.camel@localhost.localdomain \
--to=fernando@oss.ntt.co.jp \
--cc=James.Bottomley@steeleye.com \
--cc=ak@suse.de \
--cc=akpm@osdl.org \
--cc=ebiederm@xmission.com \
--cc=fastboot@lists.osdl.org \
--cc=kaos@ocs.com.au \
--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