The current version of powertop does not check if a timer is
deferred. So deferred timers will be displayed as a power consumer
This patch utilizes the /proc/timer_stats to determine if a timer
is deferred. If it is the timer is not considered in the powertop
statistics.
---
process/do_process.cpp | 3 +++
process/timer.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++
process/timer.h | 1 +
3 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/process/do_process.cpp b/process/do_process.cpp
index b5c1558..ec0ac6a 100644
--- a/process/do_process.cpp
+++ b/process/do_process.cpp
@@ -360,6 +360,9 @@ void perf_process_bundle::handle_trace_point(int type, void
*trace, int cpu, uin
tmr = (struct timer_expire *)trace;
timer = find_create_timer((uint64_t)tmr->function);
+
+ if (timer->is_deferred())
+ return;
push_consumer(cpu, timer);
timer->fire(time, (uint64_t)tmr->timer);
diff --git a/process/timer.cpp b/process/timer.cpp
index c888be4..ae0cc03 100644
--- a/process/timer.cpp
+++ b/process/timer.cpp
@@ -112,3 +112,50 @@ void clear_timers(void)
it = all_timers.begin();
}
}
+
+bool get_timerstats(void)
+{
+ FILE *file;
+ file = fopen("/proc/timer_stats", "w");
+ if (!file) {
+ return false;
+ }
+ fprintf(file, "1\n");
+ fclose(file);
+ return true;
+}
+
+bool timer::is_deferred(void)
+{
+ FILE *file;
+ char line[4096];
+
+ if (!get_timerstats()){
+ return false;
+ }
+ file = fopen("/proc/timer_stats", "r");
+ if (!file) {
+ return false;
+ }
+
+ while (file && !feof(file)) {
+ char *c;
+ if (fgets(line, 4096,file)== NULL)
+ break;
+ if (strstr(line, "total events"))
+ break;
+ if (!handler)
+ break;
+ if (strstr(line, handler)){
+ c = strchr(line, ',');
+ if (!c)
+ continue;
+ c--;
+ if (*c == 'D')
+ return true;
+ }
+ }
+ fclose(file);
+ return false;
+}
+
diff --git a/process/timer.h b/process/timer.h
index 5ff3efd..d7455e3 100644
--- a/process/timer.h
+++ b/process/timer.h
@@ -39,6 +39,7 @@ public:
void fire(uint64_t time, uint64_t timer_struct);
uint64_t done(uint64_t time, uint64_t timer_struct);
+ bool is_deferred(void);
virtual const char * description(void);
virtual const char * name(void) { return "timer"; };
--
1.7.0.4
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
_______________________________________________
Power mailing list
[email protected]
https://bughost.org/mailman/listinfo/power