From 9e92e70fc1745ce777f069adef55ea89f57ccdb0 Mon Sep 17 00:00:00 2001 From: Ziyi Cui Date: Tue, 6 Jun 2023 00:35:29 +0000 Subject: sepolicy: Enable path reading for storm_irq Test: adb bugreport Bug: 279486693 Change-Id: Id16dc3cf20a3373e8c00231d637537911a3b5b0e Signed-off-by: Ziyi Cui --- pixel_metrics/sepolicy/genfs_contexts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pixel_metrics/sepolicy/genfs_contexts b/pixel_metrics/sepolicy/genfs_contexts index b17bb4a..3be226a 100644 --- a/pixel_metrics/sepolicy/genfs_contexts +++ b/pixel_metrics/sepolicy/genfs_contexts @@ -1,6 +1,6 @@ #vendor-metrics genfscon sysfs /kernel/metrics/resume_latency/resume_latency_metrics u:object_r:sysfs_vendor_metrics:s0 genfscon sysfs /kernel/metrics/irq/long_irq_metrics u:object_r:sysfs_vendor_metrics:s0 - +genfscon sysfs /kernel/metrics/irq/storm_irq_metrics u:object_r:sysfs_vendor_metrics:s0 genfscon sysfs /kernel/metrics/thermal/tr_by_group/tmu/stats u:object_r:sysfs_vendor_metrics:s0 genfscon sysfs /kernel/metrics/thermal/tr_by_group/spmic/stats u:object_r:sysfs_vendor_metrics:s0 -- cgit v1.2.3 From 717622c5bdb4fad594776c629df1e4aff37b24b0 Mon Sep 17 00:00:00 2001 From: Ziyi Cui Date: Tue, 6 Jun 2023 00:20:47 +0000 Subject: gs-common: dumpstate: Rewrite dump_pixel_metrics to cpp Test: adb bugreport Bug: 279486693 Change-Id: Ia1611db82440e2a1a522269b363d8931b08f0fe5 Signed-off-by: Ziyi Cui --- pixel_metrics/Android.bp | 18 ++++++++++++++---- pixel_metrics/dump_pixel_metrics.cpp | 26 ++++++++++++++++++++++++++ pixel_metrics/dump_pixel_metrics.sh | 7 ------- pixel_metrics/pixel_metrics.mk | 2 +- pixel_metrics/sepolicy/device.te | 2 -- pixel_metrics/sepolicy/dump_pixel_metrics.te | 2 +- pixel_metrics/sepolicy/file.te | 2 ++ pixel_metrics/sepolicy/file_contexts | 2 +- 8 files changed, 45 insertions(+), 16 deletions(-) create mode 100644 pixel_metrics/dump_pixel_metrics.cpp delete mode 100644 pixel_metrics/dump_pixel_metrics.sh delete mode 100644 pixel_metrics/sepolicy/device.te create mode 100644 pixel_metrics/sepolicy/file.te diff --git a/pixel_metrics/Android.bp b/pixel_metrics/Android.bp index 3ad3ff4..04d83f3 100644 --- a/pixel_metrics/Android.bp +++ b/pixel_metrics/Android.bp @@ -2,9 +2,19 @@ package { default_applicable_licenses: ["Android-Apache-2.0"], } -sh_binary { - name: "dump_pixel_metrics.sh", - src: "dump_pixel_metrics.sh", +cc_binary { + name: "dump_pixel_metrics", + srcs: ["dump_pixel_metrics.cpp"], + cflags: [ + "-Wall", + "-Wextra", + "-Werror", + ], + shared_libs: [ + "libbase", + "libdump", + "liblog", + ], vendor: true, - sub_dir: "dump", + relative_install_path: "dump", } diff --git a/pixel_metrics/dump_pixel_metrics.cpp b/pixel_metrics/dump_pixel_metrics.cpp new file mode 100644 index 0000000..9a8f6e7 --- /dev/null +++ b/pixel_metrics/dump_pixel_metrics.cpp @@ -0,0 +1,26 @@ +/* + * Copyright 2022 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. + */ +#include +#include + + +int main() { + setbuf(stdout, NULL); + dumpFileContent("Long running IRQ metrics", "/sys/kernel/metrics/irq/long_irq_metrics"); + dumpFileContent("Resume latency metrics", "/sys/kernel/metrics/resume_latency/resume_latency_metrics"); + return 0; +} + diff --git a/pixel_metrics/dump_pixel_metrics.sh b/pixel_metrics/dump_pixel_metrics.sh deleted file mode 100644 index 0c6e2c2..0000000 --- a/pixel_metrics/dump_pixel_metrics.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/vendor/bin/sh -echo "Long running IRQ metrics" -cat /sys/kernel/metrics/irq/long_irq_metrics -echo "Resume latency metrics" -cat /sys/kernel/metrics/resume_latency/resume_latency_metrics -echo "Temperature Residency Metrics:" -cat /sys/kernel/metrics/temp_residency/temp_residency_all/stats diff --git a/pixel_metrics/pixel_metrics.mk b/pixel_metrics/pixel_metrics.mk index 41e027d..736ddf3 100644 --- a/pixel_metrics/pixel_metrics.mk +++ b/pixel_metrics/pixel_metrics.mk @@ -1,3 +1,3 @@ BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/pixel_metrics/sepolicy -PRODUCT_PACKAGES += dump_pixel_metrics.sh +PRODUCT_PACKAGES += dump_pixel_metrics diff --git a/pixel_metrics/sepolicy/device.te b/pixel_metrics/sepolicy/device.te deleted file mode 100644 index 63640e3..0000000 --- a/pixel_metrics/sepolicy/device.te +++ /dev/null @@ -1,2 +0,0 @@ -#vendor-metrics -type sysfs_vendor_metrics, fs_type, sysfs_type; diff --git a/pixel_metrics/sepolicy/dump_pixel_metrics.te b/pixel_metrics/sepolicy/dump_pixel_metrics.te index 681670e..903a8e3 100644 --- a/pixel_metrics/sepolicy/dump_pixel_metrics.te +++ b/pixel_metrics/sepolicy/dump_pixel_metrics.te @@ -2,4 +2,4 @@ pixel_bugreport(dump_pixel_metrics) #vendor-metrics r_dir_file(dump_pixel_metrics, sysfs_vendor_metrics) -allow dump_pixel_metrics vendor_toolbox_exec:file execute_no_trans; +allow dump_pixel_metrics vendor_dumpsys:file execute_no_trans; diff --git a/pixel_metrics/sepolicy/file.te b/pixel_metrics/sepolicy/file.te new file mode 100644 index 0000000..63640e3 --- /dev/null +++ b/pixel_metrics/sepolicy/file.te @@ -0,0 +1,2 @@ +#vendor-metrics +type sysfs_vendor_metrics, fs_type, sysfs_type; diff --git a/pixel_metrics/sepolicy/file_contexts b/pixel_metrics/sepolicy/file_contexts index 1b5b11f..966055f 100644 --- a/pixel_metrics/sepolicy/file_contexts +++ b/pixel_metrics/sepolicy/file_contexts @@ -1 +1 @@ -/vendor/bin/dump/dump_pixel_metrics\.sh u:object_r:dump_pixel_metrics_exec:s0 +/vendor/bin/dump/dump_pixel_metrics u:object_r:dump_pixel_metrics_exec:s0 -- cgit v1.2.3 From d5972765b223cdf800a948e6dd048e34ab0ee52f Mon Sep 17 00:00:00 2001 From: Ziyi Cui Date: Tue, 6 Jun 2023 04:10:09 +0000 Subject: gs-common: dumpstate: Add storm_irq_metrics into bugreport Test: adb bugreport Bug: 279486693 Change-Id: I05cba0c7bf8ef0c211d6ddf5fa4a6d148b8afc1f Signed-off-by: Ziyi Cui --- pixel_metrics/dump_pixel_metrics.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/pixel_metrics/dump_pixel_metrics.cpp b/pixel_metrics/dump_pixel_metrics.cpp index 9a8f6e7..2dd5553 100644 --- a/pixel_metrics/dump_pixel_metrics.cpp +++ b/pixel_metrics/dump_pixel_metrics.cpp @@ -20,6 +20,7 @@ int main() { setbuf(stdout, NULL); dumpFileContent("Long running IRQ metrics", "/sys/kernel/metrics/irq/long_irq_metrics"); + dumpFileContent("Storm IRQ metrics", "/sys/kernel/metrics/irq/storm_irq_metrics"); dumpFileContent("Resume latency metrics", "/sys/kernel/metrics/resume_latency/resume_latency_metrics"); return 0; } -- cgit v1.2.3