All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] softlockup: fix to allow compiling with !DETECT_HUNG_TASK
@ 2009-01-16 17:09 Mandeep Singh Baines
  2009-01-16 17:18 ` Ingo Molnar
  0 siblings, 1 reply; 4+ messages in thread
From: Mandeep Singh Baines @ 2009-01-16 17:09 UTC (permalink / raw
  To: mingo, linux-kernel; +Cc: hannes, rientjes, mbligh, thockin

Ingo Molnar (mingo@elte.hu) wrote:
> 
> doesnt build with !SOFTLOCKUP:
> 
> kernel/fork.c:1049: error: 'struct task_struct' has no member named 'last_switch_count'
> kernel/fork.c:1050: error: 'struct task_struct' has no member named 'last_switch_timestamp'
> 
> Could you send a delta fix patch relative to -v4 please? Thanks,
> 
> 	Ingo

Oops. Will be more careful next time.

---

Fixes the following compile error:

kernel/fork.c:1049: error: 'struct task_struct' has no member named 'last_switch_count'
kernel/fork.c:1050: error: 'struct task_struct' has no member named 'last_switch_timestamp'

Signed-off-by: Mandeep Singh Baines <msb@google.com>
---
 kernel/fork.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/fork.c b/kernel/fork.c
index fb1f5e9..d68e59b 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1045,7 +1045,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
 
 	p->default_timer_slack_ns = current->timer_slack_ns;
 
-#ifdef CONFIG_DETECT_SOFTLOCKUP
+#ifdef CONFIG_DETECT_HUNG_TASK
 	p->last_switch_count = 0;
 	p->last_switch_timestamp = 0;
 #endif
-- 
1.5.4.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] softlockup: fix to allow compiling with !DETECT_HUNG_TASK
  2009-01-16 17:09 [PATCH] softlockup: fix to allow compiling with !DETECT_HUNG_TASK Mandeep Singh Baines
@ 2009-01-16 17:18 ` Ingo Molnar
  2009-01-17 18:31   ` [PATCH] softlockup: fix potential race in hung_task when resetting timeout Mandeep Singh Baines
  0 siblings, 1 reply; 4+ messages in thread
From: Ingo Molnar @ 2009-01-16 17:18 UTC (permalink / raw
  To: Mandeep Singh Baines; +Cc: linux-kernel, hannes, rientjes, mbligh, thockin


* Mandeep Singh Baines <msb@google.com> wrote:

> Ingo Molnar (mingo@elte.hu) wrote:
> > 
> > doesnt build with !SOFTLOCKUP:
> > 
> > kernel/fork.c:1049: error: 'struct task_struct' has no member named 'last_switch_count'
> > kernel/fork.c:1050: error: 'struct task_struct' has no member named 'last_switch_timestamp'
> > 
> > Could you send a delta fix patch relative to -v4 please? Thanks,
> > 
> > 	Ingo
> 
> Oops. Will be more careful next time.

np - applied to tip/core/softlockup. Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] softlockup: fix potential race in hung_task when resetting timeout
  2009-01-16 17:18 ` Ingo Molnar
@ 2009-01-17 18:31   ` Mandeep Singh Baines
  2009-01-18 18:22     ` Ingo Molnar
  0 siblings, 1 reply; 4+ messages in thread
From: Mandeep Singh Baines @ 2009-01-17 18:31 UTC (permalink / raw
  To: Ingo Molnar; +Cc: linux-kernel, hannes, rientjes, mbligh, thockin

Patch against tip/core/softlockup.

---

A potential race exists if sysctl_hung_task_timeout_secs is reset to 0
while inside check_hung_uniterruptible_tasks(). If check_task() is
entered, a comparison with 0 will result in a false hung_task being
detected.

If sysctl_hung_task_panic is set, the system will panic.

Signed-off-by: Mandeep Singh Baines <msb@google.com>
---
 kernel/hung_task.c |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/kernel/hung_task.c b/kernel/hung_task.c
index ba5a77c..ba8ccd4 100644
--- a/kernel/hung_task.c
+++ b/kernel/hung_task.c
@@ -72,7 +72,8 @@ static unsigned long get_timestamp(void)
 	return cpu_clock(this_cpu) >> 30LL;  /* 2^30 ~= 10^9 */
 }
 
-static void check_hung_task(struct task_struct *t, unsigned long now)
+static void check_hung_task(struct task_struct *t, unsigned long now,
+			    unsigned long timeout)
 {
 	unsigned long switch_count = t->nvcsw + t->nivcsw;
 
@@ -84,8 +85,7 @@ static void check_hung_task(struct task_struct *t, unsigned long now)
 		t->last_switch_timestamp = now;
 		return;
 	}
-	if ((long)(now - t->last_switch_timestamp) <
-					sysctl_hung_task_timeout_secs)
+	if ((long)(now - t->last_switch_timestamp) < timeout)
 		return;
 	if (!sysctl_hung_task_warnings)
 		return;
@@ -96,8 +96,7 @@ static void check_hung_task(struct task_struct *t, unsigned long now)
 	 * complain:
 	 */
 	printk(KERN_ERR "INFO: task %s:%d blocked for more than "
-			"%ld seconds.\n", t->comm, t->pid,
-			sysctl_hung_task_timeout_secs);
+			"%ld seconds.\n", t->comm, t->pid, timeout);
 	printk(KERN_ERR "\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\""
 			" disables this message.\n");
 	sched_show_task(t);
@@ -115,7 +114,7 @@ static void check_hung_task(struct task_struct *t, unsigned long now)
  * a really long time (120 seconds). If that happens, print out
  * a warning.
  */
-static void check_hung_uninterruptible_tasks(void)
+static void check_hung_uninterruptible_tasks(unsigned long timeout)
 {
 	int max_count = sysctl_hung_task_check_count;
 	unsigned long now = get_timestamp();
@@ -134,7 +133,7 @@ static void check_hung_uninterruptible_tasks(void)
 			goto unlock;
 		/* use "==" to skip the TASK_KILLABLE tasks waiting on NFS */
 		if (t->state == TASK_UNINTERRUPTIBLE)
-			check_hung_task(t, now);
+			check_hung_task(t, now, timeout);
 	} while_each_thread(g, t);
  unlock:
 	read_unlock(&tasklist_lock);
@@ -180,8 +179,17 @@ static int watchdog(void *dummy)
 	update_poll_jiffies();
 
 	for ( ; ; ) {
+		unsigned long timeout;
+
 		while (schedule_timeout_interruptible(hung_task_poll_jiffies));
-		check_hung_uninterruptible_tasks();
+
+		/*
+		 * Need to cache timeout here to avoid timeout being set
+		 * to 0 via sysctl while inside check_hung_*_tasks().
+		 */
+		timeout = sysctl_hung_task_timeout_secs;
+		if (timeout)
+			check_hung_uninterruptible_tasks(timeout);
 	}
 
 	return 0;
-- 
1.5.4.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] softlockup: fix potential race in hung_task when resetting timeout
  2009-01-17 18:31   ` [PATCH] softlockup: fix potential race in hung_task when resetting timeout Mandeep Singh Baines
@ 2009-01-18 18:22     ` Ingo Molnar
  0 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2009-01-18 18:22 UTC (permalink / raw
  To: Mandeep Singh Baines; +Cc: linux-kernel, hannes, rientjes, mbligh, thockin


* Mandeep Singh Baines <msb@google.com> wrote:

> Patch against tip/core/softlockup.
> 
> ---
> 
> A potential race exists if sysctl_hung_task_timeout_secs is reset to 0
> while inside check_hung_uniterruptible_tasks(). If check_task() is
> entered, a comparison with 0 will result in a false hung_task being
> detected.
> 
> If sysctl_hung_task_panic is set, the system will panic.
> 
> Signed-off-by: Mandeep Singh Baines <msb@google.com>
> ---
>  kernel/hung_task.c |   24 ++++++++++++++++--------
>  1 files changed, 16 insertions(+), 8 deletions(-)

Applied to tip/core/softlockup, thanks Mandeep!

	Ingo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-01-18 18:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-16 17:09 [PATCH] softlockup: fix to allow compiling with !DETECT_HUNG_TASK Mandeep Singh Baines
2009-01-16 17:18 ` Ingo Molnar
2009-01-17 18:31   ` [PATCH] softlockup: fix potential race in hung_task when resetting timeout Mandeep Singh Baines
2009-01-18 18:22     ` Ingo Molnar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.