From: ebiederm@xmission.com (Eric W. Biederman)
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: "Pan\, Jacob jun" <jacob.jun.pan@intel.com>,
"kerstin.jonsson" <kerstin.jonsson@ericsson.com>,
Andrew Morton <akpm@linux-foundation.org>,
"linux-kernel\@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"jbohac\@novell.com" <jbohac@novell.com>,
Yinghai Lu <yinghai@kernel.org>, "mingo\@elte.hu" <mingo@elte.hu>,
Avi Kivity <avi@redhat.com>, "trenn\@suse.de" <trenn@suse.de>,
Thomas Renninger <trenn@suse.de>
Subject: Re: [PATCH] x86 apic: Ack all pending irqs when crashed/on kexec - V5
Date: Wed, 16 Jun 2010 18:51:25 -0700 [thread overview]
Message-ID: <m17hlyo28y.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <4C196A2F.5010604@zytor.com> (H. Peter Anvin's message of "Wed\, 16 Jun 2010 17\:19\:59 -0700")
"H. Peter Anvin" <hpa@zytor.com> writes:
> On 06/16/2010 02:11 PM, Pan, Jacob jun wrote:
>>
>> W.R.T. the loop limits, is it possible to use a default max_loops value in
>> case when cpu_khz is not set? The reason is that on Moorestown platform
>> we need to do an early APIC setup before tsc_init(), so cpu_khz is 0 at the
>> time we setup local APIC. The result is that we hit WARN_ON(max_loops<= 0)
>> on Moorestown for early APIC setup.
So you get a nasty warning but the system still boots?
>> The early APIC setup is needed because Moorestown does not have a PIT and the
>> system timer interrupts are routed via IOAPIC.
>>
>
> Can't MRST install a quick ballpark value into cpu_khz?
Looking at the code the initialization order in init/main.c is:
early_irq_init()
init_IRQ()
init_timers()
time_init()
tsc_init()
local_irq_enable()
So arguably if we simply switched those lines around we could make
this work, as you must be initializing the tsc with interrupts
disabled.
That said given the current ordering it appears that using the tsc
in setup_local_APIC is just broken because if it is properly called
from init_IRQ() the code doesn't work properly.
The question is what do we consider more important the current code
initialization ordering, or virtual processors having such an expensive
apic_read that we need a 1 second timeout.
I think the virtual processor concern is silly. Most of the time
this loop should execute exactly once after having confirmed there
is nothing to do. On a bad day this loop should execute at most twice.
If the vitalization is too expensive that this loop cannot execute
twice, bailing out early is a correctness concern.
I think we should set max_loops to 5. Leave the WARN_ON, and call it
good.
Does the following patch work cleanly on Moorestown?
Eric
>From fc298618e87233de748c7a289f41bcc68ed8fc64 Mon Sep 17 00:00:00 2001
From: Eric W. Biederman <ebiederm@xmission.com>
Date: Wed, 16 Jun 2010 18:42:39 -0700
Subject: [PATCH] x86/apic: Don't use the tsc in setup_local_APIC
If everything is initialized in the order of init/main.c we should have:
init_IRQ()
setup_local_APIC()
time_init()
tsc_init()
local_irq_enable()
Which means the only reason the current use of the tsc in setup_local_APIC
works is because we are calling setup_local_APIC late on most x86
platforms.
The justification given for using a 1 second timeout on this loop
is because virtualized platforms have a very expensive apic_read().
Typically this loop should execute exactly once after confirming there
is nothing to do. On a bad day this loop should execute twice
after clearing the ISR and the IRR unacked irqs. If it is too
expensive to execute this loop twice on a virtualized platform
that is not our problem.
Let's set max_loops to 5. Which is more than enough and that
removes the need for messing with the tsc.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
arch/x86/kernel/apic/apic.c | 13 ++-----------
1 files changed, 2 insertions(+), 11 deletions(-)
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index c02cc69..d1a2b19 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -51,7 +51,6 @@
#include <asm/smp.h>
#include <asm/mce.h>
#include <asm/kvm_para.h>
-#include <asm/tsc.h>
unsigned int num_processors;
@@ -1154,11 +1153,7 @@ void __cpuinit setup_local_APIC(void)
{
unsigned int value, queued;
int i, j, acked = 0;
- unsigned long long tsc = 0, ntsc;
- long long max_loops = cpu_khz;
-
- if (cpu_has_tsc)
- rdtscll(tsc);
+ int max_loops = 5;
if (disable_apic) {
arch_disable_smp_support();
@@ -1229,11 +1224,7 @@ void __cpuinit setup_local_APIC(void)
acked);
break;
}
- if (cpu_has_tsc) {
- rdtscll(ntsc);
- max_loops = (cpu_khz << 10) - (ntsc - tsc);
- } else
- max_loops--;
+ max_loops--;
} while (queued && max_loops > 0);
WARN_ON(max_loops <= 0);
--
1.6.5.2.143.g8cc62
next prev parent reply other threads:[~2010-06-17 1:56 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-08 11:17 [PATCH] x86 apic: Ack all pending irqs when crashed/on kexec Thomas Renninger
2010-03-08 11:26 ` Avi Kivity
2010-03-08 11:34 ` [PATCH] x86 apic: Ack all pending irqs when crashed/on kexec - V3 Thomas Renninger
2010-03-08 11:26 ` [PATCH] x86 apic: Ack all pending irqs when crashed/on kexec Thomas Renninger
2010-03-08 11:34 ` Cyrill Gorcunov
2010-03-08 11:40 ` Thomas Renninger
2010-03-08 11:43 ` [PATCH] x86 apic: Ack all pending irqs when crashed/on kexec - V4 Thomas Renninger
2010-03-08 16:25 ` Kerstin Jonsson
2010-03-09 9:14 ` kerstin.jonsson
2010-03-09 10:52 ` [PATCH] x86 apic: Ack all pending irqs when crashed/on kexec - V5 Thomas Renninger
2010-03-19 1:18 ` Eric W. Biederman
2010-03-20 6:42 ` Eric W. Biederman
2010-03-22 11:28 ` kerstin.jonsson
2010-03-22 12:23 ` Eric W. Biederman
[not found] ` <43F901BD926A4E43B106BF17856F0755E7C393B9@orsmsx508.amr.corp.intel.com>
2010-06-17 0:19 ` H. Peter Anvin
2010-06-17 1:51 ` Eric W. Biederman [this message]
[not found] ` <43F901BD926A4E43B106BF17856F0755E7C3985D@orsmsx508.amr.corp.intel.com>
2010-06-17 17:00 ` H. Peter Anvin
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=m17hlyo28y.fsf@fess.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=akpm@linux-foundation.org \
--cc=avi@redhat.com \
--cc=hpa@zytor.com \
--cc=jacob.jun.pan@intel.com \
--cc=jbohac@novell.com \
--cc=kerstin.jonsson@ericsson.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=trenn@suse.de \
--cc=yinghai@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