Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752306AbbGUGCA (ORCPT ); Tue, 21 Jul 2015 02:02:00 -0400 Received: from mail-lb0-f178.google.com ([209.85.217.178]:34085 "EHLO mail-lb0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751131AbbGUGB7 (ORCPT ); Tue, 21 Jul 2015 02:01:59 -0400 MIME-Version: 1.0 In-Reply-To: References: <1437407346-31186-1-git-send-email-kan.liang@intel.com> From: Andy Lutomirski Date: Mon, 20 Jul 2015 23:01:38 -0700 Message-ID: Subject: Re: [PATCH RFC V2 1/1] x86, perf: Add a freq pmu driver To: Stephane Eranian Cc: Kan Liang , Peter Zijlstra , "mingo@redhat.com" , Arnaldo Carvalho de Melo , "ak@linux.intel.com" , Mark Rutland , Adrian Hunter , David Ahern , Jiri Olsa , Namhyung Kim , LKML , Andy Lutomirski 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: 1403 Lines: 37 On Mon, Jul 20, 2015 at 8:10 PM, Stephane Eranian wrote: > On Mon, Jul 20, 2015 at 8:49 AM, Kan Liang wrote: >> From: Andy Lutomirski >> >> This patch adds freq PMU to support time and freq related counters >> includes TSC, IA32_APERF, IA32_MPERF and IA32_PPERF. >> >> The events are exposed in sysfs for use by perf stat and other tools. >> The files are under /sys/devices/freq/events/ >> >> These events only support system-wide mode counting. >> >> The PMU type (attr->type) is PERF_TYPE_FREQ. >> >> Example: >> >> To caculate the CPU% >> CPU_Utilization = CPU_CLK_UNHALTED.REF_TSC / TSC >> >> $ perf stat -e '{ref-cycles,freq/tsc/}' -C0 -- taskset -c 0 sleep 1 >> 3164023,,ref-cycles,1048387386,100.00 >> 2410812089,,freq/tsc/,1050022373,100.00 >> The CPU% for sleep is 0.13%. >> > This event is system-wide only. Thus, the kernel should return > an error when you try to use it in per-thread mode. That would > be more consistent with RAPL and uncore events. I don't know enough about perf's inner workings to be sure, but can't perf context switch free-running counters like this? --Andy -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/