lkml.org 
[lkml]   [2001]   [Apr]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: Serial port latency
Pavel Machek wrote:
>
> > >
> > > I've seen similar bugs. If you hook something on schedule_tq and
> > forget
> > > to set current->need_resched, this is exactly what you get.
> > >
> > I'm running with a patch that printk's if cpu_idle() is called while a
> > softirq is pending.
> > If I access the floppy on my K6/200 every track triggers the check, and
> > sometimes the console blanking code triggers it.
>
> Seems floppy and console is buggy, then.
>

No. The softirq implementation is buggy.
I can trigger the problem with the TASKLET_HI (floppy), and both net rx
and tx (ping -l)

> > What about creating a special cpu_is_idle() function that the idle
> > functions must call before sleeping?
>
> I'd say just fix all the bugs.
>

Ok, there are 2 bugs that are (afaics) impossible to fix without
checking for pending softirq's in cpu_idle():

a)
queue_task(my_task1, tq_immediate);
mark_bh();
schedule();
;within schedule: do_softirq()
;within my_task1:
mark_bh();
; bh returns, but do_softirq won't loop
; do_softirq returns.
; schedule() clears current->need_resched
; idle thread scheduled.
--> idle can run although softirq's are pending

I assume I trigger this race with the floppy driver.

b)
hw interrupt
do_softirq
within the net_rx handler: another hw interrupt, additional packets are
queued
do_softirq won't loop.
returns to idle thread. --> packets delayed unnecessary.

What about the attached patch? Obviously the other idle cpu must be
converted to use the function as well.

--
Manfred--- 2.4/arch/i386/kernel/process.c Thu Feb 22 22:28:52 2001
+++ build-2.4/arch/i386/kernel/process.c Sun Apr 1 00:05:21 2001
@@ -73,6 +73,30 @@
hlt_counter--;
}

+/**
+ * cpu_is_idle - helper function for idle functions
+ *
+ * pm_idle functions must call this function to verify that
+ * the cpu is really idle. It must be called with disabled
+ * local interrupts.
+ * Return values:
+ * 0: cpu was not idle, local interrupts reenabled.
+ * 1: go into power saving mode, local interrupts are
+ * still disabled.
+*/
+static inline int cpu_is_idle(void)
+{
+ if (current->need_resched) {
+ __sti();
+ return 0;
+ }
+ if (softirq_active(smp_processor_id()) & softirq_mask(smp_processor_id())) {
+ __sti();
+ do_softirq();
+ return 0;
+ }
+ return 1;
+}
/*
* We use this if we don't have any better
* idle routine..
@@ -81,10 +105,8 @@
{
if (current_cpu_data.hlt_works_ok && !hlt_counter) {
__cli();
- if (!current->need_resched)
+ if (cpu_is_idle())
safe_halt();
- else
- __sti();
}
}

\
 
 \ /
  Last update: 2005-03-22 13:22    [W:0.131 / U:2.880 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site