Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755631AbdCaVvT (ORCPT ); Fri, 31 Mar 2017 17:51:19 -0400 Received: from mail-it0-f47.google.com ([209.85.214.47]:37188 "EHLO mail-it0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751571AbdCaVvQ (ORCPT ); Fri, 31 Mar 2017 17:51:16 -0400 MIME-Version: 1.0 In-Reply-To: <1490293551-5552-1-git-send-email-kan.liang@intel.com> References: <1490293551-5552-1-git-send-email-kan.liang@intel.com> From: Stephane Eranian Date: Fri, 31 Mar 2017 14:51:15 -0700 Message-ID: Subject: Re: [PATCH 0/3]measure SMI cost To: "Liang, Kan" Cc: Peter Zijlstra , "mingo@redhat.com" , Arnaldo Carvalho de Melo , LKML , Thomas Gleixner , Jiri Olsa , "ak@linux.intel.com" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2041 Lines: 53 On Thu, Mar 23, 2017 at 11:25 AM, wrote: > From: Kan Liang > > Currently, there is no way to measure the time cost in System management > mode (SMM) by perf. > > Intel perfmon supports FREEZE_WHILE_SMM bit in IA32_DEBUGCTL. Once it sets, > the PMU core counters will freeze on SMI handler. But it will not have an > effect on free running counters. E.g. APERF counter. > The cost of SMI can be measured by (aperf - cycles). > > A new sysfs entry /sys/device/cpu/freeze_on_smi is introduced to set > FREEZE_WHILE_SMM bit in IA32_DEBUGCTL. > > A new --smi-cost mode in perf stat is implemented to measure the SMI cost > by calculating cycles and aperf results. In practice, the percentages of > SMI cycles should be more useful than absolute value. So the output will be > the percentage of SMI cycles and SMI#. > You are talking about the percentage of what cycles? Wallclock, unhalted_ref_cycles, unhalted_core_cycles? I > Here is an example output. > > Performance counter stats for 'sudo echo ': > > SMI cycles% SMI# > 0.1% 1 > > 0.010858678 seconds time elapsed > > > Kan Liang (3): > perf/x86: add sysfs entry to freeze counter on SMI > tools lib api fs: Add sysfs__write_int function > perf stat: Add support to measure SMI cost > > arch/x86/events/core.c | 10 +++++++ > arch/x86/events/intel/core.c | 48 ++++++++++++++++++++++++++++++++++ > arch/x86/events/perf_event.h | 3 +++ > arch/x86/include/asm/msr-index.h | 1 + > tools/lib/api/fs/fs.c | 29 ++++++++++++++++++++ > tools/lib/api/fs/fs.h | 4 +++ > tools/perf/Documentation/perf-stat.txt | 9 +++++++ > tools/perf/builtin-stat.c | 48 ++++++++++++++++++++++++++++++++++ > tools/perf/util/stat-shadow.c | 33 +++++++++++++++++++++++ > tools/perf/util/stat.c | 2 ++ > tools/perf/util/stat.h | 2 ++ > 11 files changed, 189 insertions(+) > > -- > 2.7.4 >