FROMLIST: binder: refactor binder ref inc/dec for thread safety
authorTodd Kjos <tkjos@google.com>
Mon, 8 May 2017 16:16:27 +0000 (09:16 -0700)
committerDanny Wood <danwood76@gmail.com>
Tue, 26 Feb 2019 11:36:33 +0000 (11:36 +0000)
commitbc65c39a4180d0a4f12ff33064d1689896c14683
tree416dc6decc13fa171412a51ad0183e31ac14e473
parent82f6ad888b410bb1a173229bd713391f4ec87082
FROMLIST: binder: refactor binder ref inc/dec for thread safety

(from https://patchwork.kernel.org/patch/9817781/)

Once locks are added, binder_ref's will only be accessed
safely with the proc lock held. Refactor the inc/dec paths
to make them atomic with the binder_get_ref* paths and
node inc/dec. For example, instead of:

  ref = binder_get_ref(proc, handle, strong);
  ...
  binder_dec_ref(ref, strong);

we now have:

  ret = binder_dec_ref_for_handle(proc, handle, strong, &rdata);

Since the actual ref is no longer exposed to callers, a
new struct binder_ref_data is introduced which can be used
to return a copy of ref state.

Change-Id: I7de22107f8ebc967cee63251d584fceb4ea56250
Signed-off-by: Todd Kjos <tkjos@google.com>
drivers/android/binder.c
drivers/android/binder_trace.h