Commit graph

46 commits

Author SHA1 Message Date
Mark Salyzyn
6290982ee3 init+bootstat: reduce last reboot reason to canonical alias
To make parsing easier for last reboot reason.  This also ensures that
last boot reason matches the content that is typically returned by the
bootloader or in turn landed in the canonical system boot reason.

Simplify parsing in bootstat.  Adjust and fix boot_reason_test.sh for
new reality.  Allow boot reason tests battery and kernel_panic to pass
if device does not support pstore (empty before and after the test).
If device somehow landed in fastboot mode while waiting for the
display, issue a fastboot reboot to move the test along.  Some cleanup
and standardization changes to the test script.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I97d5467c0b4a6d65df3525f1a2d0051db813d5ad
2017-10-10 09:37:59 -07:00
Mark Salyzyn
0af71a5327 bootstat: system_boot_reason does not handle reboot_<reason> case
Heuristic would translate reboot_<reason> to reboot._<reason>. Add
checking/squashing for leading comma (,) _or_ underscore (_).

Test: compile
Bug: 63736262
Change-Id: I7ef4930ec8c064a8151183ac08d292931a8584c8
2017-10-05 14:42:08 -07:00
Mark Salyzyn
161b8626bd init: report shutdown,container for sigterm of init
Change HandleSigtermSignal() handler to report shutdown,container. Add
the new reason to bootstat.  Remove log stutter as
HandlPowerctlMessage will also do a LOG(INFO) reporting
shutdown,container as reason.

Sending SIGTERM to init is to allow a host OS to ask an Android
Container instance to shutdown.  The temptation is to report
shutdown,sigterm but that does not accurately describe the usage
scenario.

Test: compile
Bug: 63736262
Change-Id: I3c5798921bdbef5d2689ad22a2e8103741b570b4
2017-09-27 09:10:00 -07:00
Mark Salyzyn
9033bf5a2e bootstat: Add reboot,userrequested
Result of holding power button down and hitting restart.

Test: compile
Bug: 63736262
Change-Id: I271bdf135cece5fd9dc9e60ddf8add595ed3da4c
2017-09-21 11:30:29 -07:00
Mark Salyzyn
a16e437e9d bootstat: validate last kmsg and bootreason content more carefully
Establish a tighter trust relationship with digitization of the
battery level.  Validate the reboot reason collected from the last
kmsg.  Validate the last reboot reason before using for enhancing
system reboot reason.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63636262
Change-Id: I45fbac4a33c09295cda89de3b73c93a884033e3b
2017-09-20 11:28:02 -07:00
Mark Salyzyn
14b1e6d63d bootstat: clang-format rebase
Code style has drifted too far from our current clang-format
settings.

Test: compile
Side-Effects: none
Bug: 63736262
Change-Id: Ie390459db123cfadf09aa06c8dafb1ae69a72af8
2017-09-20 11:27:56 -07:00
Mark Salyzyn
6461089bf8 bootstat: refine kernel panic details
If bootloader reports kernel_panic, gives us permission for a
deeper check of which kind occurred.  Resolve a problem with
some kernels that do not have the 'sysrq: SysRq :' log stutter.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: Idb8978de7a4f4e3c671c6ab7efc5ebe841f7bbd8
2017-09-19 16:30:05 -07:00
Mark Salyzyn
08b0256ea1 bootstat: reboot cold, warm and hard tests failed
If the bootloader insists on reporting reboot for cold, warm and
hard, we need to reconstruct canonical reason from the
persist.sys.boot.reason property.

Some log lines contained bootstate, letting their noise through
during testing, changed regex to look for bootstat[^e].

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I3788c6cf8aca7fc73dd01bf95acb596d18ed7ee4
2017-09-18 21:03:10 +00:00
James Hawkins
5240f204ed bootstat: Log the ro.boot.bootreason property through the new platform_reason Tron field.
Bug: 63584589
Test: none
Change-Id: Ifd6f3d4432d764b5ffc7db10dec5e573214f7c97
2017-09-15 16:01:57 -07:00
Mark Salyzyn
277eca138b adb: reboot: last boot command default
For reboot [reboot_arg] requests via either reboot or adb reboot,
if reboot_arg is empty then report "shell" or "adb" respectively.

Test: boot_reason_test.sh shell_reboot adb_reboot
Bug: 63736262
Change-Id: Ie613d9e62db6a705885e4e7520aede27af3aa1b9
2017-09-12 12:24:02 -07:00
Mark Salyzyn
b304f6d4e7 bootstat: introduce sys.boot.reason
Adding functionality to bootstat --record_boot_complete and
--record_boot_reason to initialize sys.boot.reason, the canonical
system boot reason.

Filter out ro.boot.bootreason oem noise into sys.boot.reason.  Add
heuristics to determine what the boot reason is, when otherwise would
be defaulting to the blunt and relatively devoid of detail catch-all
reboot reasons ("reboot", "shutdown", "cold", "warm", "hard").

boot_reason_test.sh is also a compliance test.

Test: boot_reason_test.sh all
Bug: 63736262
Change-Id: Ic9a42cccbcfc89a5c0e081ba66d577a97c8c8c76
2017-09-12 09:28:25 -07:00
James Hawkins
8d7f63da26 bootstat: Log even more boot reasons.
Bug: 27555866
Test: None
Change-Id: I8ab6597a323f5973d8b1c22c2c7422ef0c2efcc3
2017-07-25 15:58:48 -07:00
Yongqin Liu
78b2b94d1d bootstat.cpp: update help message for --record_boot_complete
add description about --record_boot_complete in the help

Test: manually with HiKey

Change-Id: I521d6f5b9d98113c006fc6ab146b6c353ce2390c
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
2017-07-07 15:27:10 +00:00
James Hawkins
0bc4ad479a bootstat: Log factory_reset_boot_complete separately from ota_*.
Bug: 37164359
Test: none
Change-Id: I7ed68e299846050fdffa58db8d2bd35fe4599dbb
2017-05-30 15:03:15 -07:00
James Hawkins
1bfcaec1ab bootstat: Calculate and log the absolute device boot time.
Bug: 38345538
Test: None
Change-Id: I76a4b831cc3809d37b7edfcf1b5657cdf363832a
2017-05-23 14:43:49 -07:00
James Hawkins
e78ea77f69 bootstat: Refactor init/utils/boot_clock into base/chrono_utils.
Use this for bootstat and init. This replaces the custom uptime parser in
bootstat.

This is a reland of aosp/338325 with a stubbed implementation for Darwin.

This change also has clang_format fixes (automatic).

Bug: 34352037
Test: chrono_utils_test
Change-Id: I72a62a3ca1ccfc0a4ccc6294ff1776c263144686
2017-03-30 14:24:12 -07:00
James Hawkins
6b5c5aa067 bootstat: Report the total bootloader time.
Bug: 35207415
Test: none
Change-Id: Id948a3b35bb3d96dc875d0a4eea869c86a71a657
2017-02-16 11:53:03 -08:00
James Hawkins
c8ac067773 Revert "bootstat: Refactor init/utils/boot_clock into base/chrono_utils."
This reverts commit 7c92e48450.

Mac sdk still broken (despite testing locally).

Change-Id: I7d9206e15997cd0efe081bd3fa17d53d2b20ec32
2017-02-14 19:20:20 +00:00
James Hawkins
7c92e48450 bootstat: Refactor init/utils/boot_clock into base/chrono_utils.
Use this for bootstat and init. This replaces the custom uptime parser in
bootstat.

This is a reland of aosp/332854 with a fix for Darwin.

Bug: 34352037
Test: chrono_utils_test
Change-Id: Ib2567d8df0e460ab59753ac1c053dd7f9f1008a7
2017-02-13 15:47:21 -08:00
James Hawkins
64984aaa6e Merge "libmetricslogger: Refactor Tron metrics histogram logging out of bootstat." 2017-02-13 18:41:23 +00:00
James Hawkins
0e3167e203 Revert "bootstat: Remove custom uptime parser in favor of elapsedRealtime."
This reverts commit 26f40c04c3.

This change broke the Darwin SDK target.

Test: none
Change-Id: Ia54fe2c31da8d8fa2825e023b035fb8321dcd457
2017-02-08 14:16:51 -08:00
James Hawkins
26f40c04c3 bootstat: Remove custom uptime parser in favor of elapsedRealtime.
Refactored init/utils/boot_clock into base/chrono_utils.

Bug: 34352037
Test: none
Change-Id: Ied0c00867336b85922369d7ff37520e3d28fc61e
2017-02-07 15:43:32 -08:00
James Hawkins
be46fd1b94 bootstat: Log bootloader timing metrics to Tron.
Bug: 34944249
Test: None
Change-Id: Ica6d87c8631a6cc8d70a01186686381f9dc352f9
2017-02-02 16:28:25 -08:00
James Hawkins
9aec926f86 libmetricslogger: Refactor Tron metrics histogram logging out of
bootstat.

To be shared with other native components that want to log histograms.

Bug: 34456830
Test: libmetricslogger_test
Change-Id: I94a1a91c6d33e443d66bc480158dc2470d6c9031
2017-01-31 11:42:24 -08:00
James Hawkins
27c052263c boottime/init: Report ro.boottime.init* properties in milliseconds.
* Nanosecond precision ended up being harder to grok.
* This change modifies the Timer class to have duration_ms instead of
duration_ns.

Bug: 34466121
Test: adb logcat | grep bootstat
Change-Id: Ibd1c27dc3cb29d838a956e342281b2fb98d752a6
2017-01-27 08:26:14 -08:00
James Hawkins
ef0a090e6f bootstat: Log ro.boottime.init timing properties.
Bug: none
Test: adb logcat | grep bootstat
Change-Id: I3375c75e8ef39be710c8001f19a9e2fb493805e9
2017-01-06 14:52:52 -08:00
Mark Salyzyn
343b76e449 bootstat: drop event_log_list_builder
Use android_log_event_context class instead

Test: manual
Bug: 31456426
Bug: 31750617
Bug: 30465923
Change-Id: I8c58d6bdd1fd921f32a1a6f42bec38937833c0e4
2016-10-24 11:13:16 -07:00
Elliott Hughes
da46b392f1 Move off std::sto* function which abort on failure.
Bug: http://b/31403370
Test: builds, boots, libbase tests pass
Change-Id: I89cd7ca3d8f1c8a1bad0ddf3043439449d19a293
2016-10-13 15:34:05 -07:00
Mark Salyzyn
ff2dcd9af9 system/core Replace log/log.h with android/log.h
Should use android/log.h instead of log/log.h as a good example
to all others.  Adjust header order to comply with Android Coding
standards.

Test: Compile
Bug: 26552300
Bug: 31289077
Change-Id: I33a8fb4e754d2dc4754d335660c450e0a67190fc
2016-09-30 12:47:05 -07:00
James Hawkins
4dded613b3 bootstat: Fix a potential unhandled exception for malformed input.
In rare cases the hardware storage on the device may be hosed and return
garbage.  Use ParseInt which handles bad input instead of stoi.

BUG: 29334139
Change-Id: I91aedc169df110bea8097775f73dda11def22311
2016-07-28 11:59:22 -07:00
James Hawkins
2d8b3e66c6 bootstat: Calculate and log the time_since_last_boot metric.
Bug: 28163811
Change-Id: I2e1350531f6a0fc891c270cfdfca6c8ad63f8040
2016-04-15 08:44:01 -07:00
James Hawkins
b9cf77159a bootstat: Differentiate system update boot times.
Bug: 27454343
Change-Id: Idb2e6f55ad7dda546a486954201619bb73cee6b0
2016-04-08 15:32:19 -07:00
James Hawkins
fff95ba5dd bootstat: Two changes to aid in debugging TimeSinceFactoryReset.
* Also log to the BootEventRecordStore to check lossiness.
* Log factory_reset_current_time_failure separately.

Bug: 27550578
Change-Id: Id3d579a74a59ac28290cb7d6048765519f9ba59b
2016-03-29 16:13:49 -07:00
James Hawkins
6f28299d0d bootstat: Track record inconsistencies w/ a debug metric, bootstat_mtime_matches_content.
Fixed a file descriptor leak while I was in here.

Bug: 27550578
Change-Id: I8e252e4f5bb3c4e2ae96a1560fbb32ae636722a0
2016-03-22 16:02:01 -07:00
James Hawkins
c627558a48 bootstat: Add a value option to allow recording an associated value for a boot event.
This has been useful in debugging, but I could see it being used
practically.

Change-Id: Ied6e23d0f7a1bc39f606b2dba88fea92adc31bda
2016-03-22 11:45:59 -07:00
James Hawkins
c08e996ac8 bootstat: Disambiguate boot time on encrypted devices.
This change introduces new metrics to discern boot time on encrypted devices:
* post_decrypt_time_elapsed
* boot_decryption_complete
* boot_complete_post_decrypt
* boot_complete_no_encryption

Bug: 27497357
Change-Id: I8d3a411029bd6a45f80589ff67c408593e133a87
2016-03-11 15:50:39 -08:00
James Hawkins
a347cde386 Merge "bootstat: Add more debug logging metrics to RecordFactoryReset." 2016-03-09 16:34:25 +00:00
James Hawkins
45ead35222 bootstat: Add more strings to the bootreason mapping.
Bug: 27555866
Change-Id: Ieebacaa9369a744d0968b3483c4302ed47bdf9f6
2016-03-08 16:42:07 -08:00
James Hawkins
0660b307b8 bootstat: Add more debug logging metrics to RecordFactoryReset.
In an effort to track down the source of some wonky data being reported.

Bug: 27550578
Change-Id: I1f08447c0203e7982d1b44bc04b531e96358c223
2016-03-08 16:18:15 -08:00
James Hawkins
3bf9b147f2 bootstat: Don't log time_since_factory_reset on device reset.
The zero value is meaningless and skews the histogram buckets.

Bug: 27477664
Change-Id: Idd641aa3005819905a2ecf664d2a5781dbbff59b
2016-03-03 14:50:24 -08:00
James Hawkins
53684ea625 bootstat: Record the time since factory reset on init.
Bug: 25448351
Change-Id: I71905a598e74f41c18a96d469c7a6ddd5a2e07fb
2016-02-24 11:01:03 -08:00
James Hawkins
500d71566a bootstat: Record metrics for factory_reset and time_since_factory_reset.
Bug: 25448351
Change-Id: I9b3a557317bc256a078f76e2b65d16bc071e4a6a
2016-02-16 16:19:48 -08:00
James Hawkins
6f74c0b843 bootstat: Add a few more bootreasons and rebase the index against index 1.
This is necessary to match the mapping in the internal infrastructure.

Bug: 21724738
Change-Id: I292166ff5c0dea7f3d771627120f16af4c56073b
2016-02-13 09:54:35 -08:00
James Hawkins
a4a1a4ac85 bootstat: Add support for logging the boot_reason metric.
This value is read from the ro.boot.bootreason system property.

Bug: 21724738
Change-Id: I43bef3d85ba9c8d87669a91da1aa675d9a86e348
2016-02-09 15:32:38 -08:00
James Hawkins
eabe08b55e bootstat: Fix the base includes to be AOSP-friendly.
Change-Id: I625cc55b41f5258addf3bb74bcef42063c565465
Bug: 21724738
2016-01-20 01:28:48 +00:00
James Hawkins
abd73e6179 system/core: Add initial implementation of the bootstat command.
The bootstat command enables the measurement and logging of boot time
metrics
for GMS devices.

BUG:21724738
Change-Id: I331456dd38a60fb4ef24a4d5320909dbad30db66
2016-01-19 15:10:38 -08:00