History

Binder: add TF_UPDATE_TXN to replace outdated txn

When the target process is busy, incoming oneway transactions are queued in the async_todo list. If the clients continue sending extra oneway transactions while the target process is frozen, this queue can become too large to accommodate new transactions. That's why binder driver introduced ONEWAY_SPAM_DETECTION to detect this situation. It's helpful to debug the async binder buffer exhausting issue, but the issue itself isn't solved directly. In real cases applications are designed to send oneway transactions repeatedly, delivering updated inforamtion to the target process. Typical examples are Wi-Fi signal strength and some real time sensor data. Even if the apps might only care about the lastet information, all outdated oneway transactions are still accumulated there until the frozen process is thawed later. For this kind of situations, there's no existing method to skip those outdated transactions and deliver the latest one only. This patch introduces a new transaction flag TF_UPDATE_TXN. To use it, use apps can set this new flag along with TF_ONE_WAY. When such an oneway transaction is to be queued into the async_todo list of a frozen process, binder driver will check if any previous pending transactions can be superseded by comparing their code, flags and target node. If such an outdated pending transaction is found, the latest transaction will supersede that outdated one. This effectively prevents the async binder buffer running out and saves unnecessary binder read workloads.

Li Li committed 4 years ago

Commit 9864bb41 parent 5afbfa83 files · +87 −3Browse files

Showing the changes to include/uapi/linux/android (1 of 3 files). Show all

Unified · Split

include/uapi/linux/android/binder.h+1−0
@@ -287,6 +287,7 @@ enum transaction_flags { · 286 unmodified lines
287 TF_STATUS_CODE = 0x08, /* contents are a 32-bit status code */287 TF_STATUS_CODE = 0x08, /* contents are a 32-bit status code */
288 TF_ACCEPT_FDS = 0x10, /* allow replies with file descriptors */288 TF_ACCEPT_FDS = 0x10, /* allow replies with file descriptors */
289 TF_CLEAR_BUF = 0x20, /* clear buffer on txn complete */289 TF_CLEAR_BUF = 0x20, /* clear buffer on txn complete */
290 TF_UPDATE_TXN = 0x40, /* update the outdated pending async txn */
290};291};
291 292
292struct binder_transaction_data {293struct binder_transaction_data {