llkd: add ro.llk.sysrq_t

Allow sysrq stack trace dump to be disabled by ro.llk.sysrq_t.

Default is true if not on a limited memory device ro.config.low_ram.
Value is true if the property value is "eng" and on a userdebug or
eng device, signaled by the ro.debuggable set to 1.

Test: compile
Bug: 118712403
Change-Id: I02e999dc640125b6a08dca10077716e5d006da49
This commit is contained in:
Mark Salyzyn 2018-10-31 10:02:08 -07:00
parent bb1256a728
commit bd7c856507
3 changed files with 25 additions and 5 deletions

View File

@ -89,7 +89,14 @@ Android Properties
Android Properties llkd respond to (*prop*_ms parms are in milliseconds):
#### ro.config.low_ram
default false, if true do not sysrq t (dump all threads).
device is configured with limited memory.
#### ro.debuggable
device is configured for userdebug or eng build.
#### ro.llk.sysrq_t
default not ro.config.low_ram, or ro.debuggable if property is "eng".
if true do sysrq t (dump all threads).
#### ro.llk.enable
default false, allow live-lock daemon to be enabled.

View File

@ -35,6 +35,8 @@ unsigned llkCheckMilliseconds(void);
#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_ENABLE_SYSRQ_T_PROPERTY "ro.llk.sysrq_t"
#define LLK_ENABLE_SYSRQ_T_DEFAULT true
#define LLK_MLOCKALL_PROPERTY "ro.llk.mlockall"
#define LLK_MLOCKALL_DEFAULT true
#define LLK_KILLTEST_PROPERTY "ro.llk.killtest"

View File

@ -85,6 +85,7 @@ milliseconds llkStateTimeoutMs[llkNumStates]; // timeout override for eac
milliseconds llkCheckMs; // checking interval to inspect any
// persistent live-locked states
bool llkLowRam; // ro.config.low_ram
bool llkEnableSysrqT = LLK_ENABLE_SYSRQ_T_DEFAULT; // sysrq stack trace dump
bool khtEnable = LLK_ENABLE_DEFAULT; // [khungtaskd] panic
// [khungtaskd] should have a timeout beyond the granularity of llkTimeoutMs.
// Provides a wide angle of margin b/c khtTimeout is also its granularity.
@ -525,7 +526,7 @@ void llkPanicKernel(bool dump, pid_t tid, const char* state) {
android::base::WriteStringToFd("d", sysrqTriggerFd);
// This can trigger hardware watchdog, that is somewhat _ok_.
// But useless if pstore configured for <256KB, low ram devices ...
if (!llkLowRam) {
if (llkEnableSysrqT) {
android::base::WriteStringToFd("t", sysrqTriggerFd);
}
::usleep(200000); // let everything settle
@ -799,6 +800,7 @@ void llkCheckSchedUpdate(proc* procp, const std::string& piddir) {
void llkLogConfig(void) {
LOG(INFO) << "ro.config.low_ram=" << llkFormat(llkLowRam) << "\n"
<< LLK_ENABLE_SYSRQ_T_PROPERTY "=" << llkFormat(llkEnableSysrqT) << "\n"
<< LLK_ENABLE_PROPERTY "=" << llkFormat(llkEnable) << "\n"
<< KHT_ENABLE_PROPERTY "=" << llkFormat(khtEnable) << "\n"
<< LLK_MLOCKALL_PROPERTY "=" << llkFormat(llkMlockall) << "\n"
@ -1150,13 +1152,22 @@ unsigned llkCheckMilliseconds() {
return duration_cast<milliseconds>(llkCheck()).count();
}
bool llkCheckEng(const std::string& property) {
return android::base::GetProperty(property, "eng") == "eng";
}
bool llkInit(const char* threadname) {
auto debuggable = android::base::GetBoolProperty("ro.debuggable", false);
llkLowRam = android::base::GetBoolProperty("ro.config.low_ram", false);
if (!LLK_ENABLE_DEFAULT && debuggable) {
llkEnable = android::base::GetProperty(LLK_ENABLE_PROPERTY, "eng") == "eng";
khtEnable = android::base::GetProperty(KHT_ENABLE_PROPERTY, "eng") == "eng";
llkEnableSysrqT &= !llkLowRam;
if (debuggable) {
llkEnableSysrqT |= llkCheckEng(LLK_ENABLE_SYSRQ_T_PROPERTY);
if (!LLK_ENABLE_DEFAULT) { // NB: default is currently true ...
llkEnable |= llkCheckEng(LLK_ENABLE_PROPERTY);
khtEnable |= llkCheckEng(KHT_ENABLE_PROPERTY);
}
}
llkEnableSysrqT = android::base::GetBoolProperty(LLK_ENABLE_SYSRQ_T_PROPERTY, llkEnableSysrqT);
llkEnable = android::base::GetBoolProperty(LLK_ENABLE_PROPERTY, llkEnable);
if (llkEnable && !llkTopDirectory.reset(procdir)) {
// Most likely reason we could be here is llkd was started