summaryrefslogtreecommitdiffstats
path: root/pixelstats
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@google.com>2020-02-27 12:11:12 -0800
committerJaegeuk Kim <jaegeuk@google.com>2020-03-18 09:48:45 -0700
commit17c1b6984844d9074aa1ea94056f093357a2f5cf (patch)
tree0f04a14f2a47c1c39bf88405066eace6db3dcf24 /pixelstats
parentb25bfed553f679786fefdaa11af446d16c3f57ae (diff)
downloadplatform_hardware_google_pixel-17c1b6984844d9074aa1ea94056f093357a2f5cf.tar.gz
platform_hardware_google_pixel-17c1b6984844d9074aa1ea94056f093357a2f5cf.tar.bz2
platform_hardware_google_pixel-17c1b6984844d9074aa1ea94056f093357a2f5cf.zip
pixelstats: Upload fsck/mount/checkpoint value
- elapsed time of fsck - mounted time of f2fs - elapsed time to disable checkpoint Bug: 146053658 Bug: 149844577 Signed-off-by: Jaegeuk Kim <jaegeuk@google.com> Change-Id: I2e1ea44a49a563d118f14376ead50cff74861df7
Diffstat (limited to 'pixelstats')
-rw-r--r--pixelstats/SysfsCollector.cpp67
-rw-r--r--pixelstats/include/pixelstats/SysfsCollector.h3
-rw-r--r--pixelstats/pixelatoms.proto11
3 files changed, 75 insertions, 6 deletions
diff --git a/pixelstats/SysfsCollector.cpp b/pixelstats/SysfsCollector.cpp
index 86b2960..f9ae928 100644
--- a/pixelstats/SysfsCollector.cpp
+++ b/pixelstats/SysfsCollector.cpp
@@ -29,6 +29,7 @@
#include <utils/Timers.h>
#include <sys/timerfd.h>
+#include <mntent.h>
#include <string>
namespace android {
@@ -51,6 +52,7 @@ using android::hardware::google::pixel::PixelAtoms::StorageUfsHealth;
using android::hardware::google::pixel::PixelAtoms::F2fsStatsInfo;
using android::hardware::google::pixel::PixelAtoms::ZramMmStat;
using android::hardware::google::pixel::PixelAtoms::ZramBdStat;
+using android::hardware::google::pixel::PixelAtoms::BootStatsInfo;
SysfsCollector::SysfsCollector(const struct SysfsPaths &sysfs_paths)
: kSlowioReadCntPath(sysfs_paths.SlowioReadCntPath),
@@ -339,6 +341,22 @@ void SysfsCollector::logUFSLifetime() {
}
}
+static std::string getUserDataBlock() {
+ std::unique_ptr<std::FILE, int (*)(std::FILE*)> fp(setmntent("/proc/mounts", "re"), endmntent);
+ if (fp == nullptr) {
+ ALOGE("Error opening /proc/mounts");
+ return "";
+ }
+
+ mntent* mentry;
+ while ((mentry = getmntent(fp.get())) != nullptr) {
+ if (strcmp(mentry->mnt_dir, "/data") == 0) {
+ return std::string(basename(mentry->mnt_fsname));
+ }
+ }
+ return "";
+}
+
void SysfsCollector::logF2fsStats() {
std::string userdataBlock;
int dirty, free, cp_calls_fg, gc_calls_fg, moved_block_fg, vblocks;
@@ -349,12 +367,7 @@ void SysfsCollector::logF2fsStats() {
return;
}
- if (kUserdataBlockProp == nullptr) {
- ALOGE("Userdata block property not specified");
- return;
- }
-
- userdataBlock = android::base::GetProperty(kUserdataBlockProp, "");
+ userdataBlock = getUserDataBlock();
if (!ReadFileToInt(kF2fsStatsPath + (userdataBlock + "/dirty_segments"), &dirty)) {
ALOGV("Unable to read dirty segments");
@@ -521,6 +534,44 @@ void SysfsCollector::logZramStats() {
reportZramBdStat();
}
+void SysfsCollector::logBootStats() {
+ std::string userdataBlock = getUserDataBlock();
+ int mounted_time_sec = 0;
+ if (!ReadFileToInt(kF2fsStatsPath + (userdataBlock + "/mounted_time_sec"), &mounted_time_sec)) {
+ ALOGV("Unable to read mounted_time_sec");
+ return;
+ }
+
+ int fsck_time_ms = android::base::GetIntProperty("ro.boottime.init.fsck.data", 0);
+ int checkpoint_time_ms = android::base::GetIntProperty("ro.boottime.init.mount.data", 0);
+
+ if (fsck_time_ms == 0 && checkpoint_time_ms == 0) {
+ ALOGV("Not yet initialized");
+ return;
+ }
+
+ // Load values array
+ std::vector<VendorAtom::Value> values(3);
+ VendorAtom::Value tmp;
+ tmp.intValue(mounted_time_sec);
+ values[BootStatsInfo::kMountedTimeSecFieldNumber - kVendorAtomOffset] = tmp;
+ tmp.intValue(fsck_time_ms / 1000);
+ values[BootStatsInfo::kFsckTimeSecFieldNumber - kVendorAtomOffset] = tmp;
+ tmp.intValue(checkpoint_time_ms / 1000);
+ values[BootStatsInfo::kCheckpointTimeSecFieldNumber - kVendorAtomOffset] = tmp;
+
+ // Send vendor atom to IStats HAL
+ VendorAtom event = {.reverseDomainName = PixelAtoms::ReverseDomainNames().pixel(),
+ .atomId = PixelAtoms::Ids::BOOT_STATS,
+ .values = values};
+ Return<void> ret = stats_->reportVendorAtom(event);
+ if (!ret.isOk()) {
+ ALOGE("Unable to report Boot stats to Stats service");
+ } else {
+ log_once_reported = true;
+ }
+}
+
void SysfsCollector::logAll() {
stats_ = IStats::tryGetService();
if (!stats_) {
@@ -528,6 +579,10 @@ void SysfsCollector::logAll() {
return;
}
+ // Collect once per service init; can be multiple due to service reinit
+ if (!log_once_reported) {
+ logBootStats();
+ }
logBatteryChargeCycles();
logCodecFailed();
logCodec1Failed();
diff --git a/pixelstats/include/pixelstats/SysfsCollector.h b/pixelstats/include/pixelstats/SysfsCollector.h
index 7ae1592..c6cc608 100644
--- a/pixelstats/include/pixelstats/SysfsCollector.h
+++ b/pixelstats/include/pixelstats/SysfsCollector.h
@@ -70,6 +70,7 @@ class SysfsCollector {
void logUFSLifetime();
void logF2fsStats();
void logZramStats();
+ void logBootStats();
void reportSlowIoFromFile(const char *path, const SlowIo::IoOperation &operation_s);
void reportZramMmStat();
@@ -101,6 +102,8 @@ class SysfsCollector {
// store everything in the values array at the index of the field number
// -2.
const int kVendorAtomOffset = 2;
+
+ bool log_once_reported = false;
};
} // namespace pixel
diff --git a/pixelstats/pixelatoms.proto b/pixelstats/pixelatoms.proto
index ac2c684..86d18f2 100644
--- a/pixelstats/pixelatoms.proto
+++ b/pixelstats/pixelatoms.proto
@@ -41,6 +41,7 @@ enum Ids {
F2FS_STATS = 105004;
ZRAM_MM_STAT = 105005;
ZRAM_BD_STAT = 105006;
+ BOOT_STATS = 105007;
// AOSP atom ID range ends at 109999
}
@@ -186,3 +187,13 @@ message ZramBdStat {
/* The number of pages written to backing device */
optional int64 bd_writes = 4;
}
+
+/* A message containing boot times */
+message BootStatsInfo {
+ /* The F2FS fsck time in secs */
+ optional int32 fsck_time_sec = 2;
+ /* The F2FS mounted time in secs */
+ optional int32 mounted_time_sec = 3;
+ /* The F2FS checkpoint=disable time in secs */
+ optional int32 checkpoint_time_sec = 4;
+}