Report kernel_panic,sysrq,livelock,<state> reboot reason via last
dmesg (pstore console). Add ro.llk.killtest property, which will
allow reliable ABA platforms to drop kill test and go directly
to kernel panic. This should also allow some manual unit testing
of the canonical boot reason report.
New canonical boot reasons from llkd are:
- kernel_panic,sysrq,livelock,alarm llkd itself locked up (Hail Mary)
- kernel_panic,sysrq,livelock,driver uninterrruptible D state
- kernel_panic,sysrq,livelock,zombie uninterrruptible Z state
Manual test assumptions:
- llkd is built by the platform and landed on system partition
- unit test is built and landed in /data/nativetest (could
land in /data/nativetest64, adjust test correspondingly)
- llkd not enabled, ro.llk.enable and ro.llk.killtest
are not set by platform allowing test to adjust all the
configuration properties and start llkd.
- or, llkd is enabled, ro.llk.enable is true, and killtest is
disabled, ro.llk.killtest is false, setup by the platform.
This breaks the go/apct generic operations of the unit test
for llk.zombie and llk.driver as kernel panic results
requiring manual intervention otherwise. If test moves to
go/apct, then we will be forced to bypass these tests under
this condition (but allow them to run if ro.llk.killtest
is "off" so specific testing above/below can be run).
for i in driver zombie; do
adb shell su root setprop ro.llk.killtest off
adb shell /data/nativetest/llkd_unit_test/llkd_unit_test --gtest_filter=llkd.${i}
adb wait-for-device
adb shell su root setprop ro.llk.killtest off
sleep 60
adb shell getprop sys.boot.reason
adb shell /data/nativetest/llkd_unit_test/llkd_unit_test --gtest_filter=llkd.${i}
done
Test: llkd_unit_test (see test assumptions)
Bug: 33808187
Bug: 72838192
Change-Id: I2b24875376ddfdbc282ba3da5c5b3567de85dbc0
80 lines
3 KiB
C++
80 lines
3 KiB
C++
/*
|
|
* Copyright (C) 2018 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.
|
|
*/
|
|
|
|
#ifndef _LLKD_H_
|
|
#define _LLKD_H_
|
|
|
|
#ifndef LOG_TAG
|
|
#define LOG_TAG "livelock"
|
|
#endif
|
|
|
|
#include <stdbool.h>
|
|
#include <sys/cdefs.h>
|
|
|
|
__BEGIN_DECLS
|
|
|
|
bool llkInit(const char* threadname); /* threadname NULL, not spawned */
|
|
unsigned llkCheckMilliseconds(void);
|
|
|
|
/* clang-format off */
|
|
#define LLK_ENABLE_WRITEABLE_PROPERTY "llk.enable"
|
|
#define LLK_ENABLE_PROPERTY "ro." LLK_ENABLE_WRITEABLE_PROPERTY
|
|
#define LLK_ENABLE_DEFAULT false /* "eng" and userdebug true */
|
|
#define KHT_ENABLE_WRITEABLE_PROPERTY "khungtask.enable"
|
|
#define KHT_ENABLE_PROPERTY "ro." KHT_ENABLE_WRITEABLE_PROPERTY
|
|
#define LLK_MLOCKALL_PROPERTY "ro.llk.mlockall"
|
|
#define LLK_MLOCKALL_DEFAULT true
|
|
#define LLK_KILLTEST_PROPERTY "ro.llk.killtest"
|
|
#define LLK_KILLTEST_DEFAULT true
|
|
#define LLK_TIMEOUT_MS_PROPERTY "ro.llk.timeout_ms"
|
|
#define KHT_TIMEOUT_PROPERTY "ro.khungtask.timeout"
|
|
#define LLK_D_TIMEOUT_MS_PROPERTY "ro.llk.D.timeout_ms"
|
|
#define LLK_Z_TIMEOUT_MS_PROPERTY "ro.llk.Z.timeout_ms"
|
|
#define LLK_CHECK_MS_PROPERTY "ro.llk.check_ms"
|
|
/* LLK_CHECK_MS_DEFAULT = actual timeout_ms / LLK_CHECKS_PER_TIMEOUT_DEFAULT */
|
|
#define LLK_CHECKS_PER_TIMEOUT_DEFAULT 5
|
|
#define LLK_BLACKLIST_PROCESS_PROPERTY "ro.llk.blacklist.process"
|
|
#define LLK_BLACKLIST_PROCESS_DEFAULT \
|
|
"0,1,2,init,[kthreadd],[khungtaskd],lmkd,lmkd.llkd,llkd,watchdogd,[watchdogd],[watchdogd/0]"
|
|
#define LLK_BLACKLIST_PARENT_PROPERTY "ro.llk.blacklist.parent"
|
|
#define LLK_BLACKLIST_PARENT_DEFAULT "0,2,[kthreadd]"
|
|
#define LLK_BLACKLIST_UID_PROPERTY "ro.llk.blacklist.uid"
|
|
#define LLK_BLACKLIST_UID_DEFAULT ""
|
|
/* clang-format on */
|
|
|
|
__END_DECLS
|
|
|
|
#ifdef __cplusplus
|
|
extern "C++" { /* In case this included wrapped with __BEGIN_DECLS */
|
|
|
|
#include <chrono>
|
|
|
|
__BEGIN_DECLS
|
|
/* C++ code allowed to not specify threadname argument for this C linkage */
|
|
bool llkInit(const char* threadname = nullptr);
|
|
__END_DECLS
|
|
std::chrono::milliseconds llkCheck(bool checkRunning = false);
|
|
|
|
/* clang-format off */
|
|
#define LLK_TIMEOUT_MS_DEFAULT std::chrono::duration_cast<milliseconds>(std::chrono::minutes(10))
|
|
#define LLK_TIMEOUT_MS_MINIMUM std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::seconds(10))
|
|
#define LLK_CHECK_MS_MINIMUM std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::seconds(1))
|
|
/* clang-format on */
|
|
|
|
} /* extern "C++" */
|
|
#endif /* __cplusplus */
|
|
|
|
#endif /* _LLKD_H_ */
|