mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-01-29 01:17:04 +00:00
Let the default Atrace HAL support /sys/kernel/tracing
With this change, atrace HAL will look for tracefs in /sys/kernel/tracing first and /sys/kernel/debug/tracing second. Test: systrace Bug: 185427606 Change-Id: Iccc5af92db222dc422a527c14b1f2fb7bc4e7746
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/stringprintf.h>
|
||||
|
||||
#include "AtraceDevice.h"
|
||||
|
||||
@@ -39,15 +40,11 @@ const std::map<std::string, TracingConfig> kTracingMap = {
|
||||
// gfx
|
||||
{
|
||||
"gfx",
|
||||
{"Graphics",
|
||||
{{"/sys/kernel/debug/tracing/events/mdss/enable", false},
|
||||
{"/sys/kernel/debug/tracing/events/sde/enable", false},
|
||||
{"/sys/kernel/debug/tracing/events/mali_systrace/enable", false}}},
|
||||
{"Graphics", {{"mdss", false}, {"sde", false}, {"mali_systrace", false}}},
|
||||
},
|
||||
{
|
||||
"ion",
|
||||
{"ION allocation",
|
||||
{{"/sys/kernel/debug/tracing/events/kmem/ion_alloc_buffer_start/enable", false}}},
|
||||
{"ION allocation", {{"kmem/ion_alloc_buffer_start", false}}},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -65,16 +62,31 @@ Return<void> AtraceDevice::listCategories(listCategories_cb _hidl_cb) {
|
||||
return Void();
|
||||
}
|
||||
|
||||
AtraceDevice::AtraceDevice() {
|
||||
struct stat st;
|
||||
|
||||
tracefs_event_root_ = "/sys/kernel/tracing/events/";
|
||||
if (stat(tracefs_event_root_.c_str(), &st) != 0) {
|
||||
tracefs_event_root_ = "/sys/kernel/debug/tracing/events/";
|
||||
CHECK(stat(tracefs_event_root_.c_str(), &st) == 0) << "tracefs must be mounted at either"
|
||||
"/sys/kernel/tracing or "
|
||||
"/sys/kernel/debug/tracing";
|
||||
}
|
||||
}
|
||||
|
||||
Return<::android::hardware::atrace::V1_0::Status> AtraceDevice::enableCategories(
|
||||
const hidl_vec<hidl_string>& categories) {
|
||||
const hidl_vec<hidl_string>& categories) {
|
||||
if (!categories.size()) {
|
||||
return Status::ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
for (auto& c : categories) {
|
||||
if (kTracingMap.count(c)) {
|
||||
for (auto& p : kTracingMap.at(c).paths) {
|
||||
if (!android::base::WriteStringToFile("1", p.first)) {
|
||||
LOG(ERROR) << "Failed to enable tracing on: " << p.first;
|
||||
std::string tracefs_event_enable_path = android::base::StringPrintf(
|
||||
"%s%s/enable", tracefs_event_root_.c_str(), p.first.c_str());
|
||||
if (!android::base::WriteStringToFile("1", tracefs_event_enable_path)) {
|
||||
LOG(ERROR) << "Failed to enable tracing on: " << tracefs_event_enable_path;
|
||||
if (p.second) {
|
||||
// disable before return
|
||||
disableAllCategories();
|
||||
@@ -91,10 +103,13 @@ Return<::android::hardware::atrace::V1_0::Status> AtraceDevice::enableCategories
|
||||
|
||||
Return<::android::hardware::atrace::V1_0::Status> AtraceDevice::disableAllCategories() {
|
||||
auto ret = Status::SUCCESS;
|
||||
|
||||
for (auto& c : kTracingMap) {
|
||||
for (auto& p : c.second.paths) {
|
||||
if (!android::base::WriteStringToFile("0", p.first)) {
|
||||
LOG(ERROR) << "Failed to disable tracing on: " << p.first;
|
||||
std::string tracefs_event_enable_path = android::base::StringPrintf(
|
||||
"%s%s/enable", tracefs_event_root_.c_str(), p.first.c_str());
|
||||
if (!android::base::WriteStringToFile("0", tracefs_event_enable_path)) {
|
||||
LOG(ERROR) << "Failed to disable tracing on: " << tracefs_event_enable_path;
|
||||
if (p.second) {
|
||||
ret = Status::ERROR_TRACING_POINT;
|
||||
}
|
||||
|
||||
@@ -36,12 +36,16 @@ using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
|
||||
struct AtraceDevice : public IAtraceDevice {
|
||||
AtraceDevice();
|
||||
// Methods from ::android::hardware::atrace::V1_0::IAtraceDevice follow.
|
||||
Return<void> listCategories(listCategories_cb _hidl_cb) override;
|
||||
Return<::android::hardware::atrace::V1_0::Status> enableCategories(
|
||||
const hidl_vec<hidl_string>& categories) override;
|
||||
Return<::android::hardware::atrace::V1_0::Status> disableAllCategories() override;
|
||||
|
||||
private:
|
||||
std::string tracefs_event_root_;
|
||||
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
};
|
||||
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
on late-init
|
||||
# vendor graphics trace points
|
||||
chmod 0666 /sys/kernel/debug/tracing/events/sde/enable
|
||||
chmod 0666 /sys/kernel/tracing/events/sde/enable
|
||||
chmod 0666 /sys/kernel/debug/tracing/events/mdss/enable
|
||||
chmod 0666 /sys/kernel/tracing/events/mdss/enable
|
||||
chmod 0666 /sys/kernel/debug/tracing/events/mali_systrace/enable
|
||||
chmod 0666 /sys/kernel/tracing/events/mali_systrace/enable
|
||||
# ion allocation trace point
|
||||
chmod 0666 /sys/kernel/debug/tracing/events/kmem/ion_alloc_buffer_start/enable
|
||||
chmod 0666 /sys/kernel/tracing/events/kmem/ion_alloc_buffer_start/enable
|
||||
|
||||
service vendor.atrace-hal-1-0 /vendor/bin/hw/android.hardware.atrace@1.0-service
|
||||
interface android.hardware.atrace@1.0::IAtraceDevice default
|
||||
|
||||
Reference in New Issue
Block a user