Skip to contentSkip to conversation

softirq: improve preempt count error message

PATCH New Ingo Molnar 2 participants 2 messages Oct 5, 2010 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 18 lines · * [email protected] <[email protected]> wrote:

From: Jiri Slaby <[email protected]>

* add a space after the action
* print function name instead of address of action (%p->%pf)

---

 kernel/softirq.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff -puN kernel/softirq.c~softirq-improve-preempt-count-error-message kernel/softirq.c

kernel/softirq.c restart: · line 226

Quoted 10 lines
kernel/softirq.c renamed from kernel/softirq.c~softirq-improve-preempt-count-error-message +2 -2
@@ -219,8 +219,8 @@ restart:
 			h->action(h);
 			trace_softirq_exit(h, softirq_vec);
 			if (unlikely(prev_count != preempt_count())) {
-				printk(KERN_ERR "huh, entered softirq %td %s %p"
-				       "with preempt_count %08x,"
+				printk(KERN_ERR "huh, entered softirq %td %s "
+				       "%pf with preempt_count %08x,"
 				       " exited with %08x?\n", h - softirq_vec,
 				       softirq_to_name[h - softirq_vec],
 				       h->action, prev_count, preempt_count());

Please fix the cause of the bug as well: i think this whole block of debug checks should move into a softirq_debug_check(h, prev_count) helper inline function - that would clean up the insane printk line which is currently spread out on 5 lines ...

It would also make __do_softirq() more readable.

Thanks,

Ingo

#2 lore raw

PATCH 1/1 softirq: cleanup preempt check

The preempt debugging check in the softirq code is ugly. The print is lenghty and spread over several lines which makes the code difficult to read. This was also the reason for the wrong spacing in the message.

So move the check into a separate inlined function and make the print text a one-liner for easier grepping.

Cc Ingo Molnar <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 kernel/softirq.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)
kernel/softirq.c +13 -8
index 2bf4cd5..4366370 100644
@@ -177,6 +177,17 @@ void local_bh_enable_ip(unsigned long ip)
 }
 EXPORT_SYMBOL(local_bh_enable_ip);
 
+static inline void softirq_preempt_check(struct softirq_action *h,
+		int prev_count)
+{
+	if (unlikely(prev_count != preempt_count())) {
+		printk(KERN_ERR "huh, entered softirq %td %s %pf with preempt_count %08x, exited with %08x?\n",
+			h - softirq_vec, softirq_to_name[h - softirq_vec],
+			h->action, prev_count, preempt_count());
+		preempt_count() = prev_count;
+	}
+}
+
 /*
  * We restart softirq processing MAX_SOFTIRQ_RESTART times,
  * and we fall back to softirqd after that.
@@ -218,14 +229,8 @@ restart:
 			trace_softirq_entry(h, softirq_vec);
 			h->action(h);
 			trace_softirq_exit(h, softirq_vec);
-			if (unlikely(prev_count != preempt_count())) {
-				printk(KERN_ERR "huh, entered softirq %td %s "
-				       "%pf with preempt_count %08x,"
-				       " exited with %08x?\n", h - softirq_vec,
-				       softirq_to_name[h - softirq_vec],
-				       h->action, prev_count, preempt_count());
-				preempt_count() = prev_count;
-			}
+
+			softirq_preempt_check(h, prev_count);
 
 			rcu_bh_qs(cpu);
 		}
Signature · 1 line
1.7.3.1