From 27c269522f41e11b420b2e7af5a9c954f957e513 Mon Sep 17 00:00:00 2001 From: Elie Kheirallah Date: Wed, 7 Sep 2022 21:45:26 +0000 Subject: binder: Added info log in waitForService to display # of threads in threadpool. Log to display # of threads configured in threadpool. We get the value from getThreadPoolMaxTotalThreadCount(). Test: boot acloud test while reducing time of waitForService to 0.1s Bug: 233222865 Change-Id: Ifcd152f1c7a622f8e21e7b242fe2ebfe7238a3d7 --- libs/binder/IServiceManager.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp index 5db3eef392..05db7743f2 100644 --- a/libs/binder/IServiceManager.cpp +++ b/libs/binder/IServiceManager.cpp @@ -380,6 +380,13 @@ sp ServiceManagerShim::waitForService(const String16& name16) if (Status status = realGetService(name, &out); !status.isOk()) { ALOGW("Failed to getService in waitForService for %s: %s", name.c_str(), status.toString8().c_str()); + if (0 == ProcessState::self()->getThreadPoolMaxTotalThreadCount()) { + ALOGW("Got service, but may be racey because we could not wait efficiently for it. " + "Threadpool has 0 guaranteed threads. " + "Is the threadpool configured properly? " + "See ProcessState::startThreadPool and " + "ProcessState::setThreadPoolMaxThreadCount."); + } return nullptr; } if (out != nullptr) return out; @@ -410,7 +417,9 @@ sp ServiceManagerShim::waitForService(const String16& name16) if (waiter->mBinder != nullptr) return waiter->mBinder; } - ALOGW("Waited one second for %s (is service started? are binder threads started and available?)", name.c_str()); + ALOGW("Waited one second for %s (is service started? Number of threads started in the " + "threadpool: %zu. Are binder threads started and available?)", + name.c_str(), ProcessState::self()->getThreadPoolMaxTotalThreadCount()); // Handle race condition for lazy services. Here is what can happen: // - the service dies (not processed by init yet). -- cgit v1.2.3-59-g8ed1b