Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761389AbdDSJFi (ORCPT ); Wed, 19 Apr 2017 05:05:38 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:29089 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1761154AbdDSJFg (ORCPT ); Wed, 19 Apr 2017 05:05:36 -0400 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="17913903" From: Dou Liyang To: , CC: , , , , , , Dou Liyang Subject: [RFC PATCH v2 00/12] Unify interrupt mode and setup it as soon as possible Date: Wed, 19 Apr 2017 17:05:14 +0800 Message-ID: X-Mailer: git-send-email 2.5.5 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.106] X-yoursite-MailScanner-ID: 513EC47CE256.A18BD X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: douly.fnst@cn.fujitsu.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3541 Lines: 110 According to Ingo's and Eric's advice[1,2], Try my best to optimize the init of interrupt delivery mode for x86. MP specification defines three different interrupt modes as follows: 1. PIC Mode 2. Virtual Wire Mode 3. Symmetric I/O Mode Currently, in kernel, 1. Setup Virtual Wire Mode during IRQ initialization( step 1 in the following figure). 2. Enable and Setup Symmetric I/O Mode either during the SMP-capable system prepares CPUs(step 2) or during the UP system initializes itself(step 3). start_kernel +---------------+ | +--> ....... | | setup_arch +--> +-------+ | | init_IRQ +-> +--+-----+ | | init_ISA_irqs | +------> +-+--------+ | | +----------------+ +---> +------> | 1.init_bsp_APIC| | ....... +----------------+ +---> | rest_init +--->---+-----+ | | kernel_init | +> ----+-----+ | | kernel_init_freeable | +-> ----+-------------+ | | smp_prepare_cpus | +---> +----+---------+ | | | +-------------------+ | | +-> |2. apic_bsp_setup | | | +-------------------+ | | v | smp_init +---> +---+----+ | +-------------------+ +--> |3. apic_bsp_setup | +-------------------+ The purpose of this patchset is unifying these setup steps and executing as soon as possible as follows: start_kernel ---------------+ | | | | x86_late_time_init +---->---+------------+ | | | | +------------------------+ | +----> | 4. init_interrupt_mode | | +------------------------+ v By the way, Also fix a bug about kexec[3]. [1]. https://lkml.org/lkml/2016/8/2/929 [2]. https://lkml.org/lkml/2016/8/1/506 [3]. https://lkml.org/lkml/2016/7/25/1118 Changes since V1: - Move the initialization from init_IRQ() to x86_late_time_init() - Use a threshold to refactor the check logic in timer_irq_works() - Rename the framework to a selector - Split two patches - Consistently start sentences with upper case letters - Fix some typos - Rewrite the changelog Dou Liyang (12): x86/apic: Replace init_bsp_APIC() with apic_virtual_wire_mode_setup() x86/apic: Construct a selector for the interrupt delivery mode x86/apic: Prepare for unifying the interrupt delivery modes setup x86/time: Initialize interrupt mode behind timer init x86/ioapic: Refactor the delay logic in timer_irq_works() x86/apic: Split local APIC timer setup from the APIC setup x86/apic: Move the logical APIC ID setup from apic_bsp_setup() x86/apic: Make the interrupt mode setup earlier for SMP-capable system x86/apic: Setup interrupt mode earlier in case of no SMP motherboard x86/apic: Make the interrupt mode setup earlier for UP system x86/apic: Mark the apic_interrupt_mode extern for refining code x86/apic: Remove the apic_virtual_wire_mode_setup() arch/x86/include/asm/apic.h | 14 +++- arch/x86/kernel/apic/apic.c | 183 +++++++++++++++++++++-------------------- arch/x86/kernel/apic/io_apic.c | 47 +++++++++-- arch/x86/kernel/irqinit.c | 3 - arch/x86/kernel/smpboot.c | 64 +++----------- arch/x86/kernel/time.c | 8 ++ 6 files changed, 168 insertions(+), 151 deletions(-) -- 2.5.5