blob: d0188ec79f83e55e9b0e16e9693b095b6b22607b [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 Salyzynf089e142018-02-20 10:47:40 -080038#define LLK_MLOCKALL_PROPERTY "ro.llk.mlockall"
39#define LLK_MLOCKALL_DEFAULT true
Mark Salyzynafd66f22018-03-19 15:16:29 -070040#define LLK_KILLTEST_PROPERTY "ro.llk.killtest"
41#define LLK_KILLTEST_DEFAULT true
Mark Salyzynf089e142018-02-20 10:47:40 -080042#define LLK_TIMEOUT_MS_PROPERTY "ro.llk.timeout_ms"
43#define KHT_TIMEOUT_PROPERTY "ro.khungtask.timeout"
44#define LLK_D_TIMEOUT_MS_PROPERTY "ro.llk.D.timeout_ms"
45#define LLK_Z_TIMEOUT_MS_PROPERTY "ro.llk.Z.timeout_ms"
Mark Salyzyn96505fa2018-08-07 08:13:13 -070046#define LLK_STACK_TIMEOUT_MS_PROPERTY "ro.llk.stack.timeout_ms"
Mark Salyzynf089e142018-02-20 10:47:40 -080047#define LLK_CHECK_MS_PROPERTY "ro.llk.check_ms"
48/* LLK_CHECK_MS_DEFAULT = actual timeout_ms / LLK_CHECKS_PER_TIMEOUT_DEFAULT */
49#define LLK_CHECKS_PER_TIMEOUT_DEFAULT 5
Mark Salyzyn96505fa2018-08-07 08:13:13 -070050#define LLK_CHECK_STACK_PROPERTY "ro.llk.stack"
51#define LLK_CHECK_STACK_DEFAULT ""
Mark Salyzynf089e142018-02-20 10:47:40 -080052#define LLK_BLACKLIST_PROCESS_PROPERTY "ro.llk.blacklist.process"
53#define LLK_BLACKLIST_PROCESS_DEFAULT \
54 "0,1,2,init,[kthreadd],[khungtaskd],lmkd,lmkd.llkd,llkd,watchdogd,[watchdogd],[watchdogd/0]"
55#define LLK_BLACKLIST_PARENT_PROPERTY "ro.llk.blacklist.parent"
56#define LLK_BLACKLIST_PARENT_DEFAULT "0,2,[kthreadd]"
57#define LLK_BLACKLIST_UID_PROPERTY "ro.llk.blacklist.uid"
58#define LLK_BLACKLIST_UID_DEFAULT ""
Mark Salyzyn96505fa2018-08-07 08:13:13 -070059#define LLK_BLACKLIST_STACK_PROPERTY "ro.llk.blacklist.process.stack"
60#define LLK_BLACKLIST_STACK_DEFAULT "init,lmkd.llkd,llkd,keystore,/system/bin/keystore"
Mark Salyzynf089e142018-02-20 10:47:40 -080061/* clang-format on */
62
63__END_DECLS
64
65#ifdef __cplusplus
66extern "C++" { /* In case this included wrapped with __BEGIN_DECLS */
67
68#include <chrono>
69
70__BEGIN_DECLS
71/* C++ code allowed to not specify threadname argument for this C linkage */
72bool llkInit(const char* threadname = nullptr);
73__END_DECLS
74std::chrono::milliseconds llkCheck(bool checkRunning = false);
75
76/* clang-format off */
77#define LLK_TIMEOUT_MS_DEFAULT std::chrono::duration_cast<milliseconds>(std::chrono::minutes(10))
78#define LLK_TIMEOUT_MS_MINIMUM std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::seconds(10))
79#define LLK_CHECK_MS_MINIMUM std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::seconds(1))
80/* clang-format on */
81
82} /* extern "C++" */
83#endif /* __cplusplus */
84
85#endif /* _LLKD_H_ */