mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dou Liyang <douly.fnst@cn.fujitsu.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: <x86@kernel.org>, <linux-kernel@vger.kernel.org>,
	<mingo@kernel.org>, <ebiederm@xmission.com>, <bhe@redhat.com>,
	<hpa@zytor.com>, <izumi.taku@jp.fujitsu.com>
Subject: Re: [RFC PATCH 0/6] Unify the Interrupt Mode and setup it as soon as possible
Date: Fri, 7 Apr 2017 17:39:04 +0800	[thread overview]
Message-ID: <71b049b0-1e4d-a885-91d3-03328cafb65f@cn.fujitsu.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1704060955460.1716@nanos>

Hi Thomas,

At 04/06/2017 04:43 PM, Thomas Gleixner wrote:
> On Wed, 29 Mar 2017, Dou Liyang wrote:
>> The purpose of this patchset is Unifing these setup steps and executing as
>> soon as possible as follows:
>>
>>    start_kernel
>> ---------------+
>> |
>> |
>> |
>> |     init_IRQ
>> +---->---+----+
>> |        |
>> |        |      +--------------------+
>> |        +----> | 4. init_bsp_APIC   |
>> |               +--------------------+
>> v
>>
>> By the way, Also fix a bug about kexec[3].
>>
>>
>> Some doubts, need help:
>>
>> 1. Patchset has influence on IOMMU in enable_IR_x2apic(). Not sure
>> it can be in advance?
>
> That should work.
>

Got it. Thanks very much.

>> 2. Due to
>>
>> Commit 8c3ba8d04924 ("x86, apic: ack all pending irqs when crashed/on kexec")
>>
>>  ..., patchset also needs TSC and uses the "cpu_khz" in setup_local_APIC().
>> And a warning[4] will be triggered when crashed/on kexec. Not sure how to
>> modify?
>
> The local APIC timer initialization cannot be run from init_IRQ().
>

Yes, I think so.

> The problem here is that CPU and TSC frequency calibration depends on the
> PIT/HPET interrupt (irq 0) working for machines which cannot calibrate via
> MSR/CPUID or if fast calibration via PIT fails.
>

Yes, we use the CPU frequency and tsc before we calibrate them.

> So we need to split that initialization into several parts:
>
> 1) Set up the APIC/IOAPIC (including testing whether the timer interrupt
>    works)
>
> 2) Calibrate TSC
>
> 3) Set up the local APIC timer
>

Yes, correct. the patchset has splited the initialization like that.
And I don't change anything in part 2 to reduce the impact.

For the problem above, the reason is:

When do part 1 in dump-capture kernel, need clear ISR for the pending
interrupt from previous kernel, and use CPU frequency and TSC for
calculating the maximum number of cycles.

But, the CPU frequency and TSC is calibrated in part 2 late than part 1.

So, in part 1, the CPU frequency is 0, and calibrate a wrong maximum
loops.

I try to replace the loops calibration with a new way, which has
nothing to do with TSC, such as set a fixed value for max_loops. Is
that OK?

Or, may need do some work in part 1, 2, re-split the initialization.


Here is the code for clearing ISR:

unsigned long long tsc = 0, ntsc;
	long long max_loops = cpu_khz ? cpu_khz : 1000000;

	if (boot_cpu_has(X86_FEATURE_TSC))
		tsc = rdtsc();
......
......

	do {
		queued = 0;
		for (i = APIC_ISR_NR - 1; i >= 0; i--)
			queued |= apic_read(APIC_IRR + i*0x10);

		for (i = APIC_ISR_NR - 1; i >= 0; i--) {
			value = apic_read(APIC_ISR + i*0x10);
			for (j = 31; j >= 0; j--) {
				if (value & (1<<j)) {
					ack_APIC_irq();
					acked++;
				}
			}
		}
		if (acked > 256) {
			printk(KERN_ERR "LAPIC pending interrupts after %d EOI\n",
			       acked);
			break;
		}
		if (queued) {
			if (boot_cpu_has(X86_FEATURE_TSC) && cpu_khz) {
				ntsc = rdtsc();
				max_loops = (cpu_khz << 10) - (ntsc - tsc);
			} else
				max_loops--;
		}
	} while (queued && max_loops > 0);
	WARN_ON(max_loops <= 0);
... ...


Thanks,
	Liyang.

> Thanks,
>
> 	tglx
>
>
>

      reply	other threads:[~2017-04-07  9:39 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-29 14:55 Dou Liyang
2017-03-29 14:55 ` [RFC PATCH 1/6] x86/apic: Replace init_bsp_APIC() with apic_virture_wire_mode_setup() Dou Liyang
2017-04-05 10:43   ` Thomas Gleixner
2017-04-05 10:50     ` Thomas Gleixner
2017-04-06  1:37       ` Dou Liyang
2017-04-06  1:32     ` Dou Liyang
2017-03-29 14:55 ` [RFC PATCH 2/6] x86/apic: Construct a framework for setuping APIC mode as soon as possible Dou Liyang
2017-04-05 11:46   ` Thomas Gleixner
2017-04-06  2:21     ` Dou Liyang
2017-03-29 14:55 ` [RFC PATCH 3/6] x86/apic: Extract APIC timer related code from apic_bsp_setup() Dou Liyang
2017-04-05 11:56   ` Thomas Gleixner
2017-04-07  7:51     ` Dou Liyang
2017-03-29 14:55 ` [RFC PATCH 4/6] x86/apic: Make the APIC mode setup earlier for SMP-capable system Dou Liyang
2017-03-29 14:55 ` [RFC PATCH 5/6] x86/apic: Make the APIC mode setup earlier for UP system Dou Liyang
2017-03-29 14:55 ` [RFC PATCH 6/6] x86/apic: Remove the apic_virture_wire_mode_setup() Dou Liyang
2017-03-30  2:08 ` [RFC PATCH 0/6] Unify the Interrupt Mode and setup it as soon as possible Baoquan He
2017-03-30  3:03   ` Dou Liyang
2017-03-30  3:09     ` Dou Liyang
2017-03-30  4:10       ` Baoquan He
2017-04-06  8:43 ` Thomas Gleixner
2017-04-07  9:39   ` Dou Liyang [this message]

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=71b049b0-1e4d-a885-91d3-03328cafb65f@cn.fujitsu.com \
    --to=douly.fnst@cn.fujitsu.com \
    --cc=bhe@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=hpa@zytor.com \
    --cc=izumi.taku@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@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

all inboxes | Powered by JetHome®