blob: 2ae28ed77418c07822ae587fb2fc4fc74065382d [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 */
33#define LLK_ENABLE_PROPERTY "ro.llk.enable"
34#define LLK_ENABLE_DEFAULT false
35#define KHT_ENABLE_PROPERTY "ro.khungtask.enable"
36#define LLK_MLOCKALL_PROPERTY "ro.llk.mlockall"
37#define LLK_MLOCKALL_DEFAULT true
38#define LLK_TIMEOUT_MS_PROPERTY "ro.llk.timeout_ms"
39#define KHT_TIMEOUT_PROPERTY "ro.khungtask.timeout"
40#define LLK_D_TIMEOUT_MS_PROPERTY "ro.llk.D.timeout_ms"
41#define LLK_Z_TIMEOUT_MS_PROPERTY "ro.llk.Z.timeout_ms"
42#define LLK_CHECK_MS_PROPERTY "ro.llk.check_ms"
43/* LLK_CHECK_MS_DEFAULT = actual timeout_ms / LLK_CHECKS_PER_TIMEOUT_DEFAULT */
44#define LLK_CHECKS_PER_TIMEOUT_DEFAULT 5
45#define LLK_BLACKLIST_PROCESS_PROPERTY "ro.llk.blacklist.process"
46#define LLK_BLACKLIST_PROCESS_DEFAULT \
47 "0,1,2,init,[kthreadd],[khungtaskd],lmkd,lmkd.llkd,llkd,watchdogd,[watchdogd],[watchdogd/0]"
48#define LLK_BLACKLIST_PARENT_PROPERTY "ro.llk.blacklist.parent"
49#define LLK_BLACKLIST_PARENT_DEFAULT "0,2,[kthreadd]"
50#define LLK_BLACKLIST_UID_PROPERTY "ro.llk.blacklist.uid"
51#define LLK_BLACKLIST_UID_DEFAULT ""
52/* clang-format on */
53
54__END_DECLS
55
56#ifdef __cplusplus
57extern "C++" { /* In case this included wrapped with __BEGIN_DECLS */
58
59#include <chrono>
60
61__BEGIN_DECLS
62/* C++ code allowed to not specify threadname argument for this C linkage */
63bool llkInit(const char* threadname = nullptr);
64__END_DECLS
65std::chrono::milliseconds llkCheck(bool checkRunning = false);
66
67/* clang-format off */
68#define LLK_TIMEOUT_MS_DEFAULT std::chrono::duration_cast<milliseconds>(std::chrono::minutes(10))
69#define LLK_TIMEOUT_MS_MINIMUM std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::seconds(10))
70#define LLK_CHECK_MS_MINIMUM std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::seconds(1))
71/* clang-format on */
72
73} /* extern "C++" */
74#endif /* __cplusplus */
75
76#endif /* _LLKD_H_ */