binder: send BC_REPLY and BC_FREE_BUFFER together

In current BR_TRANSACTION handling logic, BC_REPLY and BC_FREE_BUFFER
are sent to kernel seperately which may introduce latency for freeing
buffer.

I think it's better to free buffer asap, this change fixes this
by putting BC_REPLY and BC_FREE_BUFFER in the same buffer. And then
call waitForResponse() to send them to kernel together.

After this, function sendReply() will not be called by anyone. So
sendReply() is also removed.

Below is the test result of "binderThroughputTest -w 100"
Env: android 7.1.2, 2G ram
---------------------
--->  base:
iterations per sec: 31917.7
collecting results
average:2.83375ms worst:572.205ms best:0.054219ms
50%: 2.14844 90%: 5.27344 95%: 6.83594 99%: 12.3047

iterations per sec: 32142.3
collecting results
average:2.8186ms worst:550.884ms best:0.054948ms
50%: 2.53906 90%: 5.27344 95%: 6.83594 99%: 11.1328

iterations per sec: 31704.5
collecting results
average:2.85129ms worst:600.984ms best:0.053854ms
50%: 2.53906 90%: 5.27344 95%: 6.83594 99%: 12.3047

iterations per sec: 31932.3
collecting results
average:2.82549ms worst:563.098ms best:0.052396ms
50%: 2.53906 90%: 5.66406 95%: 6.83594 99%: 11.1328

---> patched:
iterations per sec: 32062.5
collecting results
average:2.85475ms worst:599.177ms best:0.054895ms
50%: 2.14844 90%: 5.27344 95%: 6.44531 99%: 12.6953

iterations per sec: 32241.7
collecting results
average:2.82851ms worst:634.984ms best:0.05651ms
50%: 2.53906 90%: 5.66406 95%: 6.83594 99%: 10.7422

iterations per sec: 31939
collecting results
average:2.86589ms worst:628.861ms best:0.058645ms
50%: 2.53906 90%: 5.66406 95%: 6.83594 99%: 11.1328

iterations per sec: 32149.4
collecting results
average:2.80785ms worst:658.889ms best:0.055573ms
50%: 2.53906 90%: 5.66406 95%: 6.83594 99%: 10.7422

It seems patched is better.

Change-Id: I0ef88864f4dbc63f3cdd2eba345b5dce6140b2d3
Suggested-by: Martijn Coenen <maco@google.com>
Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
2 files changed