From patchwork Tue Dec 4 06:07:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: rajagopal.venkat@linaro.org X-Patchwork-Id: 13353 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 24A152427A for ; Tue, 4 Dec 2012 06:11:44 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 90164A18B27 for ; Tue, 4 Dec 2012 06:11:43 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id c10so5364798ieb.11 for ; Mon, 03 Dec 2012 22:11:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=ZWokgHUF9nQpLJAuo4Wada8p1/iseRbfqBSDW2Q9DBE=; b=phcgqR3TGSQQWsWjm7IcgvcogG4ZZfy9GMn1sb8wgd/kK6nTwwa4J/1tQm+jZ55pzv fw97KiOTKCBfX0R9EGKLiNjsXVHQhvDiPNhfKuG8DgzjRIP99AbT3tjLqLI4m89tuuPJ RfQ2VNGoT6/8FB0OOvTaCZCXbMXJLn3VQYheXiasHxQs6Iv8j0jdixl/PKtp9N/w6Nnn i220VeOI0xf2eMTxjJnw/7jIsrr75wLrbFo46k9NBTyHbq7BWOL0GcCDDiY10Bv98wYq hXk/UpVFZFbrkemGMeaPdZFgotT8t7IsnKwV+fCZEb/7BjSfAIgLA5m6mOtbyAWM6KGx itcg== Received: by 10.50.152.137 with SMTP id uy9mr1511914igb.62.1354601502780; Mon, 03 Dec 2012 22:11:42 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp246702igt; Mon, 3 Dec 2012 22:11:42 -0800 (PST) Received: by 10.69.0.8 with SMTP id au8mr36218940pbd.58.1354601501806; Mon, 03 Dec 2012 22:11:41 -0800 (PST) Received: from mail-pb0-f46.google.com (mail-pb0-f46.google.com [209.85.160.46]) by mx.google.com with ESMTPS id bd1si327511pab.305.2012.12.03.22.11.40 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 03 Dec 2012 22:11:41 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.46 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) client-ip=209.85.160.46; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.46 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) smtp.mail=rajagopal.venkat@linaro.org Received: by mail-pb0-f46.google.com with SMTP id wy7so2479811pbc.33 for ; Mon, 03 Dec 2012 22:11:40 -0800 (PST) Received: by 10.68.253.226 with SMTP id ad2mr35815486pbd.38.1354601500723; Mon, 03 Dec 2012 22:11:40 -0800 (PST) Received: from localhost.localdomain ([101.63.108.195]) by mx.google.com with ESMTPS id o5sm204804paz.32.2012.12.03.22.11.33 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 03 Dec 2012 22:11:39 -0800 (PST) From: Rajagopal Venkat To: powertop@lists.01.org Cc: patches@linaro.org, linaro-dev@lists.linaro.org, Rajagopal Venkat Subject: [Powertop][PATCH v1] Allow frequency stats when cpuidle is not enabled Date: Tue, 4 Dec 2012 11:37:31 +0530 Message-Id: <1354601251-5722-1-git-send-email-rajagopal.venkat@linaro.org> X-Mailer: git-send-email 1.7.11.3 X-Gm-Message-State: ALoCoQlKuaqAjR1D8XJpvtMbgGPIoDjzaAK0Y8VdhX8j5EQYVd1VB8x0rQHHouKfAQAiYUTLiDZp Powertop fails to display frequency stats when cpuidle subsystem is not enabled. Fix it. Signed-off-by: Rajagopal Venkat --- src/cpu/cpu.h | 7 ++++++- src/cpu/cpu_linux.cpp | 36 +++++++++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index 4480b11..781e33c 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -159,7 +159,12 @@ extern vector all_cpus; class cpu_linux: public abstract_cpu { - void account_freq(uint64_t frequency, uint64_t duration); + void account_freq(uint64_t frequency, uint64_t duration); + void parse_pstates_start(void); + void parse_cstates_start(void); + void parse_pstates_end(void); + void parse_cstates_end(void); + public: virtual void measurement_start(void); virtual void measurement_end(void); diff --git a/src/cpu/cpu_linux.cpp b/src/cpu/cpu_linux.cpp index d6caf45..e7a3d37 100644 --- a/src/cpu/cpu_linux.cpp +++ b/src/cpu/cpu_linux.cpp @@ -47,17 +47,13 @@ static int is_turbo(uint64_t freq, uint64_t max, uint64_t maxmo) return 1; } -void cpu_linux::measurement_start(void) +void cpu_linux::parse_cstates_start(void) { ifstream file; - DIR *dir; struct dirent *entry; char filename[256]; int len; - unsigned int i; - - abstract_cpu::measurement_start(); len = sprintf(filename, "/sys/devices/system/cpu/cpu%i/cpuidle", number); @@ -111,9 +107,16 @@ void cpu_linux::measurement_start(void) } closedir(dir); +} - last_stamp = 0; +void cpu_linux::parse_pstates_start(void) +{ + ifstream file; + char filename[256]; + unsigned int i; + + last_stamp = 0; for (i = 0; i < children.size(); i++) if (children[i]) children[i]->wiggle(); @@ -136,8 +139,14 @@ void cpu_linux::measurement_start(void) account_freq(0, 0); } +void cpu_linux::measurement_start(void) +{ + abstract_cpu::measurement_start(); + parse_cstates_start(); + parse_pstates_start(); +} -void cpu_linux::measurement_end(void) +void cpu_linux::parse_cstates_end(void) { DIR *dir; struct dirent *entry; @@ -187,6 +196,12 @@ void cpu_linux::measurement_end(void) } closedir(dir); +} + +void cpu_linux::parse_pstates_end(void) +{ + char filename[256]; + ifstream file; sprintf(filename, "/sys/devices/system/cpu/cpu%i/cpufreq/stats/time_in_state", number); @@ -216,12 +231,15 @@ void cpu_linux::measurement_end(void) } file.close(); } +} - +void cpu_linux::measurement_end(void) +{ + parse_cstates_end(); + parse_pstates_end(); abstract_cpu::measurement_end(); } - char * cpu_linux::fill_cstate_line(int line_nr, char *buffer, const char *separator) { unsigned int i;