binder: add spinlocks to protect proc, node, thread, and ref

Co-developed with Badhri Jagan Sridharan <Badhri@google.com>

Add fine-grained locking to protect binder_proc,
binder_node, binder_thread, and binder_ref.

The associated proc_lock is used to protect most fields of these
structures. The lock functions binder_proc_lock and binder_proc_unlock
enforce that these locks are never nested (cannot acquire
proc1->proc_lock if holding proc2->proc_lock).

There are separate locks for the todo lists, and todo list locks
can be nested under the proc_lock since there are cases where
proc1 needs to add to a work list for proc2 etc.

To lock the various structs:

  struct binder_proc:   binder_proc_lock(proc, __LINE__);
  struct binder_ref:    binder_proc_lock(ref->proc, __LINE__);
  struct binder_node:   binder_proc_lock(node->proc, __LINE__);
  struct binder_thread: binder_proc_lock(thread->proc, __LINE__);

The binder_node is a little special since node->proc can be set
to NULL when the node is invalidated, but before it has been
cleaned up. If node->proc == NULL, then the node is protected
by the binder_dead_nodes_lock.

Bug: 33250092 32225111
Change-Id: Icf6add0eddf70473b39239960b2d9a524775b53a
Signed-off-by: Todd Kjos <tkjos@google.com>
This commit is contained in:
Todd Kjos
2016-10-20 16:43:34 -07:00
committed by Thierry Strudel
parent 1f6c11ca4b
commit edbe2b61b9

File diff suppressed because it is too large Load Diff