public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org, Daniel Walker <dwalker@mvista.com>
Subject: Re: [patch] Real-Time Preemption, -RT-2.6.13-rc4-V0.7.52-01
Date: Wed, 03 Aug 2005 12:44:07 -0400	[thread overview]
Message-ID: <1123087447.1590.136.camel@localhost.localdomain> (raw)
In-Reply-To: <1123080606.1590.119.camel@localhost.localdomain>

Ingo,

Doing some more tests on the patch, I found that I don't like the
placement in sched.c of the touch_light_softlockup_watchdog. I figure
that it may be better to put in into __schedule instead.  This really
shows where a task is taken off the run queue.

-- Steve

New patch: I've only tested this with the deadlock modules, and not with
the kjournald case. I'll do that tonight when I'm no longer needing my
computer for other tests.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Index: linux_realtime_ernie/kernel/irq/handle.c
===================================================================
--- linux_realtime_ernie/kernel/irq/handle.c	(revision 266)
+++ linux_realtime_ernie/kernel/irq/handle.c	(working copy)
@@ -177,6 +177,14 @@
 	 */
 	local_irq_save(flags);
 #endif
+	/*
+	 * If the task is currently running in user mode, don't 
+	 * detect soft lockups.  If CONFIG_DETECT_SOFTLOCKUP is not
+	 * configured, this should be optimized out.
+	 */
+	if (user_mode(regs))
+		touch_light_softlockup_watchdog();
+
 	kstat_this_cpu.irqs[irq]++;
 	if (desc->status & IRQ_PER_CPU) {
 		irqreturn_t action_ret;
Index: linux_realtime_ernie/kernel/sched.c
===================================================================
--- linux_realtime_ernie/kernel/sched.c	(revision 266)
+++ linux_realtime_ernie/kernel/sched.c	(working copy)
@@ -3209,6 +3209,7 @@
 		else {
 			if (prev->state == TASK_UNINTERRUPTIBLE)
 				rq->nr_uninterruptible++;
+			touch_light_softlockup_watchdog();
 			deactivate_task(prev, rq);
 		}
 	}
Index: linux_realtime_ernie/kernel/softlockup.c
===================================================================
--- linux_realtime_ernie/kernel/softlockup.c	(revision 269)
+++ linux_realtime_ernie/kernel/softlockup.c	(working copy)
@@ -3,6 +3,10 @@
  *
  * started by Ingo Molnar, (C) 2005, Red Hat
  *
+ * Steven Rostedt, Kihon Technologies Inc.
+ *   Added light softlockup detection off of what Daniel Walker of
+ *   MontaVista started.
+ *
  * this code detects soft lockups: incidents in where on a CPU
  * the kernel does not reschedule for 10 seconds or more.
  */
@@ -20,9 +24,7 @@
 static DEFINE_PER_CPU(unsigned long, timeout) = INITIAL_JIFFIES;
 static DEFINE_PER_CPU(unsigned long, timestamp) = INITIAL_JIFFIES;
 static DEFINE_PER_CPU(unsigned long, print_timestamp) = INITIAL_JIFFIES;
-static DEFINE_PER_CPU(struct task_struct *, prev_task);
 static DEFINE_PER_CPU(struct task_struct *, watchdog_task);
-static DEFINE_PER_CPU(unsigned long, task_counter);
 
 static int did_panic = 0;
 static int softlock_panic(struct notifier_block *this, unsigned long event,
@@ -42,6 +44,11 @@
 	per_cpu(timestamp, raw_smp_processor_id()) = jiffies;
 }
 
+void touch_light_softlockup_watchdog(void)
+{
+	current->softlockup_count = 0;
+}
+
 /*
  * This callback runs from the timer interrupt, and checks
  * whether the watchdog thread has hung or not:
@@ -59,24 +66,20 @@
 		if (!per_cpu(watchdog_task, this_cpu))
 			return;
 
-		if (per_cpu(prev_task, this_cpu) != current || 
-			!rt_task(current)) {
-			per_cpu(prev_task, this_cpu) = current;
-			per_cpu(task_counter, this_cpu) = 0;
-		}
-		else if ((++per_cpu(task_counter, this_cpu) > 10) && printk_ratelimit()) {
-
-			spin_lock(&print_lock);
-			printk(KERN_ERR "BUG: possible soft lockup detected on CPU#%u! %lu-%lu(%lu)\n",
-				this_cpu, jiffies, timestamp, timeout);
-			printk("curr=%s:%d\n",current->comm,current->pid);
-			
-			dump_stack();
+		if (current->pid) {
+			if (++current->softlockup_count > 10) {
+				spin_lock(&print_lock);
+				printk(KERN_ERR "BUG: possible soft lockup detected on CPU#%u! %lu-%lu(%lu)\n",
+				       this_cpu, jiffies, timestamp, timeout);
+				printk("curr=%s:%d count=%ld\n",current->comm,current->pid,
+				       current->softlockup_count);
+				dump_stack();
 #if defined(__i386__) && defined(CONFIG_SMP)
-			nmi_show_all_regs();
+				nmi_show_all_regs();
 #endif
-			spin_unlock(&print_lock);
-			per_cpu(task_counter, this_cpu) = 0;
+				spin_unlock(&print_lock);
+				touch_light_softlockup_watchdog();
+			}
 		}
 
 		wake_up_process(per_cpu(watchdog_task, this_cpu));
@@ -101,7 +104,6 @@
 		nmi_show_all_regs();
 #endif
 		spin_unlock(&print_lock);
-		per_cpu(task_counter, this_cpu) = 0;
 	}
 }
 
Index: linux_realtime_ernie/include/linux/sched.h
===================================================================
--- linux_realtime_ernie/include/linux/sched.h	(revision 266)
+++ linux_realtime_ernie/include/linux/sched.h	(working copy)
@@ -307,6 +307,7 @@
 extern void softlockup_tick(void);
 extern void spawn_softlockup_task(void);
 extern void touch_softlockup_watchdog(void);
+extern void touch_light_softlockup_watchdog(void);
 #else
 static inline void softlockup_tick(void)
 {
@@ -317,6 +318,9 @@
 static inline void touch_softlockup_watchdog(void)
 {
 }
+static inline void touch_light_softlockup_watchdog(void)
+{
+}
 #endif
 
 /* Attach to any functions which should be ignored in wchan output. */
@@ -898,6 +902,12 @@
 #ifdef CONFIG_DEBUG_PREEMPT
 	int lock_count;
 #endif
+#ifdef CONFIG_DETECT_SOFTLOCKUP
+	unsigned long	softlockup_count; /* Count to keep track how long the
+					   *  thread is in the kernel without
+					   *  sleeping.
+					   */
+#endif
 	/* realtime bits */
 	struct list_head delayed_put;
 	struct plist pi_waiters;



  parent reply	other threads:[~2005-08-03 16:44 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-30 16:03 [patch] Real-Time Preemption, -RT-2.6.13-rc4-V0.7.52-01 Ingo Molnar
2005-07-30 20:47 ` Peter Zijlstra
2005-07-30 20:52   ` Ingo Molnar
2005-07-31  4:47     ` Lee Revell
2005-07-31  6:38       ` Ingo Molnar
2005-08-01  4:45         ` Lee Revell
2005-08-01 21:08           ` Ingo Molnar
2005-08-01 21:12             ` Ingo Molnar
2005-08-02 13:56           ` Steven Rostedt
2005-08-02 14:05             ` Lee Revell
2005-08-02 14:20               ` Steven Rostedt
2005-08-02 15:37                 ` 2.6.13-rc3 -> sluggish PS2 keyboard (was Re: [patch] Real-Time Preemption, -RT-2.6.13-rc4-V0.7.52-01) Lee Revell
2005-08-02 15:44                   ` Vojtech Pavlik
2005-08-02 15:46                     ` Lee Revell
2005-08-02 15:47                     ` Lee Revell
2005-08-02 15:53                       ` Steven Rostedt
2005-08-02 15:55                       ` Vojtech Pavlik
2005-08-02 15:55                   ` Dmitry Torokhov
2005-08-02 15:38                 ` [patch] Real-Time Preemption, -RT-2.6.13-rc4-V0.7.52-01 Lee Revell
2005-07-31  8:03     ` Peter Zijlstra
2005-07-31 10:44       ` Ingo Molnar
2005-07-31 15:56         ` [patch] Real-Time Preemption, -RT-2.6.13-rc4-V0.7.52-05 Gene Heskett
2005-08-01 18:22 ` [patch] Real-Time Preemption, -RT-2.6.13-rc4-V0.7.52-01 Steven Rostedt
2005-08-01 19:49   ` Steven Rostedt
2005-08-01 20:52   ` Ingo Molnar
2005-08-01 21:09     ` Daniel Walker
2005-08-01 21:15       ` Ingo Molnar
2005-08-02  0:43       ` Steven Rostedt
2005-08-01 21:15     ` Steven Rostedt
2005-08-01 21:23       ` Ingo Molnar
2005-08-01 21:20   ` Daniel Walker
2005-08-02  0:53     ` Steven Rostedt
2005-08-02 10:19       ` Ingo Molnar
2005-08-02 19:45         ` Steven Rostedt
2005-08-02 19:56           ` Steven Rostedt
2005-08-02 23:38           ` Daniel Walker
2005-08-03  0:00             ` Steven Rostedt
2005-08-03  1:12               ` George Anzinger
2005-08-03  1:48                 ` Keith Owens
2005-08-03  2:12                   ` George Anzinger
2005-08-03  2:25               ` Daniel Walker
2005-08-03  2:42                 ` Steven Rostedt
2005-08-03  2:58                   ` Daniel Walker
2005-08-03 10:30                     ` Steven Rostedt
2005-08-03 15:10                       ` Daniel Walker
2005-08-03 10:37                     ` [Question] arch-independent way to differentiate between user and kernel Steven Rostedt
2005-08-03 10:48                       ` Ingo Molnar
2005-08-03 12:18                         ` Steven Rostedt
2005-08-03 10:56                       ` [Question] arch-independent way to differentiate between user andkernel linux-os (Dick Johnson)
2005-08-03 11:44                         ` Steven Rostedt
2005-08-03 12:04                           ` Ingo Molnar
2005-08-03 12:30                             ` Steven Rostedt
2005-08-03 14:50                     ` [patch] Real-Time Preemption, -RT-2.6.13-rc4-V0.7.52-01 Steven Rostedt
2005-08-03 15:15                       ` Steven Rostedt
2005-08-03 15:57                         ` Steven Rostedt
2005-08-03 16:44                       ` Steven Rostedt [this message]
     [not found]                         ` <20050812125844.GA13357@elte.hu>
2005-08-26  4:24                           ` Steven Rostedt
2005-08-26  6:08                             ` Ingo Molnar
2005-08-26 11:20                               ` Steven Rostedt
2005-08-30 10:58                                 ` Stephen C. Tweedie
2005-08-30 11:14                                   ` Ingo Molnar
2005-08-30 11:00                             ` Stephen C. Tweedie
2005-08-02  3:55     ` Steven Rostedt
2005-08-02  4:07       ` Daniel Walker
2005-08-02 14:53 ` Steven Rostedt
2005-08-04 12:20 ` Andrzej Nowak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1123087447.1590.136.camel@localhost.localdomain \
    --to=rostedt@goodmis.org \
    --cc=dwalker@mvista.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox