From patchwork Wed Jun 1 12:35:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepthi Dharwar X-Patchwork-Id: 839832 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 p51CcAHG005454 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Wed, 1 Jun 2011 12:38:30 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 p51CaAUa007209; Wed, 1 Jun 2011 05:36:11 -0700 Received: from e23smtp08.au.ibm.com (e23smtp08.au.ibm.com [202.81.31.141]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p51Ca4SB007188 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Wed, 1 Jun 2011 05:36:06 -0700 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [202.81.31.245]) by e23smtp08.au.ibm.com (8.14.4/8.13.1) with ESMTP id p51CUtQI013396 for ; Wed, 1 Jun 2011 22:30:55 +1000 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p51Ca2581265668 for ; Wed, 1 Jun 2011 22:36:02 +1000 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p51Ca267012201 for ; Wed, 1 Jun 2011 22:36:02 +1000 Received: from deepthi.in.ibm.com ([9.124.35.88]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p51CZtPT012085 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 1 Jun 2011 22:36:01 +1000 Date: Wed, 1 Jun 2011 18:05:54 +0530 From: Deepthi Dharwar To: linuxppc-dev@ozlabs.org, linux-pm@lists.linux-foundation.org, linux-kernel@vger.kernel.org Message-ID: <20110601123554.GA12492@deepthi.in.ibm.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Received-SPF: pass (localhost is always allowed.) X-Spam-Status: No, hits=-6.312 required=5 tests=BAYES_00, OSDL_HEADER_SUBJECT_BRACKETED, PATCH_SUBJECT_OSDL 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 Subject: [linux-pm] [PATCH] perf_events: Enable idle state tracing for pseries (ppc64) X-BeenThere: linux-pm@lists.linux-foundation.org X-Mailman-Version: 2.1.9 Precedence: list Reply-To: deepthi@linux.vnet.ibm.com 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]); Wed, 01 Jun 2011 12:38:30 +0000 (UTC) Hi, Please find below a patch, which has perf_events added for pseries (ppc64) platform in order to emit the trace required for perf timechart. It essentially enables perf timechart for pseries platfrom to analyse power savings events like cpuidle states. Steps to enable and disable the trace; 1) Mount debugfs; mount -t debugfs none /sys/kernel/debug 2) Then, enable the event using; echo 1 > /sys/kernel/debug/tracing/events/power/cpu_idle/enable 3) The output of the trace can be seen in /sys/kernel/debug/tracing/trace 4) To disable the trace use; echo 0 > sys/kernel/debug/tracing/events/power/cpu_idle/enable Trace .svg o/p can be viewed for pseries (ppc64) systems showing various cpu-idle states as a part of perf timechart tool. References: http://blog.fenrus.org/?p=5 Issue command 'perf timechart record' to enable tracing. This generates the trace and records in perf.data file by default. One can generate output.svg file by issuing 'perf timechart'. Sample o/p from the trace file: =============================== State 1 -> Snooze State 2 -> Cede # tracer: nop # TASK-PID CPU# TIMESTAMP FUNCTION | | | | | -0 [000] 292.482314: cpu_idle: state=1 cpu_id=0 ^^ Enter Snooze -0 [001] 292.482363: cpu_idle: state=1 cpu_id=1 -0 [000] 292.492315: cpu_idle: state=4294967295 cpu_id=0 ^^ Exit Snooze -0 [000] 292.492316: cpu_idle: state=2 cpu_id=0 ^^ Enter Cede -0 [001] 292.492364: cpu_idle: state=4294967295 cpu_id=1 -0 [001] 292.492364: cpu_idle: state=2 cpu_id=1 -0 [000] 292.504198: cpu_idle: state=4294967295 cpu_id=0 ^^Exit Cede -0 [000] 292.504204: cpu_idle: state=1 cpu_id=0 -0 [001] 292.504921: cpu_idle: state=4294967295 cpu_id=1 -0 [001] 292.504936: cpu_idle: state=1 cpu_id=1 -0 [000] 292.514205: cpu_idle: state=4294967295 cpu_id=0 This patch applies on 2.6.39 and tested on a IBM POWER7 machine. -Deepthi Adding perf events to trace various cpu idle states on ppc64 (pseries) platform. Signed-off-by: Deepthi Dharwar pseries.h | 4 ++++ setup.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+) Index: linux-2.6.39/arch/powerpc/platforms/pseries/setup.c =================================================================== --- linux-2.6.39.orig/arch/powerpc/platforms/pseries/setup.c 2011-05-19 00:06:34.000000000 -0400 +++ linux-2.6.39/arch/powerpc/platforms/pseries/setup.c 2011-06-01 07:46:00.000000000 -0400 @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -582,6 +583,10 @@ * while, do so. */ if (snooze) { + + trace_power_start(POWER_CSTATE, CPU_IDLE_SNOOZE, cpu); + trace_cpu_idle(CPU_IDLE_SNOOZE, cpu); + start_snooze = get_tb() + snooze * tb_ticks_per_usec; local_irq_enable(); set_thread_flag(TIF_POLLING_NRFLAG); @@ -602,9 +607,19 @@ goto out; } + trace_power_end(cpu); + trace_cpu_idle(PWR_EVENT_EXIT, cpu); + + trace_power_start(POWER_CSTATE, CPU_IDLE_CEDE, cpu); + trace_cpu_idle(CPU_IDLE_CEDE, cpu); + cede_processor(); out: + + trace_power_end(cpu); + trace_cpu_idle(PWR_EVENT_EXIT, cpu); + HMT_medium(); out_purr = mfspr(SPRN_PURR); get_lppaca()->wait_state_cycles += out_purr - in_purr; Index: linux-2.6.39/arch/powerpc/platforms/pseries/pseries.h =================================================================== --- linux-2.6.39.orig/arch/powerpc/platforms/pseries/pseries.h 2011-05-19 00:06:34.000000000 -0400 +++ linux-2.6.39/arch/powerpc/platforms/pseries/pseries.h 2011-06-01 07:53:24.000000000 -0400 @@ -12,6 +12,9 @@ #include +#define CPU_IDLE_SNOOZE 1 +#define CPU_IDLE_CEDE 2 + struct device_node; extern void request_event_sources_irqs(struct device_node *np, @@ -56,4 +59,5 @@ extern int dlpar_attach_node(struct device_node *); extern int dlpar_detach_node(struct device_node *); + #endif /* _PSERIES_PSERIES_H */