blob: 7b7dbf90ffd0b70dac225662fe5fa3eb984d2988 [file] [log] [blame]
Mark Salyzynf089e142018-02-20 10:47:40 -08001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _LLKD_H_
18#define _LLKD_H_
19
20#ifndef LOG_TAG
21#define LOG_TAG "livelock"
22#endif
23
24#include <stdbool.h>
25#include <sys/cdefs.h>
26
27__BEGIN_DECLS
28
29bool llkInit(const char* threadname); /* threadname NULL, not spawned */
30unsigned llkCheckMilliseconds(void);
31
32/* clang-format off */
Mark Salyzynd035dbb2018-03-26 08:23:00 -070033#define LLK_ENABLE_WRITEABLE_PROPERTY "llk.enable"
34#define LLK_ENABLE_PROPERTY "ro." LLK_ENABLE_WRITEABLE_PROPERTY
35#define LLK_ENABLE_DEFAULT false /* "eng" and userdebug true */
36#define KHT_ENABLE_WRITEABLE_PROPERTY "khungtask.enable"
37#define KHT_ENABLE_PROPERTY "ro." KHT_ENABLE_WRITEABLE_PROPERTY
Mark Salyzynbd7c8562018-10-31 10:02:08 -070038#define LLK_ENABLE_SYSRQ_T_PROPERTY "ro.llk.sysrq_t"
39#define LLK_ENABLE_SYSRQ_T_DEFAULT true
Mark Salyzynf089e142018-02-20 10:47:40 -080040#define LLK_MLOCKALL_PROPERTY "ro.llk.mlockall"
41#define LLK_MLOCKALL_DEFAULT true
Mark Salyzynafd66f22018-03-19 15:16:29 -070042#define LLK_KILLTEST_PROPERTY "ro.llk.killtest"
43#define LLK_KILLTEST_DEFAULT true
Mark Salyzynf089e142018-02-20 10:47:40 -080044#define LLK_TIMEOUT_MS_PROPERTY "ro.llk.timeout_ms"
45#define KHT_TIMEOUT_PROPERTY "ro.khungtask.timeout"
46#define LLK_D_TIMEOUT_MS_PROPERTY "ro.llk.D.timeout_ms"
47#define LLK_Z_TIMEOUT_MS_PROPERTY "ro.llk.Z.timeout_ms"
Mark Salyzyn96505fa2018-08-07 08:13:13 -070048#define LLK_STACK_TIMEOUT_MS_PROPERTY "ro.llk.stack.timeout_ms"
Mark Salyzynf089e142018-02-20 10:47:40 -080049#define LLK_CHECK_MS_PROPERTY "ro.llk.check_ms"
50/* LLK_CHECK_MS_DEFAULT = actual timeout_ms / LLK_CHECKS_PER_TIMEOUT_DEFAULT */
51#define LLK_CHECKS_PER_TIMEOUT_DEFAULT 5
Mark Salyzyn96505fa2018-08-07 08:13:13 -070052#define LLK_CHECK_STACK_PROPERTY "ro.llk.stack"
Mark Salyzynb658ffa2018-12-12 09:19:49 -080053#define LLK_CHECK_STACK_DEFAULT \
54 "cma_alloc,__get_user_pages,bit_wait_io,wait_on_page_bit_killable"
Mark Salyzynf089e142018-02-20 10:47:40 -080055#define LLK_BLACKLIST_PROCESS_PROPERTY "ro.llk.blacklist.process"
56#define LLK_BLACKLIST_PROCESS_DEFAULT \
Mark Salyzyne81ede82018-10-22 15:52:32 -070057 "0,1,2,init,[kthreadd],[khungtaskd],lmkd,llkd,watchdogd,[watchdogd],[watchdogd/0]"
Mark Salyzynf089e142018-02-20 10:47:40 -080058#define LLK_BLACKLIST_PARENT_PROPERTY "ro.llk.blacklist.parent"
Mark Salyzyn599958d2018-12-13 08:28:44 -080059#ifdef __PTRACE_ENABLED__ // defined if userdebug build
60#define LLK_BLACKLIST_PARENT_DEFAULT "0,2,[kthreadd],adbd"
61#else
Mark Salyzynf089e142018-02-20 10:47:40 -080062#define LLK_BLACKLIST_PARENT_DEFAULT "0,2,[kthreadd]"
Mark Salyzyn599958d2018-12-13 08:28:44 -080063#endif
Mark Salyzynf089e142018-02-20 10:47:40 -080064#define LLK_BLACKLIST_UID_PROPERTY "ro.llk.blacklist.uid"
65#define LLK_BLACKLIST_UID_DEFAULT ""
Mark Salyzyn96505fa2018-08-07 08:13:13 -070066#define LLK_BLACKLIST_STACK_PROPERTY "ro.llk.blacklist.process.stack"
Mark Salyzyne81ede82018-10-22 15:52:32 -070067#define LLK_BLACKLIST_STACK_DEFAULT "init,lmkd.llkd,llkd,keystore,ueventd,apexd"
Mark Salyzynf089e142018-02-20 10:47:40 -080068/* clang-format on */
69
70__END_DECLS
71
72#ifdef __cplusplus
73extern "C++" { /* In case this included wrapped with __BEGIN_DECLS */
74
75#include <chrono>
76
77__BEGIN_DECLS
78/* C++ code allowed to not specify threadname argument for this C linkage */
79bool llkInit(const char* threadname = nullptr);
80__END_DECLS
81std::chrono::milliseconds llkCheck(bool checkRunning = false);
82
83/* clang-format off */
84#define LLK_TIMEOUT_MS_DEFAULT std::chrono::duration_cast<milliseconds>(std::chrono::minutes(10))
85#define LLK_TIMEOUT_MS_MINIMUM std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::seconds(10))
86#define LLK_CHECK_MS_MINIMUM std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::seconds(1))
87/* clang-format on */
88
89} /* extern "C++" */
90#endif /* __cplusplus */
91
92#endif /* _LLKD_H_ */