Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 54635
b: refs/heads/master
c: 966812d
h: refs/heads/master
i:
  54633: 587bf72
  54631: 8da34c2
v: v3
  • Loading branch information
Jeremy Fitzhardinge authored and Linus Torvalds committed May 8, 2007
1 parent df9588d commit baf468c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8524070b7982d76258942275908b7434cfcab4b4
refs/heads/master: 966812dc98e6a7fcdf759cbfa0efab77500a8868
35 changes: 29 additions & 6 deletions trunk/kernel/softlockup.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,19 @@ static struct notifier_block panic_block = {
.notifier_call = softlock_panic,
};

/*
* Returns seconds, approximately. We don't need nanosecond
* resolution, and we don't need to waste time with a big divide when
* 2^30ns == 1.074s.
*/
static unsigned long get_timestamp(void)
{
return sched_clock() >> 30; /* 2^30 ~= 10^9 */
}

void touch_softlockup_watchdog(void)
{
__raw_get_cpu_var(touch_timestamp) = jiffies;
__raw_get_cpu_var(touch_timestamp) = get_timestamp();
}
EXPORT_SYMBOL(touch_softlockup_watchdog);

Expand All @@ -48,9 +58,17 @@ void softlockup_tick(void)
{
int this_cpu = smp_processor_id();
unsigned long touch_timestamp = per_cpu(touch_timestamp, this_cpu);
unsigned long print_timestamp;
unsigned long now;

/* prevent double reports: */
if (per_cpu(print_timestamp, this_cpu) == touch_timestamp ||
/* watchdog task hasn't updated timestamp yet */
if (touch_timestamp == 0)
return;

print_timestamp = per_cpu(print_timestamp, this_cpu);

/* report at most once a second */
if (print_timestamp < (touch_timestamp + 1) ||
did_panic ||
!per_cpu(watchdog_task, this_cpu))
return;
Expand All @@ -61,12 +79,14 @@ void softlockup_tick(void)
return;
}

now = get_timestamp();

/* Wake up the high-prio watchdog task every second: */
if (time_after(jiffies, touch_timestamp + HZ))
if (now > (touch_timestamp + 1))
wake_up_process(per_cpu(watchdog_task, this_cpu));

/* Warn about unreasonable 10+ seconds delays: */
if (time_after(jiffies, touch_timestamp + 10*HZ)) {
if (now > (touch_timestamp + 10)) {
per_cpu(print_timestamp, this_cpu) = touch_timestamp;

spin_lock(&print_lock);
Expand All @@ -87,6 +107,9 @@ static int watchdog(void * __bind_cpu)
sched_setscheduler(current, SCHED_FIFO, &param);
current->flags |= PF_NOFREEZE;

/* initialize timestamp */
touch_softlockup_watchdog();

/*
* Run briefly once per second to reset the softlockup timestamp.
* If this gets delayed for more than 10 seconds then the
Expand Down Expand Up @@ -118,7 +141,7 @@ cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
printk("watchdog for %i failed\n", hotcpu);
return NOTIFY_BAD;
}
per_cpu(touch_timestamp, hotcpu) = jiffies;
per_cpu(touch_timestamp, hotcpu) = 0;
per_cpu(watchdog_task, hotcpu) = p;
kthread_bind(p, hotcpu);
break;
Expand Down

0 comments on commit baf468c

Please sign in to comment.