All of lore.kernel.org
 help / color / mirror / Atom feed
From: Manfred Spraul <manfred@colorfullife.com>
To: Pavel Machek <pavel@suse.cz>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Serial port latency
Date: Sun, 01 Apr 2001 00:09:34 +0200	[thread overview]
Message-ID: <3AC6559E.575C4BAA@colorfullife.com> (raw)
In-Reply-To: <000401c0b319517fea9@local> <20010325231013.A34@(none)> <000401c0b828$bbdf7380$5517fea9@local> <20010331003645.F1579@atrey.karlin.mff.cuni.cz>

[-- Attachment #1: Type: text/plain, Size: 1514 bytes --]

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

[-- Attachment #2: patch-proc --]
[-- Type: text/plain, Size: 1025 bytes --]

--- 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();
 	}
 }
 


  reply	other threads:[~2001-04-01  9:05 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <000401c0b319517fea9@local>
2001-03-25 23:10 ` Serial port latency Pavel Machek
2001-03-29  7:58   ` Manfred Spraul
2001-03-30 22:36     ` Pavel Machek
2001-03-31 22:09       ` Manfred Spraul [this message]
2001-04-03 23:07         ` softirq buggy [Re: Serial port latency] Pavel Machek
2001-04-04 21:18           ` Manfred Spraul
2001-04-06 12:00             ` Pavel Machek
2001-04-07 22:28               ` Manfred Spraul
2001-04-08 16:58                 ` kuznet
2001-04-08 17:21                   ` Manfred Spraul
2001-04-08 17:58                     ` kuznet
2001-04-08 18:16                       ` Manfred Spraul
2001-04-08 21:35                       ` [PATCH] Re: softirq buggy Manfred Spraul
2001-04-09  8:42                         ` Albert D. Cahalan
2001-04-09 13:50                         ` Andrea Arcangeli
2001-04-09 15:26                           ` Manfred Spraul
2001-04-09 17:31                             ` Andrea Arcangeli
2001-04-09 17:48                             ` kuznet
2001-04-09 18:26                               ` Andrea Arcangeli
2001-04-10  0:37   ` Serial port latency Andrea Arcangeli
2001-03-22 21:45 Manfred Spraul
     [not found] <Pine.LNX.4.20.0103221219410.3343-100000@linuxtaj.korpivaara.org>
2001-03-22 20:03 ` Geir Thomassen
2001-03-22 20:17   ` Trent Jarvi
  -- strict thread matches above, loose matches on Subject: below --
2001-03-22 18:21 Geir Thomassen
2001-03-22 20:08 ` Theodore Tso
2001-03-22 20:32   ` Geir Thomassen
2001-03-22 20:55     ` Paul Fulghum
2001-03-22 22:44     ` Theodore Tso
     [not found] ` <20010322141937.C22479@universal-fasteners.com>
2001-03-22 21:02   ` Geir Thomassen
2001-03-22 21:52 ` Jonathan Lundell
2001-03-22 23:25 ` Pavel Machek
2001-03-23 14:43   ` Geir Thomassen

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=3AC6559E.575C4BAA@colorfullife.com \
    --to=manfred@colorfullife.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@suse.cz \
    /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 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.