blob: 0822a3e2bf840bbac82182ce8a43b15740aa6b8e [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 Salyzyn6d9e5152020-05-13 06:25:20 -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
38#define LLK_ENABLE_SYSRQ_T_PROPERTY "ro.llk.sysrq_t"
39#define LLK_ENABLE_SYSRQ_T_DEFAULT true
40#define LLK_MLOCKALL_PROPERTY "ro.llk.mlockall"
41#define LLK_MLOCKALL_DEFAULT true
42#define LLK_KILLTEST_PROPERTY "ro.llk.killtest"
43#define LLK_KILLTEST_DEFAULT true
44#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"
48#define LLK_STACK_TIMEOUT_MS_PROPERTY "ro.llk.stack.timeout_ms"
49#define LLK_CHECK_MS_PROPERTY "ro.llk.check_ms"
Mark Salyzynf089e142018-02-20 10:47:40 -080050/* LLK_CHECK_MS_DEFAULT = actual timeout_ms / LLK_CHECKS_PER_TIMEOUT_DEFAULT */
Mark Salyzyn6d9e5152020-05-13 06:25:20 -070051#define LLK_CHECKS_PER_TIMEOUT_DEFAULT 5
52#define LLK_CHECK_STACK_PROPERTY "ro.llk.stack"
53#define LLK_CHECK_STACK_DEFAULT \
Mark Salyzynb658ffa2018-12-12 09:19:49 -080054 "cma_alloc,__get_user_pages,bit_wait_io,wait_on_page_bit_killable"
Mark Salyzyn6d9e5152020-05-13 06:25:20 -070055#define LLK_IGNORELIST_PROCESS_PROPERTY "ro.llk.ignorelist.process"
56#define LLK_IGNORELIST_PROCESS_DEFAULT \
Mark Salyzyne81ede82018-10-22 15:52:32 -070057 "0,1,2,init,[kthreadd],[khungtaskd],lmkd,llkd,watchdogd,[watchdogd],[watchdogd/0]"
Mark Salyzyn6d9e5152020-05-13 06:25:20 -070058#define LLK_IGNORELIST_PARENT_PROPERTY "ro.llk.ignorelist.parent"
59#define LLK_IGNORELIST_PARENT_DEFAULT "0,2,[kthreadd],adbd&[setsid]"
60#define LLK_IGNORELIST_UID_PROPERTY "ro.llk.ignorelist.uid"
61#define LLK_IGNORELIST_UID_DEFAULT ""
62#define LLK_IGNORELIST_STACK_PROPERTY "ro.llk.ignorelist.process.stack"
Janis Danisevskis02843742021-03-15 09:17:58 -070063#define LLK_IGNORELIST_STACK_DEFAULT "init,lmkd.llkd,llkd,keystore,keystore2,ueventd,apexd"
Mark Salyzynf089e142018-02-20 10:47:40 -080064/* clang-format on */
65
66__END_DECLS
67
68#ifdef __cplusplus
69extern "C++" { /* In case this included wrapped with __BEGIN_DECLS */
70
71#include <chrono>
72
73__BEGIN_DECLS
74/* C++ code allowed to not specify threadname argument for this C linkage */
75bool llkInit(const char* threadname = nullptr);
76__END_DECLS
77std::chrono::milliseconds llkCheck(bool checkRunning = false);
78
79/* clang-format off */
80#define LLK_TIMEOUT_MS_DEFAULT std::chrono::duration_cast<milliseconds>(std::chrono::minutes(10))
81#define LLK_TIMEOUT_MS_MINIMUM std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::seconds(10))
82#define LLK_CHECK_MS_MINIMUM std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::seconds(1))
83/* clang-format on */
84
85} /* extern "C++" */
86#endif /* __cplusplus */
87
88#endif /* _LLKD_H_ */