From d0feaf9f79889f5991843fca9f9461096641b2a8 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Wed, 24 Apr 2019 14:28:25 -0700 Subject: [PATCH] adbd: reduce queue depths. Each operation we submit results in a contiguous allocation in the kernel which can trigger OOM-killing. Tune the queue depths to reduce the chances of this happening, with a minimal impact on performance. Bug: http://b/126582877 Test: ./benchmark_device.py with blueline Change-Id: I4b0f83d54a9a9a69f0ab48322d78fb137c94dd35 (cherry picked from commit 28293f16a80e3d7af442bc9817dae999f78beb57) --- adb/daemon/usb.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/adb/daemon/usb.cpp b/adb/daemon/usb.cpp index 3b29ab5fc..1e3701582 100644 --- a/adb/daemon/usb.cpp +++ b/adb/daemon/usb.cpp @@ -58,10 +58,12 @@ using android::base::StringPrintf; static std::optional gFfsAioSupported; // Not all USB controllers support operations larger than 16k, so don't go above that. -static constexpr size_t kUsbReadQueueDepth = 32; +// Also, each submitted operation does an allocation in the kernel of that size, so we want to +// minimize our queue depth while still maintaining a deep enough queue to keep the USB stack fed. +static constexpr size_t kUsbReadQueueDepth = 8; static constexpr size_t kUsbReadSize = 4 * PAGE_SIZE; -static constexpr size_t kUsbWriteQueueDepth = 32; +static constexpr size_t kUsbWriteQueueDepth = 8; static constexpr size_t kUsbWriteSize = 4 * PAGE_SIZE; static const char* to_string(enum usb_functionfs_event_type type) {