diff options
author | Wade Cherry <wade.cherry@arm.com> | 2012-02-23 09:56:29 +0000 |
---|---|---|
committer | Jon Medhurst <tixy@linaro.org> | 2012-03-19 09:06:36 +0000 |
commit | 1acaa28b2098f7e2aa8eca492c569e894e1a4b79 (patch) | |
tree | 35efbbbc695ac9249dc4921f767b632f02af5950 | |
parent | 685fec4d4f4fb6bca850be6659e795e8368ce613 (diff) |
gator/daemon: Fix counters initialisation
In certain circumstances counter were not enabled correctly. Fixed.
Signed-off-by: Wade Cherry <wade.cherry@arm.com>
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
-rw-r--r-- | drivers/gator/daemon/Child.cpp | 2 | ||||
-rw-r--r-- | drivers/gator/daemon/Collector.cpp | 27 | ||||
-rw-r--r-- | 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/<types>/enabled + for (int i=0; i<MAX_PERFORMANCE_COUNTERS; i++) { + if (!gSessionData->mPerfCounterEnabled[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/<types> char text[sizeof(gSessionData->mPerfCounterType[0]) + 20]; // sufficiently large to hold all events/<types>/<file> @@ -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; |