From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932800AbdHYUHi (ORCPT ); Fri, 25 Aug 2017 16:07:38 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:42630 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754518AbdHYUHh (ORCPT ); Fri, 25 Aug 2017 16:07:37 -0400 Date: Fri, 25 Aug 2017 22:07:33 +0200 (CEST) From: Thomas Gleixner To: Steven Rostedt cc: LKML , Ingo Molnar , Peter Anvin , Peter Zijlstra , Andy Lutomirski , Borislav Petkov Subject: Re: [patch 14/41] x86/smp: Use static key for reschedule interrupt tracing In-Reply-To: <20170825154016.2b692126@gandalf.local.home> Message-ID: References: <20170825103103.287814238@linutronix.de> <20170825104414.076899278@linutronix.de> <20170825154016.2b692126@gandalf.local.home> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 25 Aug 2017, Steven Rostedt wrote: > On Fri, 25 Aug 2017 12:31:17 +0200 > Thomas Gleixner wrote: > > > > -__visible void __irq_entry smp_trace_reschedule_interrupt(struct pt_regs *regs) > > -{ > > - /* > > - * Need to call irq_enter() before calling the trace point. > > - * __smp_reschedule_interrupt() calls irq_enter/exit() too (in > > - * scheduler_ipi(). This is OK, since those functions are allowed > > - * to nest. > > - */ > > - ipi_entering_ack_irq(); > > - trace_reschedule_entry(RESCHEDULE_VECTOR); > > + if (trace_irqvectors_enabled()) { > > + /* > > + * scheduler_ipi() might call irq_enter() as well, but > > + * nested calls are fine. > > + */ > > + irq_enter(); > > + trace_reschedule_entry(RESCHEDULE_VECTOR); > > + } > > + > > inc_irq_stat(irq_resched_count); > > scheduler_ipi(); > > - trace_reschedule_exit(RESCHEDULE_VECTOR); > > - exiting_irq(); > > + > > + if (trace_irqvectors_enabled()) { > > + trace_reschedule_exit(RESCHEDULE_VECTOR); > > + irq_exit(); > > This is racy. If the static key gets changed on one and not the other, > we lose the irq_enter/irq_exit match. Indeed. Good point. Fixed up version below. Thanks, tglx 8<--------------------- --- a/arch/x86/include/asm/hw_irq.h +++ b/arch/x86/include/asm/hw_irq.h @@ -48,7 +48,7 @@ extern asmlinkage void call_function_sin #ifdef CONFIG_TRACING /* Interrupt handlers registered during init_IRQ */ -extern void trace_reschedule_interrupt(void); +#define trace_reschedule_interrupt reschedule_interrupt #define trace_call_function_interrupt call_function_interrupt #define trace_call_function_single_interrupt call_function_single_interrupt #define trace_thermal_interrupt thermal_interrupt --- a/arch/x86/kernel/smp.c +++ b/arch/x86/kernel/smp.c @@ -254,37 +254,27 @@ static void native_stop_other_cpus(int w } /* - * Reschedule call back. + * Reschedule call back. KVM uses this interrupt to force a cpu out of + * guest mode */ -static inline void __smp_reschedule_interrupt(void) -{ - inc_irq_stat(irq_resched_count); - scheduler_ipi(); -} - __visible void __irq_entry smp_reschedule_interrupt(struct pt_regs *regs) { ack_APIC_irq(); - __smp_reschedule_interrupt(); - /* - * KVM uses this interrupt to force a cpu out of guest mode - */ -} - -__visible void __irq_entry smp_trace_reschedule_interrupt(struct pt_regs *regs) -{ - /* - * Need to call irq_enter() before calling the trace point. - * __smp_reschedule_interrupt() calls irq_enter/exit() too (in - * scheduler_ipi(). This is OK, since those functions are allowed - * to nest. - */ - ipi_entering_ack_irq(); - trace_reschedule_entry(RESCHEDULE_VECTOR); inc_irq_stat(irq_resched_count); + + if (trace_irqvectors_enabled()) { + /* + * scheduler_ipi() might call irq_enter() as well, but + * nested calls are fine. + */ + irq_enter(); + trace_reschedule_entry(RESCHEDULE_VECTOR); + scheduler_ipi(); + trace_reschedule_exit(RESCHEDULE_VECTOR); + irq_exit(); + return; + } scheduler_ipi(); - trace_reschedule_exit(RESCHEDULE_VECTOR); - exiting_irq(); } __visible void __irq_entry smp_call_function_interrupt(struct pt_regs *regs)