From 1acaa28b2098f7e2aa8eca492c569e894e1a4b79 Mon Sep 17 00:00:00 2001 From: Wade Cherry Date: Thu, 23 Feb 2012 09:56:29 +0000 Subject: gator/daemon: Fix counters initialisation In certain circumstances counter were not enabled correctly. Fixed. Signed-off-by: Wade Cherry Signed-off-by: Pawel Moll Signed-off-by: Jon Medhurst --- drivers/gator/daemon/Child.cpp | 2 +- drivers/gator/daemon/Collector.cpp | 27 +++++++++++++++++++++------ drivers/gator/daemon/Collector.h | 1 + 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/drivers/gator/daemon/Child.cpp b/drivers/gator/daemon/Child.cpp index fe5a1f061f9..ddf105b8d31 100644 --- a/drivers/gator/daemon/Child.cpp +++ b/drivers/gator/daemon/Child.cpp @@ -226,7 +226,7 @@ void Child::run() { } // Write configuration into the driver - collector->enablePerfCounters(); + collector->setupPerfCounters(); // Create user-space buffers int fifoBufferSize = collector->getBufferSize(); diff --git a/drivers/gator/daemon/Collector.cpp b/drivers/gator/daemon/Collector.cpp index c6f837628f1..7a41198e5cb 100644 --- a/drivers/gator/daemon/Collector.cpp +++ b/drivers/gator/daemon/Collector.cpp @@ -46,10 +46,14 @@ Collector::Collector() { getCoreName(); + enablePerfCounters(); + // Read unchanging keys from driver which are created at insmod'ing of gator.ko for (int i = 0; i < MAX_PERFORMANCE_COUNTERS; i++) { - snprintf(text, sizeof(text), "events/%s/key", gSessionData->mPerfCounterType[i]); - readIntDriver(text, &gSessionData->mPerfCounterKey[i]); + if (gSessionData->mPerfCounterEnabled[i]) { + snprintf(text, sizeof(text), "events/%s/key", gSessionData->mPerfCounterType[i]); + readIntDriver(text, &gSessionData->mPerfCounterKey[i]); + } } } @@ -64,6 +68,21 @@ Collector::~Collector() { } void Collector::enablePerfCounters() { + char text[sizeof(gSessionData->mPerfCounterType[0]) + 30]; // sufficiently large to hold all /dev/gator/events//enabled + for (int i=0; imPerfCounterEnabled[i]) { + continue; + } + snprintf(text, sizeof(text), "events/%s/enabled", gSessionData->mPerfCounterType[i]); + if (writeReadDriver(text, &gSessionData->mPerfCounterEnabled[i])) { + // Disable those events that don't exist on this hardware platform even though they exist in configuration.xml + gSessionData->mPerfCounterEnabled[i] = 0; + continue; + } + } +} + +void Collector::setupPerfCounters() { char base[sizeof(gSessionData->mPerfCounterType[0]) + 10]; // sufficiently large to hold all events/ char text[sizeof(gSessionData->mPerfCounterType[0]) + 20]; // sufficiently large to hold all events// @@ -86,10 +105,6 @@ void Collector::enablePerfCounters() { handleException(); } } - snprintf(text, sizeof(text), "%s/enabled", base); - if (writeReadDriver(text, &gSessionData->mPerfCounterEnabled[i])) { - gSessionData->mPerfCounterEnabled[i] = 0; - } } } diff --git a/drivers/gator/daemon/Collector.h b/drivers/gator/daemon/Collector.h index 1cfe84e1b97..6c80725ad94 100644 --- a/drivers/gator/daemon/Collector.h +++ b/drivers/gator/daemon/Collector.h @@ -19,6 +19,7 @@ public: void stop(); int collect(char* buffer); void enablePerfCounters(); + void setupPerfCounters(); int getBufferSize() {return bufferSize;} private: int bufferSize; -- cgit v1.2.3