summaryrefslogtreecommitdiff
path: root/perfprofd/cpuconfig.h
diff options
context:
space:
mode:
Diffstat (limited to 'perfprofd/cpuconfig.h')
-rw-r--r--perfprofd/cpuconfig.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/perfprofd/cpuconfig.h b/perfprofd/cpuconfig.h
new file mode 100644
index 00000000..bc5b5cf9
--- /dev/null
+++ b/perfprofd/cpuconfig.h
@@ -0,0 +1,50 @@
+/*
+**
+** Copyright 2015, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+//
+// Helper class to perform cpu setup (if needed) prior to a profile collection.
+//
+class HardwireCpuHelper {
+ public:
+
+ // The constructor for this class checks to see if the 'mpdecision'
+ // service is running; if so (and if 'perform' is TRUE), then it
+ // disables the service and on-lines all of the available cores/cpus
+ // (anything listed in /sys/devices/system/cpu/possible). The
+ // destructor will re-enable the mpdecision service if it was
+ // previously disabled.
+ explicit HardwireCpuHelper(bool perform);
+ virtual ~HardwireCpuHelper();
+
+ private:
+ bool mpdecision_stopped_;
+
+ // Collect the number of available cpus/cores from /sys/devices/system/cpu/possible
+ int GetNumCores();
+
+ // Returns TRUE if the system service 'mpdecision' is running
+ bool GetMpdecisionRunning();
+
+ // Online/offline the specified cpu
+ void OnlineCore(int whichCore, int onoff);
+
+ // Enable/disable the mpdecision service via the equivalent of
+ // setprop ctl.start mpdecision
+ // setprop ctl.stop mpdecision
+ void StopMpdecision();
+ void RestartMpdecision();
+};