diff options
author | 2024-12-16 15:02:50 -0800 | |
---|---|---|
committer | 2024-12-16 15:02:50 -0800 | |
commit | f0e54183f40b00ec549355dc709b464f0398a822 (patch) | |
tree | 3c0bf08c7fe30585abdb8315913030e012b14675 | |
parent | 02efc70436289c0d9fbc7179b5e486a29084631d (diff) | |
parent | c0d95276f6576918794f0fc13cbcd1a34ae9534b (diff) |
Merge "libbinder: log when threads requested, not started" into main am: 38a4ab9f6e am: c0d95276f6
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/3413323
Change-Id: Icfee762f34f62e0eceb5c96c4775bc77f7c6b727
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | libs/binder/IPCThreadState.cpp | 1 | ||||
-rw-r--r-- | libs/binder/ProcessState.cpp | 15 | ||||
-rw-r--r-- | libs/binder/include/binder/ProcessState.h | 2 |
3 files changed, 18 insertions, 0 deletions
diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp index 6698d0c0cd..623e7b9139 100644 --- a/libs/binder/IPCThreadState.cpp +++ b/libs/binder/IPCThreadState.cpp @@ -775,6 +775,7 @@ void IPCThreadState::joinThreadPool(bool isMain) { LOG_THREADPOOL("**** THREAD %p (PID %d) IS JOINING THE THREAD POOL\n", (void*)pthread_self(), getpid()); + mProcess->checkExpectingThreadPoolStart(); mProcess->mCurrentThreads++; mOut.writeInt32(isMain ? BC_ENTER_LOOPER : BC_REGISTER_LOOPER); diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp index 5e7f1510bc..0e1e9b4127 100644 --- a/libs/binder/ProcessState.cpp +++ b/libs/binder/ProcessState.cpp @@ -501,6 +501,21 @@ bool ProcessState::isThreadPoolStarted() const { return mThreadPoolStarted; } +void ProcessState::checkExpectingThreadPoolStart() const { + if (mThreadPoolStarted) return; + + // this is also racey, but you should setup the threadpool in the main thread. If that is an + // issue, we can check if we are the process leader, but haven't seen the issue in practice. + size_t requestedThreads = mMaxThreads.load(); + + // if it's manually set to the default, we do ignore it here... + if (requestedThreads == DEFAULT_MAX_BINDER_THREADS) return; + if (requestedThreads == 0) return; + + ALOGW("Thread pool configuration of size %zu requested, but startThreadPool was not called.", + requestedThreads); +} + #define DRIVER_FEATURES_PATH "/dev/binderfs/features/" bool ProcessState::isDriverFeatureEnabled(const DriverFeature feature) { // Use static variable to cache the results. diff --git a/libs/binder/include/binder/ProcessState.h b/libs/binder/include/binder/ProcessState.h index 21bfd42fcc..ced49c19c2 100644 --- a/libs/binder/include/binder/ProcessState.h +++ b/libs/binder/include/binder/ProcessState.h @@ -141,6 +141,8 @@ public: private: static sp<ProcessState> init(const char* defaultDriver, bool requireDefault); + void checkExpectingThreadPoolStart() const; + static void onFork(); static void parentPostFork(); static void childPostFork(); |