From patchwork Thu May 26 08:34:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 820152 Received: from smtp1.linux-foundation.org (smtp1.linux-foundation.org [140.211.169.13]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4Q8ka4J009126 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Thu, 26 May 2011 08:46:57 GMT Received: from daredevil.linux-foundation.org (localhost [127.0.0.1]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p4Q8i9th025628; Thu, 26 May 2011 01:44:41 -0700 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p4Q8a01T024536 for ; Thu, 26 May 2011 01:36:02 -0700 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 26 May 2011 01:36:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.65,272,1304319600"; d="scan'208";a="5200428" Received: from rui.sh.intel.com (HELO [10.239.36.62]) ([10.239.36.62]) by orsmga001.jf.intel.com with ESMTP; 26 May 2011 01:35:55 -0700 From: Zhang Rui To: LKML , linux-pm Date: Thu, 26 May 2011 16:34:15 +0800 Message-ID: <1306398855.2207.156.camel@rui> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Received-SPF: pass (localhost is always allowed.) X-Spam-Status: No, hits=-104.079 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SUBJECT_BRACKETED, USER_IN_WHITELIST X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.21 Cc: acme@redhat.com, mingo@elte.hu, a.p.zijlstra@chello.nl, ming.m.lin@intel.com Subject: [linux-pm] [PATCH 3/3] show energy consumption info in perf tool X-BeenThere: linux-pm@lists.linux-foundation.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux power management List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 26 May 2011 08:46:57 +0000 (UTC) Introduce four new perf software events PERF_COUNT_SW_PKG_ENERGY PERF_COUNT_SW_CORE_ENERGY PERF_COUNT_SW_UNCORE_ENERGY and PERF_COUNT_SW_DRAM_ENERGY To use it, users can run perf stat -e pkg-energy foo to get the package energy consumption when running foo. Signed-off-by: Zhang Rui --- tools/perf/design.txt | 4 ++++ tools/perf/util/parse-events.c | 8 ++++++++ 2 files changed, 12 insertions(+) Index: linux-2.6/tools/perf/design.txt =================================================================== --- linux-2.6.orig/tools/perf/design.txt +++ linux-2.6/tools/perf/design.txt @@ -139,6 +139,10 @@ enum sw_event_ids { PERF_COUNT_SW_PAGE_FAULTS_MAJ = 6, PERF_COUNT_SW_ALIGNMENT_FAULTS = 7, PERF_COUNT_SW_EMULATION_FAULTS = 8, + PERF_COUNT_SW_PKG_ENERGY = 9, + PERF_COUNT_SW_CORE_ENERGY = 10, + PERF_COUNT_SW_UNCORE_ENERGY = 11, + PERF_COUNT_SW_DRAM_ENERGY = 12, }; Counters of the type PERF_TYPE_TRACEPOINT are available when the ftrace event Index: linux-2.6/tools/perf/util/parse-events.c =================================================================== --- linux-2.6.orig/tools/perf/util/parse-events.c +++ linux-2.6/tools/perf/util/parse-events.c @@ -50,6 +50,10 @@ static struct event_symbol event_symbols { CSW(CPU_MIGRATIONS), "cpu-migrations", "migrations" }, { CSW(ALIGNMENT_FAULTS), "alignment-faults", "" }, { CSW(EMULATION_FAULTS), "emulation-faults", "" }, + { CSW(PKG_ENERGY), "pkg-energy", "" }, + { CSW(CORE_ENERGY), "core-energy", "" }, + { CSW(UNCORE_ENERGY), "uncore-energy", "" }, + { CSW(DRAM_ENERGY), "dram-energy", "" }, }; #define __PERF_EVENT_FIELD(config, name) \ @@ -82,6 +86,10 @@ static const char *sw_event_names[PERF_C "major-faults", "alignment-faults", "emulation-faults", + "package-energy-consumption", + "core-energy-consumption", + "uncore-energy-consumption", + "dram-energy-consumption", }; #define MAX_ALIASES 8