ANDROID: binder: Don't BUG_ON(!spin_is_locked()).
authorMartijn Coenen <maco@android.com>
Thu, 27 Jul 2017 21:52:24 +0000 (23:52 +0200)
committerDanny Wood <danwood76@gmail.com>
Tue, 26 Feb 2019 16:35:30 +0000 (16:35 +0000)
Because is_spin_locked() always returns false on UP
systems.

Use assert_spin_locked() instead, and remove the
WARN_ON() instances, since those were easy to verify.

Bug: 64073116
Change-Id: I9080991c6d67e91928282a3ee64db23e50c7d66a
Signed-off-by: Martijn Coenen <maco@android.com>
drivers/android/binder.c

index 11f65175f944e9d2ac566b8186123be3763799ce..77476c537adc17e623fdbb0d063ff68f5ed2e712 100644 (file)
@@ -1021,7 +1021,7 @@ binder_select_thread_ilocked(struct binder_proc *proc)
 {
        struct binder_thread *thread;
 
-       BUG_ON(!spin_is_locked(&proc->inner_lock));
+       assert_spin_locked(&proc->inner_lock);
        thread = list_first_entry_or_null(&proc->waiting_threads,
                                          struct binder_thread,
                                          waiting_thread_node);
@@ -1052,7 +1052,7 @@ static void binder_wakeup_thread_ilocked(struct binder_proc *proc,
                                         struct binder_thread *thread,
                                         bool sync)
 {
-       BUG_ON(!spin_is_locked(&proc->inner_lock));
+       assert_spin_locked(&proc->inner_lock);
 
        if (thread) {
                if (sync)
@@ -1231,7 +1231,7 @@ static struct binder_node *binder_get_node_ilocked(struct binder_proc *proc,
        struct rb_node *n = proc->nodes.rb_node;
        struct binder_node *node;
 
-       BUG_ON(!spin_is_locked(&proc->inner_lock));
+       assert_spin_locked(&proc->inner_lock);
 
        while (n) {
                node = rb_entry(n, struct binder_node, rb_node);
@@ -1277,7 +1277,8 @@ static struct binder_node *binder_init_node_ilocked(
        __u32 flags = fp ? fp->flags : 0;
        s8 priority;
 
-       BUG_ON(!spin_is_locked(&proc->inner_lock));
+       assert_spin_locked(&proc->inner_lock);
+
        while (*p) {
 
                parent = *p;
@@ -1356,9 +1357,9 @@ static int binder_inc_node_nilocked(struct binder_node *node, int strong,
 {
        struct binder_proc *proc = node->proc;
 
-       BUG_ON(!spin_is_locked(&node->lock));
+       assert_spin_locked(&node->lock);
        if (proc)
-               BUG_ON(!spin_is_locked(&proc->inner_lock));
+               assert_spin_locked(&proc->inner_lock);
        if (strong) {
                if (internal) {
                        if (target_list == NULL &&
@@ -1410,9 +1411,9 @@ static bool binder_dec_node_nilocked(struct binder_node *node,
 {
        struct binder_proc *proc = node->proc;
 
-       BUG_ON(!spin_is_locked(&node->lock));
+       assert_spin_locked(&node->lock);
        if (proc)
-               BUG_ON(!spin_is_locked(&proc->inner_lock));
+               assert_spin_locked(&proc->inner_lock);
        if (strong) {
                if (internal)
                        node->internal_strong_refs--;
@@ -1936,7 +1937,7 @@ static void binder_pop_transaction_ilocked(struct binder_thread *target_thread,
                                           struct binder_transaction *t)
 {
        BUG_ON(!target_thread);
-       BUG_ON(!spin_is_locked(&target_thread->proc->inner_lock));
+       assert_spin_locked(&target_thread->proc->inner_lock);
        BUG_ON(target_thread->transaction_stack != t);
        BUG_ON(target_thread->transaction_stack->from != target_thread);
        target_thread->transaction_stack =
@@ -5079,7 +5080,6 @@ static void print_binder_transaction_ilocked(struct seq_file *m,
        struct binder_proc *to_proc;
        struct binder_buffer *buffer = t->buffer;
 
-       WARN_ON(!spin_is_locked(&proc->inner_lock));
        spin_lock(&t->lock);
        to_proc = t->to_proc;
        seq_printf(m,
@@ -5168,7 +5168,6 @@ static void print_binder_thread_ilocked(struct seq_file *m,
        size_t start_pos = m->count;
        size_t header_pos;
 
-       WARN_ON(!spin_is_locked(&thread->proc->inner_lock));
        seq_printf(m, "  thread %d: l %02x need_return %d tr %d\n",
                        thread->pid, thread->looper,
                        thread->looper_need_return,
@@ -5205,10 +5204,6 @@ static void print_binder_node_nilocked(struct seq_file *m,
        struct binder_work *w;
        int count;
 
-       WARN_ON(!spin_is_locked(&node->lock));
-       if (node->proc)
-               WARN_ON(!spin_is_locked(&node->proc->inner_lock));
-
        count = 0;
        hlist_for_each_entry(ref, &node->refs, node_entry)
                count++;
@@ -5235,7 +5230,6 @@ static void print_binder_node_nilocked(struct seq_file *m,
 static void print_binder_ref_olocked(struct seq_file *m,
                                     struct binder_ref *ref)
 {
-       WARN_ON(!spin_is_locked(&ref->proc->outer_lock));
        binder_node_lock(ref->node);
        seq_printf(m, "  ref %d: desc %d %snode %d s %d w %d d %pK\n",
                   ref->data.debug_id, ref->data.desc,