[-mm UPDATE PATCH 13/32] ppc64: replace schedule_timeout() with msleep_interruptible()
Nishanth Aravamudan
nacc at us.ibm.com
Wed Aug 17 08:56:08 EST 2005
On 16.08.2005 [13:30:01 +0200], Arnd Bergmann wrote:
> On Maandag 15 August 2005 20:15, Nishanth Aravamudan wrote:
> > Description: Use schedule_timeout_interruptible() instead of
> > set_current_state()/schedule_timeout() to reduce kernel size.
>
> Shouldn't these use msleep_interruptible() instead?
Yes, you are right. I had forgotten to get on that after my -KJ patches
which affected these files. Does the following patch look ok/better?
This should avoid the load average increase issues the ppc64 maintainers
(rightly) had with my older -KJ patches.
Thanks,
Nish
Description: Use msleep_interruptible() instead of schedule_timeout() in
ppc64-specific code to cleanup/simplify the sleeping logic. Change the
units of the parameter of do_event_scan_all_cpus() to milliseconds from
jiffies. The return value of rtas_extended_busy_delay_time() was
incorrectly being used as a jiffies value (it is actually milliseconds),
which is fixed by using the value as a parameter to
msleep_interruptible(). Also, use rtas_extended_busy_delay_time() in
another case where similar logic is duplicated.
Signed-off-by: Nishanth Aravamudan <nacc at us.ibm.com>
---
arch/ppc64/kernel/rtasd.c | 10 +++++-----
arch/ppc64/kernel/rtc.c | 7 +++----
arch/ppc64/kernel/scanlog.c | 17 ++++-------------
3 files changed, 12 insertions(+), 22 deletions(-)
diff -urpN 2.6.13-rc5-mm1/arch/ppc64/kernel/rtasd.c 2.6.13-rc5-mm1-dev/arch/ppc64/kernel/rtasd.c
--- 2.6.13-rc5-mm1/arch/ppc64/kernel/rtasd.c 2005-08-07 09:57:45.000000000 -0700
+++ 2.6.13-rc5-mm1-dev/arch/ppc64/kernel/rtasd.c 2005-08-16 15:50:10.000000000 -0700
@@ -19,6 +19,7 @@
#include <linux/vmalloc.h>
#include <linux/spinlock.h>
#include <linux/cpu.h>
+#include <linux/delay.h>
#include <asm/uaccess.h>
#include <asm/io.h>
@@ -412,8 +413,7 @@ static void do_event_scan_all_cpus(long
/* Drop hotplug lock, and sleep for the specified delay */
unlock_cpu_hotplug();
- set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(delay);
+ msleep_interruptible(delay);
lock_cpu_hotplug();
cpu = next_cpu(cpu, cpu_online_map);
@@ -442,7 +442,7 @@ static int rtasd(void *unused)
printk(KERN_INFO "RTAS daemon started\n");
- DEBUG("will sleep for %d jiffies\n", (HZ*60/rtas_event_scan_rate) / 2);
+ DEBUG("will sleep for %d milliseconds\n", (30000/rtas_event_scan_rate));
/* See if we have any error stored in NVRAM */
memset(logdata, 0, rtas_error_log_max);
@@ -459,7 +459,7 @@ static int rtasd(void *unused)
}
/* First pass. */
- do_event_scan_all_cpus(HZ);
+ do_event_scan_all_cpus(1000);
if (surveillance_timeout != -1) {
DEBUG("enabling surveillance\n");
@@ -471,7 +471,7 @@ static int rtasd(void *unused)
* machines have problems if we call event-scan too
* quickly. */
for (;;)
- do_event_scan_all_cpus((HZ*60/rtas_event_scan_rate) / 2);
+ do_event_scan_all_cpus(30000/rtas_event_scan_rate);
error:
/* Should delete proc entries */
diff -urpN 2.6.13-rc5-mm1/arch/ppc64/kernel/rtc.c 2.6.13-rc5-mm1-dev/arch/ppc64/kernel/rtc.c
--- 2.6.13-rc5-mm1/arch/ppc64/kernel/rtc.c 2005-08-07 09:57:45.000000000 -0700
+++ 2.6.13-rc5-mm1-dev/arch/ppc64/kernel/rtc.c 2005-08-16 15:49:53.000000000 -0700
@@ -35,6 +35,7 @@
#include <linux/spinlock.h>
#include <linux/bcd.h>
#include <linux/interrupt.h>
+#include <linux/delay.h>
#include <asm/io.h>
#include <asm/uaccess.h>
@@ -351,8 +352,7 @@ void rtas_get_rtc_time(struct rtc_time *
return; /* delay not allowed */
}
wait_time = rtas_extended_busy_delay_time(error);
- set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(wait_time);
+ msleep_interruptible(wait_time);
error = RTAS_CLOCK_BUSY;
}
} while (error == RTAS_CLOCK_BUSY && (__get_tb() < max_wait_tb));
@@ -386,8 +386,7 @@ int rtas_set_rtc_time(struct rtc_time *t
if (in_interrupt())
return 1; /* probably decrementer */
wait_time = rtas_extended_busy_delay_time(error);
- set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(wait_time);
+ msleep_interruptible(wait_time);
error = RTAS_CLOCK_BUSY;
}
} while (error == RTAS_CLOCK_BUSY && (__get_tb() < max_wait_tb));
diff -urpN 2.6.13-rc5-mm1/arch/ppc64/kernel/scanlog.c 2.6.13-rc5-mm1-dev/arch/ppc64/kernel/scanlog.c
--- 2.6.13-rc5-mm1/arch/ppc64/kernel/scanlog.c 2005-08-07 09:57:22.000000000 -0700
+++ 2.6.13-rc5-mm1-dev/arch/ppc64/kernel/scanlog.c 2005-08-16 15:49:39.000000000 -0700
@@ -25,6 +25,7 @@
#include <linux/errno.h>
#include <linux/proc_fs.h>
#include <linux/init.h>
+#include <linux/delay.h>
#include <asm/uaccess.h>
#include <asm/rtas.h>
#include <asm/prom.h>
@@ -77,7 +78,7 @@ static ssize_t scanlog_read(struct file
return -EFAULT;
for (;;) {
- wait_time = HZ/2; /* default wait if no data */
+ wait_time = 500; /* default wait if no data */
spin_lock(&rtas_data_buf_lock);
memcpy(rtas_data_buf, data, RTAS_DATA_BUF_SIZE);
status = rtas_call(ibm_scan_log_dump, 2, 1, NULL,
@@ -107,24 +108,14 @@ static ssize_t scanlog_read(struct file
break;
default:
if (status > 9900 && status <= 9905) {
- /* No data. RTAS is hinting at a delay required
- * between 1-100000 milliseconds
- */
- int ms = 1;
- for (; status > 9900; status--)
- ms = ms * 10;
- /* Use microseconds for reasonable accuracy */
- ms *= 1000;
- wait_time = ms / (1000000/HZ); /* round down is fine */
- /* Fall through to sleep */
+ wait_time = rtas_extended_busy_delay_time(status);
} else {
printk(KERN_ERR "scanlog: unknown error from rtas: %d\n", status);
return -EIO;
}
}
/* Apparently no data yet. Wait and try again. */
- set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(wait_time);
+ msleep_interruptible(wait_time);
}
/*NOTREACHED*/
}
More information about the Linuxppc64-dev
mailing list