diff options
author | Ankit Goyal <layog@google.com> | 2021-10-08 05:00:31 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2021-10-08 05:00:31 +0000 |
commit | 03316c5e63d1db54ae060c2f4212868e40fcb0dc (patch) | |
tree | 179130bb685a4c0998e7a9b13847f92d89c4d959 | |
parent | 94d6294954a90c45be554bbea26f12b1a2d94fea (diff) | |
parent | 71a210eec63a9987af147f4c68ecc16f19b8667b (diff) | |
download | gchips-03316c5e63d1db54ae060c2f4212868e40fcb0dc.tar.gz |
Merge "Maximize the priority of gralloc allocator thread" into sc-qpr1-dev
-rw-r--r-- | gralloc4/service/4.x/Android.bp | 4 | ||||
-rw-r--r-- | gralloc4/service/4.x/service.cpp | 27 | ||||
-rw-r--r-- | gralloc4/src/4.x/GrallocAllocator.cpp | 10 |
3 files changed, 28 insertions, 13 deletions
diff --git a/gralloc4/service/4.x/Android.bp b/gralloc4/service/4.x/Android.bp index de06942..5bd81bc 100644 --- a/gralloc4/service/4.x/Android.bp +++ b/gralloc4/service/4.x/Android.bp @@ -29,8 +29,12 @@ cc_binary { init_rc: [ "android.hardware.graphics.allocator@4.0-service.rc", ], + header_libs: [ + "libgralloc_headers", + ], shared_libs: [ "android.hardware.graphics.allocator@4.0", + "android.hardware.graphics.allocator@4.0-impl", "libhidlbase", "liblog", "libutils", diff --git a/gralloc4/service/4.x/service.cpp b/gralloc4/service/4.x/service.cpp index bd28407..d540086 100644 --- a/gralloc4/service/4.x/service.cpp +++ b/gralloc4/service/4.x/service.cpp @@ -16,13 +16,30 @@ */ #define LOG_TAG "android.hardware.graphics.allocator@4.0-service" -#include <android/hardware/graphics/allocator/4.0/IAllocator.h> +#include <hidl/HidlTransportSupport.h> +#include <hidl/Status.h> +#include <utils/StrongPointer.h> -#include <hidl/LegacySupport.h> +#include "4.x/GrallocAllocator.h" -using android::hardware::defaultPassthroughServiceImplementation; -using android::hardware::graphics::allocator::V4_0::IAllocator; +using android::hardware::configureRpcThreadpool; +using android::hardware::joinRpcThreadpool; +using android::hardware::setMinSchedulerPolicy; +using arm::allocator::GrallocAllocator; int main() { - return defaultPassthroughServiceImplementation<IAllocator>(/*maxThreads*/ 4); + android::sp<GrallocAllocator> service = new GrallocAllocator(); + configureRpcThreadpool(4, true /* callerWillJoin */); + + if (!setMinSchedulerPolicy(service, SCHED_NORMAL, -20)) { + ALOGW("Cannot bump allocator priority"); + } + + if (service->registerAsService() != android::OK) { + ALOGE("Cannot register allocator service"); + return -EINVAL; + } + + joinRpcThreadpool(); + return 0; } diff --git a/gralloc4/src/4.x/GrallocAllocator.cpp b/gralloc4/src/4.x/GrallocAllocator.cpp index 4e074b5..0ac81fd 100644 --- a/gralloc4/src/4.x/GrallocAllocator.cpp +++ b/gralloc4/src/4.x/GrallocAllocator.cpp @@ -40,6 +40,8 @@ unsigned long callingPid() { GrallocAllocator::GrallocAllocator() { + MALI_GRALLOC_LOGV("Arm Module IAllocator %d.%d, pid = %d ppid = %d", GRALLOC_VERSION_MAJOR, + (HIDL_ALLOCATOR_VERSION_SCALED - (GRALLOC_VERSION_MAJOR * 100)) / 10, getpid(), getppid()); } GrallocAllocator::~GrallocAllocator() @@ -64,11 +66,3 @@ Return<void> GrallocAllocator::allocate(const BufferDescriptor &descriptor, uint } // namespace allocator } // namespace arm - -extern "C" IAllocator *HIDL_FETCH_IAllocator(const char * /* name */) -{ - MALI_GRALLOC_LOGV("Arm Module IAllocator %d.%d, pid = %d ppid = %d", GRALLOC_VERSION_MAJOR, - (HIDL_ALLOCATOR_VERSION_SCALED - (GRALLOC_VERSION_MAJOR * 100)) / 10, getpid(), getppid()); - - return new arm::allocator::GrallocAllocator(); -} |