Commit graph

117 commits

Author SHA1 Message Date
Logan Chien
67afa10231 Merge "Fix PDK build" am: 24e34e4b8e am: 9a393de28f
am: 2dc1f072f2

Change-Id: Ib64a3307ff02481b4fff1500830f75e56eae5815
2018-02-14 03:23:00 +00:00
Logan Chien
4892bbf8d2 Fix PDK build
This commit disables "bootstat" in PDK builds because "bootstat" depends
on "libstatslog" (from "frameworks/base") which is not included in PDK
builds as well.

Test: Build a target (described in http://b/72961456) with
`platform.zip` built from master FSK source tree.

Bug: 72961456
Change-Id: I06b1555694510e17ea82d5c6dfcdeaf99b905e4d
2018-02-14 03:03:28 +00:00
Tej Singh
fe3e762b6d Fix performance degradation from BootSequence atom
Adding the boot sequence reported atom in ag/3518079 caused the duration
of bootstat to increase, as seen in b/72864061. I isolated the cause
down to calling BootReasonStrToReason. However, this function also gets
called in ReportBootReason, so I created another function that does the
parsing and sets the system boot reason property, and made
RecordBootReason and statsd logging get that property.

Bug: 72864061
Test: rebooted phone, verified boot events were received in adb shell
logcat -b stats and verified adb shell bootstat -p printed correct
values. Ran timing tests as well on walleye with 20 boots: before this
change, the average was ~150-160ms. After, it was ~80ms.

Change-Id: I92dbc9880328835647be7d9d50c7861b42f27bdb
2018-02-12 21:42:29 +00:00
TreeHugger Robot
94cde4e86c Merge "Atom: BootSequenceReported" 2018-01-31 04:24:54 +00:00
Tej Singh
4eacd38366 Atom: BootSequenceReported
Logs information about boot time and reason to statsd.
Specifically: bootloader boot reason, system boot reason, bootloader
boot time, total boot time, time that the boot finished, and time since
last boot.

Test: booted the phone and verified "adb logcat -b stats" received the
event

Change-Id: I769df9a09263ed3667f7085c81b3d072e868cbda
2018-01-26 16:14:13 -08:00
James Hawkins
79a4ee260b bootstat: Add more boot reasons.
Bug: none
Test: none
Change-Id: I483e4e2c6ea4219ac21b64a24bfac58c2919a40b
2018-01-26 14:31:04 -08:00
Treehugger Robot
b91021a2a8 Merge "bootstat: Add more boot reasons." 2018-01-09 00:03:22 +00:00
James Hawkins
b607daec94 bootstat: Add more boot reasons.
These appear to be winding down...

Bug: none
Test: none
Change-Id: I00bc84d8e50b1563f97f812f722aa6bdbd6265b2
2018-01-05 14:42:55 -08:00
Ivan Lozano
9ddf491492 Merge "Fix sanitizer errors in bootstat.cpp." 2017-12-21 06:42:55 +00:00
Ivan Lozano
44d3cacfce Fix sanitizer errors in bootstat.cpp.
Integer overflow sanitized builds are throwing an error on the while
loop decrement in the rfind function. This refactors the loop to prevent
decrementing the value on the final iteration.

Test: Compiled and device boots without runtime error.
Bug: 30969751
Change-Id: Ice4532cce933062b3c14adf2d9749cfdea4ad84c
Merged-In: Ice4532cce933062b3c14adf2d9749cfdea4ad84c
2017-12-20 14:59:19 -08:00
Elliott Hughes
579e682628 Add std::string StartsWith*/EndsWith* overloads.
We should have done this from the beginning. Thanks to Windows, we're not
going to be able to switch libbase over to std::string_view any time soon.

Bug: N/A
Test: ran tests
Change-Id: Iff2f56986e39de53f3ac484415378af17dacf26b
2017-12-20 09:42:22 -08:00
James Hawkins
e2c2724aee bootstat: Add tons of new boot reasons.
Bug: none
Test: none
Change-Id: I57e89a20f23d3b3cff2fa6667e25f1c37cb2870c
2017-12-18 13:40:27 -08:00
Elliott Hughes
3289b9c928 Merge "Add OWNERS." 2017-12-07 23:21:26 +00:00
Elliott Hughes
693d63f9cf Add OWNERS.
Bug: N/A
Test: N/A
Change-Id: Ie785058c0f5eb9b4086c98ccba6e63e3ed411b65
2017-12-07 13:30:03 -08:00
James Hawkins
00433a2305 bootstat: Add more boot reasons.
Bug: none
Test: none
Change-Id: I4cc6e2e39b6c5954387006d48f2119211fa37dd5
2017-12-04 14:20:21 -08:00
James Hawkins
f4444f058c bootstat: Add four more boot reasons.
Bug: none
Test: none
Change-Id: Ifd62e3a8bb6142e89fcde819eab1caba3d7933b7
2017-11-30 15:01:40 -08:00
James Hawkins
5f85f8354b bootstat: Three more boot reasons.
Bug: none
Test: none
Change-Id: I37b6ed6ce73f403aa5f9db2c0234e9dc4c0f7c01
2017-11-29 14:30:06 -08:00
James Hawkins
b623389421 Merge "bootstat: Add a few more bootreasons." 2017-11-29 19:29:54 +00:00
James Hawkins
74b1758cad bootstat: Add a few more bootreasons.
Bug: none
Test: none
Change-Id: I9b482e642a9eec26670118a265046194f3cc2a7a
2017-11-28 15:20:44 -08:00
Mark Salyzyn
547063eab6 bootstat: kernel_panic test w/o bootloader or pstore support
If the platform has no bootloader or pstore support, kernel_panic
test should fail if the results are not correct. Drop skipping of
failed test if pstore support is lacking.

If device demonstrably has pstore content support, the result must
be exacting kernel_panic,sysrq. Otherwise accept the less precise
result.

Test: On hikey960 (which currently lacks reliable pstore, or a
      compliant bootloader reporting bootreason), expect failure of:
      system/core/bootstat/boot_reason_test.sh kernel_panic
Bug: 63736262
Change-Id: I071a2a9c00dc522ec037c8a8997fea524d17e6e4
2017-11-20 12:18:09 -08:00
James Hawkins
8ac79bc820 bootstat: Add another boot reason.
Bug: None
Test: None
Change-Id: I865a12e9c8833c4a345284181aa1812be3eddadd
2017-10-31 10:07:34 -07:00
Mark Salyzyn
e7c95fb34f bootstat: test: add error propagation for fastboot format userdata
Test: system/core/bootstat/boot_reason_test.sh optional_factory_reset
Bug: 63736262
Change-Id: I8893df15ef802bb76c0795288df91d8463bfe3d1
2017-10-27 08:32:55 -07:00
Mark Salyzyn
293cb3b217 bootstat: handle a bad bit error rate issue with pstore
Create a private rfind that allows a fuzzy match based on a bit error
rate (BER) of 1 every 8 bits.  last kmsg is affected by pstore ramoops
backing that suffers from data corruption.  Add some additional
validation based on possible data corruption scenarios, as a noisy
match means higher chance of noisy data.

Noisy data notably can affect the battery level detection, but do not
typically result in false positives.  Battery level, or failure, is
the responsibility of the BatteryStats service, providing a positive
signal and strong device-independent algorithm.  The checking done in
bootstat is likely to be deprecated in favour of an API request to
BatteryStats once their algorithms deal with surprise outages due to
aging.

The kernel logging heuristic and BER fixup handily deals with a
prevalent issue where some bootloaders failure to properly notify us
of panics.  This is where the gains are noticed with this improvement.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I93b4210f12fb47c5c036f4d6eb4cafeee4896d35
2017-10-26 14:17:14 -07:00
Mark Salyzyn
747c0e6216 bootstat: better validation of battery level (shutdown,battery)
Replace simple strtoull with loop that ensures no leading zeros.
Restrict size of value buffer being checked as allocation was
going to end of retrieved buffer, which can cause unnecessary
memory pressure during boot.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: Ifdc1d4fd3a73794c001577024ce7cbfde9c25028
2017-10-26 14:17:14 -07:00
Mark Salyzyn
dafced93a5 bootstat: Do not allow unknown boot reasons to land in first field.
If we sniff an unknown boot reason from last kmsg, make sure it
has a "reboot," prefix.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: Ia1c401b8899d1f0c56bd4f5d8d2d19b7fc889a30
2017-10-26 14:14:40 -07:00
Mark Salyzyn
88d692c09e bootstat: move boot reason validation transformation policy into subroutine.
Allow for future policy adjustments.

SideEffects: None
Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I571fb7dafc6b80c75d2809a3da3f9b96784cef06
2017-10-26 14:11:04 -07:00
Mark Salyzyn
72a8ea3d3c bootstat: test: fix Its_Just_So_Hard_reboot
Add the test injection to known list, and deal with an error
propagation issue.

Test: system/core/bootstat/boot_reason_test.sh Its_Just_So_Hard_reboot
Bug: 63736262
Change-Id: I4799956978a8884c69c830fcedd7febd143651fd
2017-10-26 14:10:31 -07:00
Mark Salyzyn
c89f9da060 bootstat: add shutdown,thermal,battery
Test: system/core/bootreason/boot_reason_test.sh
Bug: 63736262
Change-Id: I30d6b5308fd8616eae31ad13e925d66c9fc07367
2017-10-25 15:45:49 -07:00
Mark Salyzyn
cabbe4ff35 bootstat: add reboot,2sec
Test: system/core/bootreason/boot_reason_test.sh
Bug: 63736262
Change-Id: Ie2e5872adb14e0979ff87eb4d2f57ab2849facd4
2017-10-25 15:45:49 -07:00
Mark Salyzyn
2a8e5cce33 bootstat: test: check ro.boot.bootreason in some tests
blind_reboot_test() did not report the ro.boot.bootreason value,
making it more difficult to diagnose failures.

Test: system/core/bootstat/boot_reason_test.sh cold warm hard
Bug: 63736262
Change-Id: I313cfef202b1e06c583b0b47cd5d0e0888a7dbe7
2017-10-25 15:45:49 -07:00
Mark Salyzyn
73691aafc2 bootstat: fix test regression (exec_background)
Deal with regression from 557a9d4054
where bootstat was moved to exec_background and actions delayed
to improve boot time.  Add a 1 second sleep rather than trying to
inspect the dmesg (debug only) for clues to the end of bootstat.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I87dfb6a07130112bf51c367632967efa53ea2534
2017-10-25 15:45:46 -07:00
Mark Salyzyn
bcf66ed699 bootstat: fix test regression (extra logging)
Deal with regression from 9a3870490a
where additional content is logged and should be ignored.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I70709ba5b00ea18a653ff8d1658556b7d4c48775
2017-10-25 15:40:56 -07:00
Treehugger Robot
a03c935e27 Merge "bootstat: Add more boot reasons found by logging in the wild." 2017-10-19 19:41:34 +00:00
James Hawkins
34073b583a bootstat: Add more boot reasons found by logging in the wild.
Bug: none
Test: none
Change-Id: I7e388326be44aeb3e6fdb79d2e173dc17eb8bc1f
2017-10-19 10:44:22 -07:00
Josh Gao
52315ae329 bootstat: remove extraneous android_logcat_destroy.
android_logcat_pclose already does that.

Bug: http://b/67960705
Test: mma
Change-Id: I03d06b10807e8a313c9654c2e1db36bfb59e3f99
2017-10-18 16:57:33 -07:00
Mark Salyzyn
244947e813 bootstat: test: duration fixes
misspelled duration_test in test_thermal_shutdown

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I5981fa899db84199aefb46c8741511e6889bc79c
2017-10-13 09:29:53 -07:00
Mark Salyzyn
9a3870490a bootstat: test: inject ro.boot.bootreason values
Adding a set of automated engineering unit tests with a strict list of
prerequisites.  Not meant for "user" builds.  Must have a crafted
bootloader that does not set the boot reason.  Only works on platforms
where the bootloader either by accident or specifically does not set
the ro.boot.bootreason via kernel command line configuration
androidboot.bootreason=.  If the tests do not have the prerequisites,
the test will report success, but with protest.

These new tests should work on current Hikey and Hikey960 bootloaders
but could very well become obsolete if those platform bootloaders
start setting the boot reason.

We do not want a platform solution as it could allow a third party to
override the bootloader boot reason.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I1793184a8484b83e1d9077475bc65af9816dadf7
2017-10-11 13:48:33 -07:00
Mark Salyzyn
bb52cbf35d Merge "bootstat: test: refine reported test durations" 2017-10-11 20:33:05 +00:00
Mark Salyzyn
444e3a9f74 Merge "bootstat: Add some reserved sys.boot.reason values to enumeration" 2017-10-11 20:32:00 +00:00
Mark Salyzyn
2450cb1a30 bootstat: test: refine reported test durations
Use actual test durations to refine future duration estimates.
Better estimates are cosmetic, but lend confidence to the test
results.

SideEffects: none
Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I49143b78a6dc6fb21838a3d6c70b7eb5a8b4cba5
2017-10-11 10:56:54 -07:00
Mark Salyzyn
243fa29804 bootstat: Add some reserved sys.boot.reason values to enumeration
Add cold,powerkey, warm,s3_wakeup and hard,hw_reset so that
sys.boot.reason values can also be enumerated.  Also add
some reserved speculative entries associated with forced
suspend to RAM and DISK; shutdown,suspend and shutdown,hibernate
respectively.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 67636061
Change-Id: Ic43523748e6006aaca882f8eec7c1f0c08431bd8
2017-10-11 10:56:42 -07:00
James Hawkins
25f7122512 bootstat: Special case logging for empty boot reason.
Empty boot reason is mostly unexpected but may take up the bulk of
unknown reported boot reason values.

Bug: none
Test: none
Change-Id: I9978658c2b052d5cf5d28299861b0d1125ba9fc0
2017-10-10 16:37:05 -07:00
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
557a9d4054 bootstat: reduce overall boot time
Run bootstat as a oneshot service rather than as a series of inline
exec commands.  exec commands impact boot time.

Test: cts-tradefed run cts-dev --module CtsBootStatsTestCases
      system/core/bootstat/boot_reason_test.sh all
         (make sure it filters out new init reports)
Bug: 65736247
Change-Id: Ic9d509a8cbee4bc1e278081de1001e25ae0915fd
2017-09-19 07:36:34 -07:00