* [patch 0/3] x86 apic series
@ 2009-10-13 20:07 Cyrill Gorcunov
2009-10-13 20:07 ` [patch 1/3] x86,apic: introduce NOOP apic driver Cyrill Gorcunov
` (2 more replies)
0 siblings, 3 replies; 16+ messages in thread
From: Cyrill Gorcunov @ 2009-10-13 20:07 UTC (permalink / raw)
To: mingo; +Cc: x86, yinghai, macro, linux-kernel
Hi,
here is apic NOOP splitted and one show-lapic (Yinghai
suggested it and implemented initial version, so I add
Suggested-by tag there).
Please review. And of course it should be widely/strongly
tested.
Any complains are welcome!
Cyrill
^ permalink raw reply [flat|nested] 16+ messages in thread* [patch 1/3] x86,apic: introduce NOOP apic driver 2009-10-13 20:07 [patch 0/3] x86 apic series Cyrill Gorcunov @ 2009-10-13 20:07 ` Cyrill Gorcunov 2009-10-14 8:17 ` [tip:x86/apic] x86, apic: Introduce the " tip-bot for Cyrill Gorcunov 2009-10-13 20:07 ` [patch 2/3] x86,apic -- use apic noop driver Cyrill Gorcunov 2009-10-13 20:07 ` [patch 3/3] x86,apic: limit apic dumping, introduce show_lapic setup option Cyrill Gorcunov 2 siblings, 1 reply; 16+ messages in thread From: Cyrill Gorcunov @ 2009-10-13 20:07 UTC (permalink / raw) To: mingo; +Cc: x86, yinghai, macro, linux-kernel, Cyrill Gorcunov [-- Attachment #1: x86-apic-noop-v2 --] [-- Type: text/plain, Size: 7602 bytes --] Introduce NOOP APIC driver. We should use it in case if apic was disabled due to hardware of software/firmware problems (including user requested to disable it case). The driver is attempting to catch any inappropriate apic operation call with warning issue. Also it is possible to use some apic operation like IPI calls, read/write without checking for apic presence which should make callers code easier. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> --- arch/x86/include/asm/apic.h | 2 arch/x86/kernel/apic/Makefile | 2 arch/x86/kernel/apic/apic_noop.c | 194 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 197 insertions(+), 1 deletion(-) Index: linux-2.6.git/arch/x86/include/asm/apic.h ===================================================================== --- linux-2.6.git.orig/arch/x86/include/asm/apic.h +++ linux-2.6.git/arch/x86/include/asm/apic.h @@ -488,6 +488,8 @@ static inline unsigned int read_apic_id( extern void default_setup_apic_routing(void); +extern struct apic apic_noop; + #ifdef CONFIG_X86_32 extern struct apic apic_default; Index: linux-2.6.git/arch/x86/kernel/apic/Makefile ===================================================================== --- linux-2.6.git.orig/arch/x86/kernel/apic/Makefile +++ linux-2.6.git/arch/x86/kernel/apic/Makefile @@ -2,7 +2,7 @@ # Makefile for local APIC drivers and for the IO-APIC code # -obj-$(CONFIG_X86_LOCAL_APIC) += apic.o probe_$(BITS).o ipi.o nmi.o +obj-$(CONFIG_X86_LOCAL_APIC) += apic.o apic_noop.o probe_$(BITS).o ipi.o nmi.o obj-$(CONFIG_X86_IO_APIC) += io_apic.o obj-$(CONFIG_SMP) += ipi.o Index: linux-2.6.git/arch/x86/kernel/apic/apic_noop.c ===================================================================== --- /dev/null +++ linux-2.6.git/arch/x86/kernel/apic/apic_noop.c @@ -0,0 +1,194 @@ +/* + * NOOP APIC driver. + * + * Does almost nothing and should be substituted by a real apic driver via + * probe routine. + * + * Though in case if apic is disabled (for some reason) we try + * to not uglify the caller's code and allow to call (some) apic routines + * like self-ipi, etc... and issue a warning if an operation is not allowed + */ + +#include <linux/threads.h> +#include <linux/cpumask.h> +#include <linux/module.h> +#include <linux/string.h> +#include <linux/kernel.h> +#include <linux/ctype.h> +#include <linux/init.h> +#include <linux/errno.h> +#include <asm/fixmap.h> +#include <asm/mpspec.h> +#include <asm/apicdef.h> +#include <asm/apic.h> +#include <asm/setup.h> + +#include <linux/smp.h> +#include <asm/ipi.h> + +#include <linux/interrupt.h> +#include <asm/acpi.h> +#include <asm/e820.h> + +/* + * some operations should never be reached with + * noop apic if it's not turned off, this mostly + * means the caller forgot to disable apic (or + * check the apic presence) before doing a call + */ +static void warn_apic_enabled(void) +{ + WARN_ONCE((cpu_has_apic || !disable_apic), + "APIC: Called for NOOP operation with apic enabled\n"); +} + +/* + * To check operations but do not bloat source code + */ +#define NOOP_FUNC(func) func { warn_apic_enabled(); } +#define NOOP_FUNC_RET(func, ret) func { warn_apic_enabled(); return ret; } + +NOOP_FUNC(static void noop_init_apic_ldr(void)) +NOOP_FUNC(static void noop_send_IPI_mask(const struct cpumask *cpumask, int vector)) +NOOP_FUNC(static void noop_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector)) +NOOP_FUNC(static void noop_send_IPI_allbutself(int vector)) +NOOP_FUNC(static void noop_send_IPI_all(int vector)) +NOOP_FUNC(static void noop_send_IPI_self(int vector)) +NOOP_FUNC_RET(static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip), -1) +NOOP_FUNC(static void noop_apic_write(u32 reg, u32 v)) +NOOP_FUNC(void noop_apic_wait_icr_idle(void)) +NOOP_FUNC_RET(static u32 noop_safe_apic_wait_icr_idle(void), 0) +NOOP_FUNC_RET(static u64 noop_apic_icr_read(void), 0) +NOOP_FUNC(static void noop_apic_icr_write(u32 low, u32 id)) +NOOP_FUNC_RET(static physid_mask_t noop_ioapic_phys_id_map(physid_mask_t phys_map), phys_map) +NOOP_FUNC_RET(static int noop_cpu_to_logical_apicid(int cpu), 1) +NOOP_FUNC_RET(static int noop_default_phys_pkg_id(int cpuid_apic, int index_msb), 0) +NOOP_FUNC_RET(static unsigned int noop_get_apic_id(unsigned long x), 0) + +static int noop_probe(void) +{ + /* should not ever be enabled this way */ + return 0; +} + +static int noop_apic_id_registered(void) +{ + warn_apic_enabled(); + return physid_isset(read_apic_id(), phys_cpu_present_map); +} + +static const struct cpumask *noop_target_cpus(void) +{ + warn_apic_enabled(); + + /* only BSP here */ + return cpumask_of(0); +} + +static unsigned long noop_check_apicid_used(physid_mask_t bitmap, int apicid) +{ + warn_apic_enabled(); + return physid_isset(apicid, bitmap); +} + +static unsigned long noop_check_apicid_present(int bit) +{ + warn_apic_enabled(); + return physid_isset(bit, phys_cpu_present_map); +} + +static void noop_vector_allocation_domain(int cpu, struct cpumask *retmask) +{ + warn_apic_enabled(); + if (cpu != 0) + pr_warning("APIC: Vector allocated for non-BSP cpu\n"); + cpumask_clear(retmask); + cpumask_set_cpu(cpu, retmask); +} + +int noop_apicid_to_node(int logical_apicid) +{ + warn_apic_enabled(); + + /* we're always on node 0 */ + return 0; +} + +static u32 noop_apic_read(u32 reg) +{ + /* + * noop-read is always safe until we have + * non-disabled unit + */ + WARN_ON_ONCE((cpu_has_apic && !disable_apic)); + return 0; +} + +struct apic apic_noop = { + .name = "noop", + .probe = noop_probe, + .acpi_madt_oem_check = NULL, + + .apic_id_registered = noop_apic_id_registered, + + .irq_delivery_mode = dest_LowestPrio, + /* logical delivery broadcast to all CPUs: */ + .irq_dest_mode = 1, + + .target_cpus = noop_target_cpus, + .disable_esr = 0, + .dest_logical = APIC_DEST_LOGICAL, + .check_apicid_used = noop_check_apicid_used, + .check_apicid_present = noop_check_apicid_present, + + .vector_allocation_domain = noop_vector_allocation_domain, + .init_apic_ldr = noop_init_apic_ldr, + + .ioapic_phys_id_map = noop_ioapic_phys_id_map, + .setup_apic_routing = NULL, + .multi_timer_check = NULL, + .apicid_to_node = noop_apicid_to_node, + + .cpu_to_logical_apicid = noop_cpu_to_logical_apicid, + .cpu_present_to_apicid = default_cpu_present_to_apicid, + .apicid_to_cpu_present = default_apicid_to_cpu_present, + + .setup_portio_remap = NULL, + .check_phys_apicid_present = default_check_phys_apicid_present, + .enable_apic_mode = NULL, + + .phys_pkg_id = noop_default_phys_pkg_id, + + .mps_oem_check = NULL, + + .get_apic_id = noop_get_apic_id, + .set_apic_id = NULL, + .apic_id_mask = 0x0F << 24, + + .cpu_mask_to_apicid = default_cpu_mask_to_apicid, + .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, + + .send_IPI_mask = noop_send_IPI_mask, + .send_IPI_mask_allbutself = noop_send_IPI_mask_allbutself, + .send_IPI_allbutself = noop_send_IPI_allbutself, + .send_IPI_all = noop_send_IPI_all, + .send_IPI_self = noop_send_IPI_self, + + .wakeup_secondary_cpu = noop_wakeup_secondary_cpu, + + /* should be safe */ + .trampoline_phys_low = DEFAULT_TRAMPOLINE_PHYS_LOW, + .trampoline_phys_high = DEFAULT_TRAMPOLINE_PHYS_HIGH, + + .wait_for_init_deassert = NULL, + + .smp_callin_clear_local_apic = NULL, + .inquire_remote_apic = NULL, + + .read = noop_apic_read, + .write = noop_apic_write, + .icr_read = noop_apic_icr_read, + .icr_write = noop_apic_icr_write, + .wait_icr_idle = noop_apic_wait_icr_idle, + .safe_wait_icr_idle = noop_safe_apic_wait_icr_idle, +}; ^ permalink raw reply [flat|nested] 16+ messages in thread
* [tip:x86/apic] x86, apic: Introduce the NOOP apic driver 2009-10-13 20:07 ` [patch 1/3] x86,apic: introduce NOOP apic driver Cyrill Gorcunov @ 2009-10-14 8:17 ` tip-bot for Cyrill Gorcunov 0 siblings, 0 replies; 16+ messages in thread From: tip-bot for Cyrill Gorcunov @ 2009-10-14 8:17 UTC (permalink / raw) To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, gorcunov, tglx, mingo Commit-ID: 9844ab11c763bfed9f054c82366b19dcda66aca9 Gitweb: http://git.kernel.org/tip/9844ab11c763bfed9f054c82366b19dcda66aca9 Author: Cyrill Gorcunov <gorcunov@openvz.org> AuthorDate: Wed, 14 Oct 2009 00:07:03 +0400 Committer: Ingo Molnar <mingo@elte.hu> CommitDate: Wed, 14 Oct 2009 09:17:00 +0200 x86, apic: Introduce the NOOP apic driver Introduce NOOP APIC driver. We should use it in case if apic was disabled due to hardware of software/firmware problems (including user requested to disable it case). The driver is attempting to catch any inappropriate apic operation call with warning issue. Also it is possible to use some apic operation like IPI calls, read/write without checking for apic presence which should make callers code easier. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Cc: yinghai@kernel.org Cc: macro@linux-mips.org LKML-Reference: <20091013201022.534682104@openvz.org> Signed-off-by: Ingo Molnar <mingo@elte.hu> --- arch/x86/include/asm/apic.h | 2 + arch/x86/kernel/apic/Makefile | 2 +- arch/x86/kernel/apic/apic_noop.c | 194 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 197 insertions(+), 1 deletions(-) diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h index 474d80d..08a5f42 100644 --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -488,6 +488,8 @@ static inline unsigned int read_apic_id(void) extern void default_setup_apic_routing(void); +extern struct apic apic_noop; + #ifdef CONFIG_X86_32 extern struct apic apic_default; diff --git a/arch/x86/kernel/apic/Makefile b/arch/x86/kernel/apic/Makefile index da7b7b9..565c1bf 100644 --- a/arch/x86/kernel/apic/Makefile +++ b/arch/x86/kernel/apic/Makefile @@ -2,7 +2,7 @@ # Makefile for local APIC drivers and for the IO-APIC code # -obj-$(CONFIG_X86_LOCAL_APIC) += apic.o probe_$(BITS).o ipi.o nmi.o +obj-$(CONFIG_X86_LOCAL_APIC) += apic.o apic_noop.o probe_$(BITS).o ipi.o nmi.o obj-$(CONFIG_X86_IO_APIC) += io_apic.o obj-$(CONFIG_SMP) += ipi.o diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c new file mode 100644 index 0000000..0b93ec2 --- /dev/null +++ b/arch/x86/kernel/apic/apic_noop.c @@ -0,0 +1,194 @@ +/* + * NOOP APIC driver. + * + * Does almost nothing and should be substituted by a real apic driver via + * probe routine. + * + * Though in case if apic is disabled (for some reason) we try + * to not uglify the caller's code and allow to call (some) apic routines + * like self-ipi, etc... and issue a warning if an operation is not allowed + */ + +#include <linux/threads.h> +#include <linux/cpumask.h> +#include <linux/module.h> +#include <linux/string.h> +#include <linux/kernel.h> +#include <linux/ctype.h> +#include <linux/init.h> +#include <linux/errno.h> +#include <asm/fixmap.h> +#include <asm/mpspec.h> +#include <asm/apicdef.h> +#include <asm/apic.h> +#include <asm/setup.h> + +#include <linux/smp.h> +#include <asm/ipi.h> + +#include <linux/interrupt.h> +#include <asm/acpi.h> +#include <asm/e820.h> + +/* + * some operations should never be reached with + * noop apic if it's not turned off, this mostly + * means the caller forgot to disable apic (or + * check the apic presence) before doing a call + */ +static void warn_apic_enabled(void) +{ + WARN_ONCE((cpu_has_apic || !disable_apic), + "APIC: Called for NOOP operation with apic enabled\n"); +} + +/* + * To check operations but do not bloat source code + */ +#define NOOP_FUNC(func) func { warn_apic_enabled(); } +#define NOOP_FUNC_RET(func, ret) func { warn_apic_enabled(); return ret; } + +NOOP_FUNC(static void noop_init_apic_ldr(void)) +NOOP_FUNC(static void noop_send_IPI_mask(const struct cpumask *cpumask, int vector)) +NOOP_FUNC(static void noop_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector)) +NOOP_FUNC(static void noop_send_IPI_allbutself(int vector)) +NOOP_FUNC(static void noop_send_IPI_all(int vector)) +NOOP_FUNC(static void noop_send_IPI_self(int vector)) +NOOP_FUNC_RET(static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip), -1) +NOOP_FUNC(static void noop_apic_write(u32 reg, u32 v)) +NOOP_FUNC(void noop_apic_wait_icr_idle(void)) +NOOP_FUNC_RET(static u32 noop_safe_apic_wait_icr_idle(void), 0) +NOOP_FUNC_RET(static u64 noop_apic_icr_read(void), 0) +NOOP_FUNC(static void noop_apic_icr_write(u32 low, u32 id)) +NOOP_FUNC_RET(static physid_mask_t noop_ioapic_phys_id_map(physid_mask_t phys_map), phys_map) +NOOP_FUNC_RET(static int noop_cpu_to_logical_apicid(int cpu), 1) +NOOP_FUNC_RET(static int noop_default_phys_pkg_id(int cpuid_apic, int index_msb), 0) +NOOP_FUNC_RET(static unsigned int noop_get_apic_id(unsigned long x), 0) + +static int noop_probe(void) +{ + /* should not ever be enabled this way */ + return 0; +} + +static int noop_apic_id_registered(void) +{ + warn_apic_enabled(); + return physid_isset(read_apic_id(), phys_cpu_present_map); +} + +static const struct cpumask *noop_target_cpus(void) +{ + warn_apic_enabled(); + + /* only BSP here */ + return cpumask_of(0); +} + +static unsigned long noop_check_apicid_used(physid_mask_t bitmap, int apicid) +{ + warn_apic_enabled(); + return physid_isset(apicid, bitmap); +} + +static unsigned long noop_check_apicid_present(int bit) +{ + warn_apic_enabled(); + return physid_isset(bit, phys_cpu_present_map); +} + +static void noop_vector_allocation_domain(int cpu, struct cpumask *retmask) +{ + warn_apic_enabled(); + if (cpu != 0) + pr_warning("APIC: Vector allocated for non-BSP cpu\n"); + cpumask_clear(retmask); + cpumask_set_cpu(cpu, retmask); +} + +int noop_apicid_to_node(int logical_apicid) +{ + warn_apic_enabled(); + + /* we're always on node 0 */ + return 0; +} + +static u32 noop_apic_read(u32 reg) +{ + /* + * noop-read is always safe until we have + * non-disabled unit + */ + WARN_ON_ONCE((cpu_has_apic && !disable_apic)); + return 0; +} + +struct apic apic_noop = { + .name = "noop", + .probe = noop_probe, + .acpi_madt_oem_check = NULL, + + .apic_id_registered = noop_apic_id_registered, + + .irq_delivery_mode = dest_LowestPrio, + /* logical delivery broadcast to all CPUs: */ + .irq_dest_mode = 1, + + .target_cpus = noop_target_cpus, + .disable_esr = 0, + .dest_logical = APIC_DEST_LOGICAL, + .check_apicid_used = noop_check_apicid_used, + .check_apicid_present = noop_check_apicid_present, + + .vector_allocation_domain = noop_vector_allocation_domain, + .init_apic_ldr = noop_init_apic_ldr, + + .ioapic_phys_id_map = noop_ioapic_phys_id_map, + .setup_apic_routing = NULL, + .multi_timer_check = NULL, + .apicid_to_node = noop_apicid_to_node, + + .cpu_to_logical_apicid = noop_cpu_to_logical_apicid, + .cpu_present_to_apicid = default_cpu_present_to_apicid, + .apicid_to_cpu_present = default_apicid_to_cpu_present, + + .setup_portio_remap = NULL, + .check_phys_apicid_present = default_check_phys_apicid_present, + .enable_apic_mode = NULL, + + .phys_pkg_id = noop_default_phys_pkg_id, + + .mps_oem_check = NULL, + + .get_apic_id = noop_get_apic_id, + .set_apic_id = NULL, + .apic_id_mask = 0x0F << 24, + + .cpu_mask_to_apicid = default_cpu_mask_to_apicid, + .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, + + .send_IPI_mask = noop_send_IPI_mask, + .send_IPI_mask_allbutself = noop_send_IPI_mask_allbutself, + .send_IPI_allbutself = noop_send_IPI_allbutself, + .send_IPI_all = noop_send_IPI_all, + .send_IPI_self = noop_send_IPI_self, + + .wakeup_secondary_cpu = noop_wakeup_secondary_cpu, + + /* should be safe */ + .trampoline_phys_low = DEFAULT_TRAMPOLINE_PHYS_LOW, + .trampoline_phys_high = DEFAULT_TRAMPOLINE_PHYS_HIGH, + + .wait_for_init_deassert = NULL, + + .smp_callin_clear_local_apic = NULL, + .inquire_remote_apic = NULL, + + .read = noop_apic_read, + .write = noop_apic_write, + .icr_read = noop_apic_icr_read, + .icr_write = noop_apic_icr_write, + .wait_icr_idle = noop_apic_wait_icr_idle, + .safe_wait_icr_idle = noop_safe_apic_wait_icr_idle, +}; ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [patch 2/3] x86,apic -- use apic noop driver 2009-10-13 20:07 [patch 0/3] x86 apic series Cyrill Gorcunov 2009-10-13 20:07 ` [patch 1/3] x86,apic: introduce NOOP apic driver Cyrill Gorcunov @ 2009-10-13 20:07 ` Cyrill Gorcunov 2009-10-14 8:17 ` [tip:x86/apic] x86, apic: Use " tip-bot for Cyrill Gorcunov 2009-10-13 20:07 ` [patch 3/3] x86,apic: limit apic dumping, introduce show_lapic setup option Cyrill Gorcunov 2 siblings, 1 reply; 16+ messages in thread From: Cyrill Gorcunov @ 2009-10-13 20:07 UTC (permalink / raw) To: mingo; +Cc: x86, yinghai, macro, linux-kernel, Cyrill Gorcunov [-- Attachment #1: x86-apic-use-noop --] [-- Type: text/plain, Size: 1360 bytes --] In case if apic were disabled we may use the whole apic NOOP driver instead of sparse poking the some functions in apic driver. Also NOOP would catch any inappropriate apic operation calls (not just read/write). Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> --- arch/x86/kernel/apic/apic.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) Index: linux-2.6.git/arch/x86/kernel/apic/apic.c ===================================================================== --- linux-2.6.git.orig/arch/x86/kernel/apic/apic.c +++ linux-2.6.git/arch/x86/kernel/apic/apic.c @@ -241,28 +241,12 @@ static int modern_apic(void) } /* - * bare function to substitute write operation - * and it's _that_ fast :) - */ -static void native_apic_write_dummy(u32 reg, u32 v) -{ - WARN_ON_ONCE((cpu_has_apic || !disable_apic)); -} - -static u32 native_apic_read_dummy(u32 reg) -{ - WARN_ON_ONCE((cpu_has_apic && !disable_apic)); - return 0; -} - -/* - * right after this call apic->write/read doesn't do anything - * note that there is no restore operation it works one way + * right after this call apic become NOOP driven + * so apic->write/read doesn't do anything */ void apic_disable(void) { - apic->read = native_apic_read_dummy; - apic->write = native_apic_write_dummy; + apic = &apic_noop; } void native_apic_wait_icr_idle(void) ^ permalink raw reply [flat|nested] 16+ messages in thread
* [tip:x86/apic] x86, apic: Use apic noop driver 2009-10-13 20:07 ` [patch 2/3] x86,apic -- use apic noop driver Cyrill Gorcunov @ 2009-10-14 8:17 ` tip-bot for Cyrill Gorcunov 0 siblings, 0 replies; 16+ messages in thread From: tip-bot for Cyrill Gorcunov @ 2009-10-14 8:17 UTC (permalink / raw) To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, gorcunov, tglx, mingo Commit-ID: a933c61829509eb27083146dda392132baa0969a Gitweb: http://git.kernel.org/tip/a933c61829509eb27083146dda392132baa0969a Author: Cyrill Gorcunov <gorcunov@openvz.org> AuthorDate: Wed, 14 Oct 2009 00:07:04 +0400 Committer: Ingo Molnar <mingo@elte.hu> CommitDate: Wed, 14 Oct 2009 09:17:00 +0200 x86, apic: Use apic noop driver In case if apic were disabled we may use the whole apic NOOP driver instead of sparse poking the some functions in apic driver. Also NOOP would catch any inappropriate apic operation calls (not just read/write). Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Cc: yinghai@kernel.org Cc: macro@linux-mips.org LKML-Reference: <20091013201022.747817361@openvz.org> Signed-off-by: Ingo Molnar <mingo@elte.hu> --- arch/x86/kernel/apic/apic.c | 22 +++------------------- 1 files changed, 3 insertions(+), 19 deletions(-) diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index 894aa97..61a5628 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -241,28 +241,12 @@ static int modern_apic(void) } /* - * bare function to substitute write operation - * and it's _that_ fast :) - */ -static void native_apic_write_dummy(u32 reg, u32 v) -{ - WARN_ON_ONCE((cpu_has_apic || !disable_apic)); -} - -static u32 native_apic_read_dummy(u32 reg) -{ - WARN_ON_ONCE((cpu_has_apic && !disable_apic)); - return 0; -} - -/* - * right after this call apic->write/read doesn't do anything - * note that there is no restore operation it works one way + * right after this call apic become NOOP driven + * so apic->write/read doesn't do anything */ void apic_disable(void) { - apic->read = native_apic_read_dummy; - apic->write = native_apic_write_dummy; + apic = &apic_noop; } void native_apic_wait_icr_idle(void) ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [patch 3/3] x86,apic: limit apic dumping, introduce show_lapic setup option 2009-10-13 20:07 [patch 0/3] x86 apic series Cyrill Gorcunov 2009-10-13 20:07 ` [patch 1/3] x86,apic: introduce NOOP apic driver Cyrill Gorcunov 2009-10-13 20:07 ` [patch 2/3] x86,apic -- use apic noop driver Cyrill Gorcunov @ 2009-10-13 20:07 ` Cyrill Gorcunov 2009-10-14 7:12 ` Ingo Molnar 2009-10-14 8:17 ` [tip:x86/apic] x86, apic: Limit apic dumping, introduce new show_lapic= " tip-bot for Cyrill Gorcunov 2 siblings, 2 replies; 16+ messages in thread From: Cyrill Gorcunov @ 2009-10-13 20:07 UTC (permalink / raw) To: mingo; +Cc: x86, yinghai, macro, linux-kernel, Cyrill Gorcunov [-- Attachment #1: x86-apic-show-apic-2 --] [-- Type: text/plain, Size: 3343 bytes --] In case if a system has a large number of cpus printing apics contents may consume a long time period. We limit such an output by 1 apic by default. But to have an ability to see all apics or some part of them we introduce "show_lapic" setup option which allow us to limit/unlimit the number of APICs being dumped. Example: apic=debug show_lapic=5, or apic=debug show_lapic=all Also move apic_verbosity checking upper that way so helper routines do not need to inspect it at all. Suggested-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> --- arch/x86/kernel/apic/io_apic.c | 47 +++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 15 deletions(-) Index: linux-2.6.git/arch/x86/kernel/apic/io_apic.c ===================================================================== --- linux-2.6.git.orig/arch/x86/kernel/apic/io_apic.c +++ linux-2.6.git/arch/x86/kernel/apic/io_apic.c @@ -1599,9 +1599,6 @@ __apicdebuginit(void) print_IO_APIC(void struct irq_desc *desc; unsigned int irq; - if (apic_verbosity == APIC_QUIET) - return; - printk(KERN_DEBUG "number of MP IRQ sources: %d.\n", mp_irq_entries); for (i = 0; i < nr_ioapics; i++) printk(KERN_DEBUG "number of IO-APIC #%d registers: %d.\n", @@ -1708,9 +1705,6 @@ __apicdebuginit(void) print_APIC_field(i { int i; - if (apic_verbosity == APIC_QUIET) - return; - printk(KERN_DEBUG); for (i = 0; i < 8; i++) @@ -1724,9 +1718,6 @@ __apicdebuginit(void) print_local_APIC(v unsigned int i, v, ver, maxlvt; u64 icr; - if (apic_verbosity == APIC_QUIET) - return; - printk(KERN_DEBUG "printing local APIC contents on CPU#%d/%d:\n", smp_processor_id(), hard_smp_processor_id()); v = apic_read(APIC_ID); @@ -1824,13 +1815,19 @@ __apicdebuginit(void) print_local_APIC(v printk("\n"); } -__apicdebuginit(void) print_all_local_APICs(void) +__apicdebuginit(void) print_local_APICs(int maxcpu) { int cpu; + if (!maxcpu) + return; + preempt_disable(); - for_each_online_cpu(cpu) + for_each_online_cpu(cpu) { + if (cpu >= maxcpu) + break; smp_call_function_single(cpu, print_local_APIC, NULL, 1); + } preempt_enable(); } @@ -1839,7 +1836,7 @@ __apicdebuginit(void) print_PIC(void) unsigned int v; unsigned long flags; - if (apic_verbosity == APIC_QUIET || !nr_legacy_irqs) + if (!nr_legacy_irqs) return; printk(KERN_DEBUG "\nprinting PIC contents\n"); @@ -1866,21 +1863,41 @@ __apicdebuginit(void) print_PIC(void) printk(KERN_DEBUG "... PIC ELCR: %04x\n", v); } -__apicdebuginit(int) print_all_ICs(void) +static int __initdata show_lapic = 1; +static __init int setup_show_lapic(char *arg) +{ + int num = -1; + + if (strcmp(arg, "all") == 0) { + show_lapic = CONFIG_NR_CPUS; + } else { + get_option(&arg, &num); + if (num >= 0) + show_lapic = num; + } + + return 1; +} +__setup("show_lapic=", setup_show_lapic); + +__apicdebuginit(int) print_ICs(void) { + if (apic_verbosity == APIC_QUIET) + return 0; + print_PIC(); /* don't print out if apic is not there */ if (!cpu_has_apic && !apic_from_smp_config()) return 0; - print_all_local_APICs(); + print_local_APICs(show_lapic); print_IO_APIC(); return 0; } -fs_initcall(print_all_ICs); +fs_initcall(print_ICs); /* Where if anywhere is the i8259 connect in external int mode */ ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch 3/3] x86,apic: limit apic dumping, introduce show_lapic setup option 2009-10-13 20:07 ` [patch 3/3] x86,apic: limit apic dumping, introduce show_lapic setup option Cyrill Gorcunov @ 2009-10-14 7:12 ` Ingo Molnar 2009-10-14 7:51 ` Cyrill Gorcunov 2009-10-14 15:09 ` Cyrill Gorcunov 2009-10-14 8:17 ` [tip:x86/apic] x86, apic: Limit apic dumping, introduce new show_lapic= " tip-bot for Cyrill Gorcunov 1 sibling, 2 replies; 16+ messages in thread From: Ingo Molnar @ 2009-10-14 7:12 UTC (permalink / raw) To: Cyrill Gorcunov; +Cc: x86, yinghai, macro, linux-kernel * Cyrill Gorcunov <gorcunov@openvz.org> wrote: > In case if a system has a large number of cpus printing apics > contents may consume a long time period. > > We limit such an output by 1 apic by default. But to have an > ability to see all apics or some part of them we introduce > "show_lapic" setup option which allow us to limit/unlimit > the number of APICs being dumped. > > Example: apic=debug show_lapic=5, or apic=debug show_lapic=all > > Also move apic_verbosity checking upper that way so helper routines > do not need to inspect it at all. > > Suggested-by: Yinghai Lu <yinghai@kernel.org> > Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> > --- > arch/x86/kernel/apic/io_apic.c | 47 +++++++++++++++++++++++++++-------------- > 1 file changed, 32 insertions(+), 15 deletions(-) > +__setup("show_lapic=", setup_show_lapic); Note: new __setup() functions need an entry in Documentation/kernel-parameters.txt as well. Ingo ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch 3/3] x86,apic: limit apic dumping, introduce show_lapic setup option 2009-10-14 7:12 ` Ingo Molnar @ 2009-10-14 7:51 ` Cyrill Gorcunov 2009-10-14 15:09 ` Cyrill Gorcunov 1 sibling, 0 replies; 16+ messages in thread From: Cyrill Gorcunov @ 2009-10-14 7:51 UTC (permalink / raw) To: Ingo Molnar; +Cc: x86, yinghai, macro, linux-kernel On 10/14/09, Ingo Molnar <mingo@elte.hu> wrote: > > * Cyrill Gorcunov <gorcunov@openvz.org> wrote: > >> In case if a system has a large number of cpus printing apics >> contents may consume a long time period. >> >> We limit such an output by 1 apic by default. But to have an >> ability to see all apics or some part of them we introduce >> "show_lapic" setup option which allow us to limit/unlimit >> the number of APICs being dumped. >> >> Example: apic=debug show_lapic=5, or apic=debug show_lapic=all >> >> Also move apic_verbosity checking upper that way so helper routines >> do not need to inspect it at all. >> >> Suggested-by: Yinghai Lu <yinghai@kernel.org> >> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> >> --- >> arch/x86/kernel/apic/io_apic.c | 47 >> +++++++++++++++++++++++++++-------------- >> 1 file changed, 32 insertions(+), 15 deletions(-) > >> +__setup("show_lapic=", setup_show_lapic); > > Note: new __setup() functions need an entry in > Documentation/kernel-parameters.txt as well. > > Ingo > Will update today evening. Thanks! ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch 3/3] x86,apic: limit apic dumping, introduce show_lapic setup option 2009-10-14 7:12 ` Ingo Molnar 2009-10-14 7:51 ` Cyrill Gorcunov @ 2009-10-14 15:09 ` Cyrill Gorcunov 2009-10-14 15:40 ` [tip:x86/apic] x86, apic: Explain show_lapic= in kernel parameters list tip-bot for Cyrill Gorcunov 2009-10-14 17:56 ` [patch 3/3] x86,apic: limit apic dumping, introduce show_lapic setup option Ingo Molnar 1 sibling, 2 replies; 16+ messages in thread From: Cyrill Gorcunov @ 2009-10-14 15:09 UTC (permalink / raw) To: Ingo Molnar; +Cc: x86, yinghai, macro, linux-kernel [Ingo Molnar - Wed, Oct 14, 2009 at 09:12:17AM +0200] | ... | Note: new __setup() functions need an entry in | Documentation/kernel-parameters.txt as well. | | Ingo | Here is it. -- Cyrill --- x86,apic: explain show_lapic in kernel parameters list Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> --- Documentation/kernel-parameters.txt | 9 +++++++++ 1 file changed, 9 insertions(+) Index: linux-2.6.git/Documentation/kernel-parameters.txt ===================================================================== --- linux-2.6.git.orig/Documentation/kernel-parameters.txt +++ linux-2.6.git/Documentation/kernel-parameters.txt @@ -345,6 +345,15 @@ and is between 256 and 4096 characters. Change the amount of debugging information output when initialising the APIC and IO-APIC components. + show_lapic= [APIC,X86] Advanced Programmable Interrupt Controller + Limit apic dumping. The parameter defines the maximal + number of local apics being dumped. Also it is possible + to set it to "all" by meaning -- no limit here. + Format: { 1 (default) | 2 | ... | all }. + The parameter valid if only apic=debug or + apic=verbose is specified. + Example: apic=debug show_lapic=all + apm= [APM] Advanced Power Management See header of arch/x86/kernel/apm_32.c. ^ permalink raw reply [flat|nested] 16+ messages in thread
* [tip:x86/apic] x86, apic: Explain show_lapic= in kernel parameters list 2009-10-14 15:09 ` Cyrill Gorcunov @ 2009-10-14 15:40 ` tip-bot for Cyrill Gorcunov 2009-10-14 17:56 ` [patch 3/3] x86,apic: limit apic dumping, introduce show_lapic setup option Ingo Molnar 1 sibling, 0 replies; 16+ messages in thread From: tip-bot for Cyrill Gorcunov @ 2009-10-14 15:40 UTC (permalink / raw) To: linux-tip-commits Cc: linux-kernel, hpa, mingo, gorcunov, tglx, gorcunov, mingo Commit-ID: 9636bc0555e3f383c120ddcffe4b7c5c58a10b1a Gitweb: http://git.kernel.org/tip/9636bc0555e3f383c120ddcffe4b7c5c58a10b1a Author: Cyrill Gorcunov <gorcunov@gmail.com> AuthorDate: Wed, 14 Oct 2009 19:09:04 +0400 Committer: Ingo Molnar <mingo@elte.hu> CommitDate: Wed, 14 Oct 2009 17:28:05 +0200 x86, apic: Explain show_lapic= in kernel parameters list Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Cc: yinghai@kernel.org Cc: macro@linux-mips.org LKML-Reference: <20091014150904.GA5259@lenovo> Signed-off-by: Ingo Molnar <mingo@elte.hu> --- Documentation/kernel-parameters.txt | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 9107b38..465a786 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -345,6 +345,15 @@ and is between 256 and 4096 characters. It is defined in the file Change the amount of debugging information output when initialising the APIC and IO-APIC components. + show_lapic= [APIC,X86] Advanced Programmable Interrupt Controller + Limit apic dumping. The parameter defines the maximal + number of local apics being dumped. Also it is possible + to set it to "all" by meaning -- no limit here. + Format: { 1 (default) | 2 | ... | all }. + The parameter valid if only apic=debug or + apic=verbose is specified. + Example: apic=debug show_lapic=all + apm= [APM] Advanced Power Management See header of arch/x86/kernel/apm_32.c. ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [patch 3/3] x86,apic: limit apic dumping, introduce show_lapic setup option 2009-10-14 15:09 ` Cyrill Gorcunov 2009-10-14 15:40 ` [tip:x86/apic] x86, apic: Explain show_lapic= in kernel parameters list tip-bot for Cyrill Gorcunov @ 2009-10-14 17:56 ` Ingo Molnar 2009-10-14 18:00 ` Cyrill Gorcunov ` (2 more replies) 1 sibling, 3 replies; 16+ messages in thread From: Ingo Molnar @ 2009-10-14 17:56 UTC (permalink / raw) To: Cyrill Gorcunov; +Cc: x86, yinghai, macro, linux-kernel btw., i'm getting this warning on a test-box: [ 0.290000] Initializing cgroup subsys net_cls [ 0.300000] ------------[ cut here ]------------ [ 0.300000] WARNING: at arch/x86/kernel/apic/apic_noop.c:42 warn_apic_enabled+0x5d/0x80() [ 0.310000] Hardware name: System Product Name [ 0.320000] APIC: Called for NOOP operation with apic enabled [ 0.320000] Modules linked in: [ 0.330000] Pid: 0, comm: swapper Not tainted 2.6.32-rc4-tip-01511-g59b4c9d-dirty #1741 [ 0.330000] Call Trace: [ 0.340000] [<79061fa5>] warn_slowpath_common+0x65/0xa0 [ 0.340000] [<7903d84d>] ? warn_apic_enabled+0x5d/0x80 [ 0.350000] [<7906203f>] warn_slowpath_fmt+0x2f/0x50 [ 0.350000] [<7903d84d>] warn_apic_enabled+0x5d/0x80 [ 0.360000] [<7903da96>] noop_default_phys_pkg_id+0x16/0x30 [ 0.360000] [<79af1514>] generic_identify+0xa3/0x176 [ 0.370000] [<79af165f>] identify_cpu+0x78/0x1fd [ 0.370000] [<792c8d7d>] ? __init_rwsem+0x4d/0x70 [ 0.380000] [<79abcb54>] identify_boot_cpu+0xd/0x1e [ 0.380000] [<79abcdae>] check_bugs+0x16/0xe5 [ 0.390000] [<79ab6b39>] start_kernel+0x31d/0x342 [ 0.390000] [<79ab60aa>] i386_start_kernel+0xaa/0xc2 [ 0.400000] ---[ end trace a7919e7f17c0a725 ]--- [ 0.400000] Checking 'hlt' instruction... OK. [ 0.440000] SMP alternatives: switching to UP code [ 0.450000] debug: unmapping init memory 79c7a000..79c80000 noop_default_phys_pkg_id() should return 0 i guess, and not generate a warning? Ingo ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch 3/3] x86,apic: limit apic dumping, introduce show_lapic setup option 2009-10-14 17:56 ` [patch 3/3] x86,apic: limit apic dumping, introduce show_lapic setup option Ingo Molnar @ 2009-10-14 18:00 ` Cyrill Gorcunov 2009-10-14 18:20 ` Cyrill Gorcunov 2009-10-14 20:29 ` Cyrill Gorcunov 2 siblings, 0 replies; 16+ messages in thread From: Cyrill Gorcunov @ 2009-10-14 18:00 UTC (permalink / raw) To: Ingo Molnar; +Cc: x86, yinghai, macro, linux-kernel [Ingo Molnar - Wed, Oct 14, 2009 at 07:56:16PM +0200] ... | | noop_default_phys_pkg_id() should return 0 i guess, and not generate a | warning? | | Ingo | hmm, letme check (seems so)... -- Cyrill ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch 3/3] x86,apic: limit apic dumping, introduce show_lapic setup option 2009-10-14 17:56 ` [patch 3/3] x86,apic: limit apic dumping, introduce show_lapic setup option Ingo Molnar 2009-10-14 18:00 ` Cyrill Gorcunov @ 2009-10-14 18:20 ` Cyrill Gorcunov 2009-10-14 20:29 ` Cyrill Gorcunov 2 siblings, 0 replies; 16+ messages in thread From: Cyrill Gorcunov @ 2009-10-14 18:20 UTC (permalink / raw) To: Ingo Molnar; +Cc: x86, yinghai, macro, linux-kernel [Ingo Molnar - Wed, Oct 14, 2009 at 07:56:16PM +0200] ... | | noop_default_phys_pkg_id() should return 0 i guess, and not generate a | warning? | | Ingo | We have ------- start_kernel setup_arch generic_apic_probe init_apic_mappings <-- here we change apic to noop driver check_bugs <-- noop warn here but apic should be already disabled so it seems some flag is forgotten to set. All in one: some nit in my patch. Checking... -- Cyrill ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch 3/3] x86,apic: limit apic dumping, introduce show_lapic setup option 2009-10-14 17:56 ` [patch 3/3] x86,apic: limit apic dumping, introduce show_lapic setup option Ingo Molnar 2009-10-14 18:00 ` Cyrill Gorcunov 2009-10-14 18:20 ` Cyrill Gorcunov @ 2009-10-14 20:29 ` Cyrill Gorcunov 2009-10-15 14:27 ` Cyrill Gorcunov 2 siblings, 1 reply; 16+ messages in thread From: Cyrill Gorcunov @ 2009-10-14 20:29 UTC (permalink / raw) To: Ingo Molnar; +Cc: x86, yinghai, macro, linux-kernel [Ingo Molnar - Wed, Oct 14, 2009 at 07:56:16PM +0200] | | btw., i'm getting this warning on a test-box: ... | | [ 0.400000] Checking 'hlt' instruction... OK. | [ 0.440000] SMP alternatives: switching to UP code | [ 0.450000] debug: unmapping init memory 79c7a000..79c80000 | | noop_default_phys_pkg_id() should return 0 i guess, and not generate a | warning? | | Ingo | Ingo, I think the better would be to just make NOOP plain NOOP without any kind of checking. Something like below (I still can't fetch last/fresh -tip repo /remote point hangs/ for this so I've used interdiff). Comments? Btw, the base problem from dump you posted is that we've been cheking only for read/write operations allowing all other ops be called without any kind of check (and retrieving pkgid happened there all the time just didn't trigger warn until we've substituted apic driver completely). Using NOOP without warn should be more convenient (all previous "dark" places in apic code already covered with cpu_has_apic/disable_apic checks so the only risk we have -- is code that will appear in future). -- Cyrill --- x86,apic: allow noop operations to be called at any moment As only apic noop is used we allow to use any operation caller wants (and which of them noop driver supports of course). Initially it was reported by Ingo Molnar that apic noop issue a warning (which is actually false positive and should be eliminated). So lets NOOP be plain NOOP -- ie it should do nothing (and be fast) but attempting to return sane values on read opertaions and be dumb on write operations. Reported-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> --- apic_noop.c | 87 +++++++++++++++++++++++++++++------------------------------- 1 file changed, 43 insertions(+), 44 deletions(-) diff -u linux-2.6.git/arch/x86/kernel/apic/apic_noop.c linux-2.6.git/arch/x86/kernel/apic/apic_noop.c --- linux-2.6.git/arch/x86/kernel/apic/apic_noop.c +++ linux-2.6.git/arch/x86/kernel/apic/apic_noop.c @@ -6,7 +6,7 @@ * * Though in case if apic is disabled (for some reason) we try * to not uglify the caller's code and allow to call (some) apic routines - * like self-ipi, etc... and issue a warning if an operation is not allowed + * like self-ipi, etc... */ #include <linux/threads.h> @@ -30,40 +30,48 @@ #include <asm/acpi.h> #include <asm/e820.h> -/* - * some operations should never be reached with - * noop apic if it's not turned off, this mostly - * means the caller forgot to disable apic (or - * check the apic presence) before doing a call - */ -static void warn_apic_enabled(void) +static void noop_init_apic_ldr(void) { } +static void noop_send_IPI_mask(const struct cpumask *cpumask, int vector) { } +static void noop_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector) { } +static void noop_send_IPI_allbutself(int vector) { } +static void noop_send_IPI_all(int vector) { } +static void noop_send_IPI_self(int vector) { } +static void noop_apic_wait_icr_idle(void) { } +static void noop_apic_icr_write(u32 low, u32 id) { } + +static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip) { - WARN_ONCE((cpu_has_apic || !disable_apic), - "APIC: Called for NOOP operation with apic enabled\n"); + return -1; } -/* - * To check operations but do not bloat source code - */ -#define NOOP_FUNC(func) func { warn_apic_enabled(); } -#define NOOP_FUNC_RET(func, ret) func { warn_apic_enabled(); return ret; } +static u32 noop_safe_apic_wait_icr_idle(void) +{ + return 0; +} + +static u64 noop_apic_icr_read(void) +{ + return 0; +} +static physid_mask_t noop_ioapic_phys_id_map(physid_mask_t phys_map) +{ + return phys_map; +} -NOOP_FUNC(static void noop_init_apic_ldr(void)) -NOOP_FUNC(static void noop_send_IPI_mask(const struct cpumask *cpumask, int vector)) -NOOP_FUNC(static void noop_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector)) -NOOP_FUNC(static void noop_send_IPI_allbutself(int vector)) -NOOP_FUNC(static void noop_send_IPI_all(int vector)) -NOOP_FUNC(static void noop_send_IPI_self(int vector)) -NOOP_FUNC_RET(static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip), -1) -NOOP_FUNC(static void noop_apic_write(u32 reg, u32 v)) -NOOP_FUNC(void noop_apic_wait_icr_idle(void)) -NOOP_FUNC_RET(static u32 noop_safe_apic_wait_icr_idle(void), 0) -NOOP_FUNC_RET(static u64 noop_apic_icr_read(void), 0) -NOOP_FUNC(static void noop_apic_icr_write(u32 low, u32 id)) -NOOP_FUNC_RET(static physid_mask_t noop_ioapic_phys_id_map(physid_mask_t phys_map), phys_map) -NOOP_FUNC_RET(static int noop_cpu_to_logical_apicid(int cpu), 1) -NOOP_FUNC_RET(static int noop_default_phys_pkg_id(int cpuid_apic, int index_msb), 0) -NOOP_FUNC_RET(static unsigned int noop_get_apic_id(unsigned long x), 0) +static int noop_cpu_to_logical_apicid(int cpu) +{ + return 1; +} + +static int noop_default_phys_pkg_id(int cpuid_apic, int index_msb) +{ + return 0; +} + +static unsigned int noop_get_apic_id(unsigned long x) +{ + return 0; +} static int noop_probe(void) { @@ -73,33 +81,27 @@ static int noop_apic_id_registered(void) { - warn_apic_enabled(); return physid_isset(read_apic_id(), phys_cpu_present_map); } static const struct cpumask *noop_target_cpus(void) { - warn_apic_enabled(); - /* only BSP here */ return cpumask_of(0); } static unsigned long noop_check_apicid_used(physid_mask_t bitmap, int apicid) { - warn_apic_enabled(); return physid_isset(apicid, bitmap); } static unsigned long noop_check_apicid_present(int bit) { - warn_apic_enabled(); return physid_isset(bit, phys_cpu_present_map); } static void noop_vector_allocation_domain(int cpu, struct cpumask *retmask) { - warn_apic_enabled(); if (cpu != 0) pr_warning("APIC: Vector allocated for non-BSP cpu\n"); cpumask_clear(retmask); @@ -108,22 +110,19 @@ int noop_apicid_to_node(int logical_apicid) { - warn_apic_enabled(); - /* we're always on node 0 */ return 0; } static u32 noop_apic_read(u32 reg) { - /* - * noop-read is always safe until we have - * non-disabled unit - */ - WARN_ON_ONCE((cpu_has_apic && !disable_apic)); return 0; } +static void noop_apic_write(u32 reg, u32 v) +{ +} + struct apic apic_noop = { .name = "noop", .probe = noop_probe, ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch 3/3] x86,apic: limit apic dumping, introduce show_lapic setup option 2009-10-14 20:29 ` Cyrill Gorcunov @ 2009-10-15 14:27 ` Cyrill Gorcunov 0 siblings, 0 replies; 16+ messages in thread From: Cyrill Gorcunov @ 2009-10-15 14:27 UTC (permalink / raw) To: Ingo Molnar, x86, yinghai, macro, linux-kernel [Cyrill Gorcunov - Thu, Oct 15, 2009 at 12:29:41AM +0400] | [Ingo Molnar - Wed, Oct 14, 2009 at 07:56:16PM +0200] | | | | btw., i'm getting this warning on a test-box: | ... | | | | [ 0.400000] Checking 'hlt' instruction... OK. | | [ 0.440000] SMP alternatives: switching to UP code | | [ 0.450000] debug: unmapping init memory 79c7a000..79c80000 | | | | noop_default_phys_pkg_id() should return 0 i guess, and not generate a | | warning? | | | | Ingo | | | | Ingo, I think the better would be to just make NOOP plain | NOOP without any kind of checking. Something like below | (I still can't fetch last/fresh -tip repo /remote point hangs/ | for this so I've used interdiff). | | Comments? | | Btw, the base problem from dump you posted is that we've been | cheking only for read/write operations allowing all other ops | be called without any kind of check (and retrieving pkgid happened | there all the time just didn't trigger warn until we've substituted | apic driver completely). Using NOOP without warn should be more | convenient (all previous "dark" places in apic code already covered | with cpu_has_apic/disable_apic checks so the only risk we have -- | is code that will appear in future). | | -- Cyrill | --- Ingo, please don't apply it yet. I think there is a nit. Checking now. Will resend later the proper patch. -- Cyrill ^ permalink raw reply [flat|nested] 16+ messages in thread
* [tip:x86/apic] x86, apic: Limit apic dumping, introduce new show_lapic= setup option 2009-10-13 20:07 ` [patch 3/3] x86,apic: limit apic dumping, introduce show_lapic setup option Cyrill Gorcunov 2009-10-14 7:12 ` Ingo Molnar @ 2009-10-14 8:17 ` tip-bot for Cyrill Gorcunov 1 sibling, 0 replies; 16+ messages in thread From: tip-bot for Cyrill Gorcunov @ 2009-10-14 8:17 UTC (permalink / raw) To: linux-tip-commits Cc: linux-kernel, hpa, mingo, yinghai, gorcunov, tglx, mingo Commit-ID: 2626eb2b2fd958dc0f683126aa84e93b939699a1 Gitweb: http://git.kernel.org/tip/2626eb2b2fd958dc0f683126aa84e93b939699a1 Author: Cyrill Gorcunov <gorcunov@openvz.org> AuthorDate: Wed, 14 Oct 2009 00:07:05 +0400 Committer: Ingo Molnar <mingo@elte.hu> CommitDate: Wed, 14 Oct 2009 09:17:01 +0200 x86, apic: Limit apic dumping, introduce new show_lapic= setup option In case if a system has a large number of cpus printing apics contents may consume a long time period. We limit such an output by 1 apic by default. But to have an ability to see all apics or some part of them we introduce "show_lapic" setup option which allow us to limit/unlimit the number of APICs being dumped. Example: apic=debug show_lapic=5, or apic=debug show_lapic=all Also move apic_verbosity checking upper that way so helper routines do not need to inspect it at all. Suggested-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Cc: yinghai@kernel.org Cc: macro@linux-mips.org LKML-Reference: <20091013201022.926793122@openvz.org> Signed-off-by: Ingo Molnar <mingo@elte.hu> --- arch/x86/kernel/apic/io_apic.c | 47 +++++++++++++++++++++++++++------------ 1 files changed, 32 insertions(+), 15 deletions(-) diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index dc69f28..8c718c9 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -1599,9 +1599,6 @@ __apicdebuginit(void) print_IO_APIC(void) struct irq_desc *desc; unsigned int irq; - if (apic_verbosity == APIC_QUIET) - return; - printk(KERN_DEBUG "number of MP IRQ sources: %d.\n", mp_irq_entries); for (i = 0; i < nr_ioapics; i++) printk(KERN_DEBUG "number of IO-APIC #%d registers: %d.\n", @@ -1708,9 +1705,6 @@ __apicdebuginit(void) print_APIC_field(int base) { int i; - if (apic_verbosity == APIC_QUIET) - return; - printk(KERN_DEBUG); for (i = 0; i < 8; i++) @@ -1724,9 +1718,6 @@ __apicdebuginit(void) print_local_APIC(void *dummy) unsigned int i, v, ver, maxlvt; u64 icr; - if (apic_verbosity == APIC_QUIET) - return; - printk(KERN_DEBUG "printing local APIC contents on CPU#%d/%d:\n", smp_processor_id(), hard_smp_processor_id()); v = apic_read(APIC_ID); @@ -1824,13 +1815,19 @@ __apicdebuginit(void) print_local_APIC(void *dummy) printk("\n"); } -__apicdebuginit(void) print_all_local_APICs(void) +__apicdebuginit(void) print_local_APICs(int maxcpu) { int cpu; + if (!maxcpu) + return; + preempt_disable(); - for_each_online_cpu(cpu) + for_each_online_cpu(cpu) { + if (cpu >= maxcpu) + break; smp_call_function_single(cpu, print_local_APIC, NULL, 1); + } preempt_enable(); } @@ -1839,7 +1836,7 @@ __apicdebuginit(void) print_PIC(void) unsigned int v; unsigned long flags; - if (apic_verbosity == APIC_QUIET || !nr_legacy_irqs) + if (!nr_legacy_irqs) return; printk(KERN_DEBUG "\nprinting PIC contents\n"); @@ -1866,21 +1863,41 @@ __apicdebuginit(void) print_PIC(void) printk(KERN_DEBUG "... PIC ELCR: %04x\n", v); } -__apicdebuginit(int) print_all_ICs(void) +static int __initdata show_lapic = 1; +static __init int setup_show_lapic(char *arg) +{ + int num = -1; + + if (strcmp(arg, "all") == 0) { + show_lapic = CONFIG_NR_CPUS; + } else { + get_option(&arg, &num); + if (num >= 0) + show_lapic = num; + } + + return 1; +} +__setup("show_lapic=", setup_show_lapic); + +__apicdebuginit(int) print_ICs(void) { + if (apic_verbosity == APIC_QUIET) + return 0; + print_PIC(); /* don't print out if apic is not there */ if (!cpu_has_apic && !apic_from_smp_config()) return 0; - print_all_local_APICs(); + print_local_APICs(show_lapic); print_IO_APIC(); return 0; } -fs_initcall(print_all_ICs); +fs_initcall(print_ICs); /* Where if anywhere is the i8259 connect in external int mode */ ^ permalink raw reply related [flat|nested] 16+ messages in thread
end of thread, other threads:[~2009-10-15 14:28 UTC | newest] Thread overview: 16+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-10-13 20:07 [patch 0/3] x86 apic series Cyrill Gorcunov 2009-10-13 20:07 ` [patch 1/3] x86,apic: introduce NOOP apic driver Cyrill Gorcunov 2009-10-14 8:17 ` [tip:x86/apic] x86, apic: Introduce the " tip-bot for Cyrill Gorcunov 2009-10-13 20:07 ` [patch 2/3] x86,apic -- use apic noop driver Cyrill Gorcunov 2009-10-14 8:17 ` [tip:x86/apic] x86, apic: Use " tip-bot for Cyrill Gorcunov 2009-10-13 20:07 ` [patch 3/3] x86,apic: limit apic dumping, introduce show_lapic setup option Cyrill Gorcunov 2009-10-14 7:12 ` Ingo Molnar 2009-10-14 7:51 ` Cyrill Gorcunov 2009-10-14 15:09 ` Cyrill Gorcunov 2009-10-14 15:40 ` [tip:x86/apic] x86, apic: Explain show_lapic= in kernel parameters list tip-bot for Cyrill Gorcunov 2009-10-14 17:56 ` [patch 3/3] x86,apic: limit apic dumping, introduce show_lapic setup option Ingo Molnar 2009-10-14 18:00 ` Cyrill Gorcunov 2009-10-14 18:20 ` Cyrill Gorcunov 2009-10-14 20:29 ` Cyrill Gorcunov 2009-10-15 14:27 ` Cyrill Gorcunov 2009-10-14 8:17 ` [tip:x86/apic] x86, apic: Limit apic dumping, introduce new show_lapic= " tip-bot for Cyrill Gorcunov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox