From 2b0742ec9da3d64dd90d6ccdc5e4902d0a7a32ec Mon Sep 17 00:00:00 2001 From: Ziyi Cui Date: Fri, 25 Nov 2022 05:22:15 +0000 Subject: [PATCH 1/3] gs-common:dumpstate: Dump long irq metrics, resume latency metrics at bugreport Create pixel_metrics to support bugreport for metrics Bug: 227809911 Bug: 232541623 Test: Test: "adb bugreport" includes metrics capture. Change-Id: If62a53b5ffa643c37c287f8ba0319de1d6b07529 Signed-off-by: Ziyi Cui --- pixel_metrics/Android.bp | 10 ++++++++++ pixel_metrics/dump_pixel_metrics.sh | 6 ++++++ pixel_metrics/pixel_metrics.mk | 3 +++ pixel_metrics/sepolicy/device.te | 2 ++ pixel_metrics/sepolicy/dump_pixel_metrics.te | 5 +++++ pixel_metrics/sepolicy/file_contexts | 1 + pixel_metrics/sepolicy/genfs_contexts | 3 +++ 7 files changed, 30 insertions(+) create mode 100644 pixel_metrics/Android.bp create mode 100644 pixel_metrics/dump_pixel_metrics.sh create mode 100644 pixel_metrics/pixel_metrics.mk create mode 100644 pixel_metrics/sepolicy/device.te create mode 100644 pixel_metrics/sepolicy/dump_pixel_metrics.te create mode 100644 pixel_metrics/sepolicy/file_contexts create mode 100644 pixel_metrics/sepolicy/genfs_contexts diff --git a/pixel_metrics/Android.bp b/pixel_metrics/Android.bp new file mode 100644 index 0000000..3ad3ff4 --- /dev/null +++ b/pixel_metrics/Android.bp @@ -0,0 +1,10 @@ +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +sh_binary { + name: "dump_pixel_metrics.sh", + src: "dump_pixel_metrics.sh", + vendor: true, + sub_dir: "dump", +} diff --git a/pixel_metrics/dump_pixel_metrics.sh b/pixel_metrics/dump_pixel_metrics.sh new file mode 100644 index 0000000..229f618 --- /dev/null +++ b/pixel_metrics/dump_pixel_metrics.sh @@ -0,0 +1,6 @@ +#!/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 + diff --git a/pixel_metrics/pixel_metrics.mk b/pixel_metrics/pixel_metrics.mk new file mode 100644 index 0000000..41e027d --- /dev/null +++ b/pixel_metrics/pixel_metrics.mk @@ -0,0 +1,3 @@ +BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/pixel_metrics/sepolicy + +PRODUCT_PACKAGES += dump_pixel_metrics.sh diff --git a/pixel_metrics/sepolicy/device.te b/pixel_metrics/sepolicy/device.te new file mode 100644 index 0000000..63640e3 --- /dev/null +++ b/pixel_metrics/sepolicy/device.te @@ -0,0 +1,2 @@ +#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 new file mode 100644 index 0000000..681670e --- /dev/null +++ b/pixel_metrics/sepolicy/dump_pixel_metrics.te @@ -0,0 +1,5 @@ +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; diff --git a/pixel_metrics/sepolicy/file_contexts b/pixel_metrics/sepolicy/file_contexts new file mode 100644 index 0000000..1b5b11f --- /dev/null +++ b/pixel_metrics/sepolicy/file_contexts @@ -0,0 +1 @@ +/vendor/bin/dump/dump_pixel_metrics\.sh u:object_r:dump_pixel_metrics_exec:s0 diff --git a/pixel_metrics/sepolicy/genfs_contexts b/pixel_metrics/sepolicy/genfs_contexts new file mode 100644 index 0000000..36882aa --- /dev/null +++ b/pixel_metrics/sepolicy/genfs_contexts @@ -0,0 +1,3 @@ +#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 From 3add9b2b48843d0fc9ccc55da2f2815882aeb78e Mon Sep 17 00:00:00 2001 From: Ziyi Cui Date: Fri, 25 Nov 2022 05:32:35 +0000 Subject: [PATCH 2/3] gs-common:dumpstate: Combine Temperature Residency bugreport to pixel_metrics Bug: 246799997 Test: Test: "adb bugreport" includes temp residency metrics capture. Change-Id: I51eb7f961bd1ddeb0b7cd7bb33d1a19fef9b2c92 --- pixel_metrics/dump_pixel_metrics.sh | 3 ++- pixel_metrics/sepolicy/genfs_contexts | 1 + thermal/dump_thermal.sh | 2 -- thermal/sepolicy/device.te | 2 -- thermal/sepolicy/dump_thermal.te | 3 --- thermal/sepolicy/genfs_contexts | 2 -- 6 files changed, 3 insertions(+), 10 deletions(-) delete mode 100644 thermal/sepolicy/device.te diff --git a/pixel_metrics/dump_pixel_metrics.sh b/pixel_metrics/dump_pixel_metrics.sh index 229f618..0c6e2c2 100644 --- a/pixel_metrics/dump_pixel_metrics.sh +++ b/pixel_metrics/dump_pixel_metrics.sh @@ -3,4 +3,5 @@ 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/sepolicy/genfs_contexts b/pixel_metrics/sepolicy/genfs_contexts index 36882aa..b914014 100644 --- a/pixel_metrics/sepolicy/genfs_contexts +++ b/pixel_metrics/sepolicy/genfs_contexts @@ -1,3 +1,4 @@ #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/temp_residency/temp_residency_all/stats u:object_r:sysfs_vendor_metrics:s0 diff --git a/thermal/dump_thermal.sh b/thermal/dump_thermal.sh index 748753c..2b87da9 100644 --- a/thermal/dump_thermal.sh +++ b/thermal/dump_thermal.sh @@ -44,5 +44,3 @@ echo "TMU_SUB rise thresholds:" cat /sys/module/gs_thermal/parameters/tmu_sub_reg_dump_rise_thres echo "TMU_SUB fall thresholds:" cat /sys/module/gs_thermal/parameters/tmu_sub_reg_dump_fall_thres -echo "Temperature Residency Metrics:" -cat /sys/kernel/metrics/temp_residency/temp_residency_all/stats diff --git a/thermal/sepolicy/device.te b/thermal/sepolicy/device.te deleted file mode 100644 index 63640e3..0000000 --- a/thermal/sepolicy/device.te +++ /dev/null @@ -1,2 +0,0 @@ -#vendor-metrics -type sysfs_vendor_metrics, fs_type, sysfs_type; diff --git a/thermal/sepolicy/dump_thermal.te b/thermal/sepolicy/dump_thermal.te index 930b4dd..c36f7cd 100644 --- a/thermal/sepolicy/dump_thermal.te +++ b/thermal/sepolicy/dump_thermal.te @@ -5,6 +5,3 @@ allow dump_thermal sysfs_thermal:file r_file_perms; allow dump_thermal sysfs_thermal:lnk_file r_file_perms; allow dump_thermal vendor_toolbox_exec:file execute_no_trans; -#vendor-metrics -r_dir_file(dump_thermal, sysfs_vendor_metrics) -allow dump_thermal sysfs_vendor_metrics:lnk_file r_file_perms; diff --git a/thermal/sepolicy/genfs_contexts b/thermal/sepolicy/genfs_contexts index 5cecbd3..1422e63 100644 --- a/thermal/sepolicy/genfs_contexts +++ b/thermal/sepolicy/genfs_contexts @@ -1,5 +1,3 @@ # thermal sysfs files genfscon sysfs /module/gs_thermal/parameters u:object_r:sysfs_thermal:s0 -#vendor-metrics -genfscon sysfs /kernel/metrics/temp_residency/temp_residency_all/stats u:object_r:sysfs_vendor_metrics:s0 From 594463304417281fa1da9738ff7908f7df76754c Mon Sep 17 00:00:00 2001 From: Adam Shih Date: Tue, 29 Nov 2022 07:28:50 +0800 Subject: [PATCH 3/3] Move sysfs_touch to gs-common Bug: 256521567 Test: adb bugreport Change-Id: I2690b19ba1729af53a7d6e4f3f6c4d87f2ebd7eb --- touch/focaltech/sepolicy/file.te | 1 + touch/gti/sepolicy/file.te | 2 ++ touch/lsi/sepolicy/file.te | 2 ++ touch/syna/sepolicy/file.te | 2 ++ 4 files changed, 7 insertions(+) create mode 100644 touch/gti/sepolicy/file.te create mode 100644 touch/lsi/sepolicy/file.te create mode 100644 touch/syna/sepolicy/file.te diff --git a/touch/focaltech/sepolicy/file.te b/touch/focaltech/sepolicy/file.te index 929bf69..c9a0c1f 100644 --- a/touch/focaltech/sepolicy/file.te +++ b/touch/focaltech/sepolicy/file.te @@ -1,2 +1,3 @@ type proc_touch, proc_type, fs_type; +type sysfs_touch, sysfs_type, fs_type; diff --git a/touch/gti/sepolicy/file.te b/touch/gti/sepolicy/file.te new file mode 100644 index 0000000..3e53ec3 --- /dev/null +++ b/touch/gti/sepolicy/file.te @@ -0,0 +1,2 @@ +type sysfs_touch, sysfs_type, fs_type; + diff --git a/touch/lsi/sepolicy/file.te b/touch/lsi/sepolicy/file.te new file mode 100644 index 0000000..3e53ec3 --- /dev/null +++ b/touch/lsi/sepolicy/file.te @@ -0,0 +1,2 @@ +type sysfs_touch, sysfs_type, fs_type; + diff --git a/touch/syna/sepolicy/file.te b/touch/syna/sepolicy/file.te new file mode 100644 index 0000000..3e53ec3 --- /dev/null +++ b/touch/syna/sepolicy/file.te @@ -0,0 +1,2 @@ +type sysfs_touch, sysfs_type, fs_type; +