lmkd: set normal scheduling policy for reaper threads
Reaper threads can take considerable time to free target's memory running at RT priority that they inherit from LMKD. This might prevent other critical tasks from being scheduled while reaper threads are active. Explicitly set reaper threads to run under normal scheduling policy but set their nice value to ANDROID_PRIORITY_HIGHEST. Bug: 237180716 Signed-off-by: Suren Baghdasaryan <surenb@google.com> Change-Id: Idad817e698ae1d5ac6cee5aa3281c69c7e0d257f
This commit is contained in:
parent
fd238117c8
commit
ab4c6d86e0
11
reaper.cpp
11
reaper.cpp
|
|
@ -64,6 +64,10 @@ static void* reaper_main(void* param) {
|
||||||
ALOGE("Failed to assign cpuset to the reaper thread");
|
ALOGE("Failed to assign cpuset to the reaper thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (setpriority(PRIO_PROCESS, tid, ANDROID_PRIORITY_HIGHEST)) {
|
||||||
|
ALOGW("Unable to raise priority of the reaper thread (%d): errno=%d", tid, errno);
|
||||||
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
target = reaper->dequeue_request();
|
target = reaper->dequeue_request();
|
||||||
|
|
||||||
|
|
@ -112,6 +116,9 @@ bool Reaper::is_reaping_supported() {
|
||||||
|
|
||||||
bool Reaper::init(int comm_fd) {
|
bool Reaper::init(int comm_fd) {
|
||||||
char name[16];
|
char name[16];
|
||||||
|
struct sched_param param = {
|
||||||
|
.sched_priority = 0,
|
||||||
|
};
|
||||||
|
|
||||||
if (thread_cnt_ > 0) {
|
if (thread_cnt_ > 0) {
|
||||||
// init should not be called multiple times
|
// init should not be called multiple times
|
||||||
|
|
@ -124,6 +131,10 @@ bool Reaper::init(int comm_fd) {
|
||||||
ALOGE("pthread_create failed: %s", strerror(errno));
|
ALOGE("pthread_create failed: %s", strerror(errno));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// set normal scheduling policy for the reaper thread
|
||||||
|
if (pthread_setschedparam(thread_pool_[thread_cnt_], SCHED_OTHER, ¶m)) {
|
||||||
|
ALOGW("set SCHED_FIFO failed %s", strerror(errno));
|
||||||
|
}
|
||||||
snprintf(name, sizeof(name), "lmkd_reaper%d", thread_cnt_);
|
snprintf(name, sizeof(name), "lmkd_reaper%d", thread_cnt_);
|
||||||
if (pthread_setname_np(thread_pool_[thread_cnt_], name)) {
|
if (pthread_setname_np(thread_pool_[thread_cnt_], name)) {
|
||||||
ALOGW("pthread_setname_np failed: %s", strerror(errno));
|
ALOGW("pthread_setname_np failed: %s", strerror(errno));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue