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