From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965175AbbJ1Ig2 (ORCPT ); Wed, 28 Oct 2015 04:36:28 -0400 Received: from mgwkm03.jp.fujitsu.com ([202.219.69.170]:45536 "EHLO mgwkm03.jp.fujitsu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965107AbbJ1Ig0 (ORCPT ); Wed, 28 Oct 2015 04:36:26 -0400 X-Greylist: delayed 603 seconds by postgrey-1.27 at vger.kernel.org; Wed, 28 Oct 2015 04:36:25 EDT X-SecurityPolicyCheck: OK by SHieldMailChecker v2.2.3 X-SHieldMailCheckerPolicyVersion: FJ-ISEC-20140219-2 From: Takao Indoh To: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Alexander Shishkin , Vivek Goyal CC: , Subject: [PATCH 1/2] perf/x86/intel/pt: Add interface to stop Intel PT logging Date: Wed, 28 Oct 2015 17:25:47 +0900 Message-ID: <1446020748-5436-2-git-send-email-indou.takao@jp.fujitsu.com> X-Mailer: git-send-email 2.4.5 In-Reply-To: <1446020748-5436-1-git-send-email-indou.takao@jp.fujitsu.com> References: <1446020748-5436-1-git-send-email-indou.takao@jp.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-SecurityPolicyCheck-GC: OK by FENCE-Mail X-TM-AS-MML: disable Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch add a function for external component to stop Intel PT. Basically this function is used when kernel panic occurs. When it is called, intel_pt driver disables Intel PT and saves its registers using pt_event_stop, which is also used by pmu.stop handler. This function stops Intel PT on the cpu where it is working, therefore user need to call it for each cpu to stop all logging. Signed-off-by: Takao Indoh --- arch/x86/include/asm/intel_pt.h | 10 ++++++++++ arch/x86/kernel/cpu/perf_event_intel_pt.c | 9 +++++++++ 2 files changed, 19 insertions(+), 0 deletions(-) create mode 100644 arch/x86/include/asm/intel_pt.h diff --git a/arch/x86/include/asm/intel_pt.h b/arch/x86/include/asm/intel_pt.h new file mode 100644 index 0000000..3bfe971 --- /dev/null +++ b/arch/x86/include/asm/intel_pt.h @@ -0,0 +1,10 @@ +#ifndef _ASM_X86_INTEL_PT_H +#define _ASM_X86_INTEL_PT_H + +#if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_CPU_SUP_INTEL) +void cpu_emergency_stop_pt(void); +#else +void cpu_emergency_stop_pt(void) {} +#endif + +#endif /* _ASM_X86_INTEL_PT_H */ diff --git a/arch/x86/kernel/cpu/perf_event_intel_pt.c b/arch/x86/kernel/cpu/perf_event_intel_pt.c index 4216928..a638b5b 100644 --- a/arch/x86/kernel/cpu/perf_event_intel_pt.c +++ b/arch/x86/kernel/cpu/perf_event_intel_pt.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "perf_event.h" #include "intel_pt.h" @@ -1125,6 +1126,14 @@ static int pt_event_init(struct perf_event *event) return 0; } +void cpu_emergency_stop_pt(void) +{ + struct pt *pt = this_cpu_ptr(&pt_ctx); + + if (pt->handle.event) + pt_event_stop(pt->handle.event, PERF_EF_UPDATE); +} + static __init int pt_init(void) { int ret, cpu, prior_warn = 0; -- 1.7.1