linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Alistair John Strachan <s0348365@sms.ed.ac.uk>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Realtime Preemption, 2.6.12, Beginners Guide?
Date: Wed, 6 Jul 2005 18:24:57 +0200	[thread overview]
Message-ID: <20050706162457.GA24728@elte.hu> (raw)
In-Reply-To: <200507061655.45801.s0348365@sms.ed.ac.uk>


* Alistair John Strachan <s0348365@sms.ed.ac.uk> wrote:

> > (generally i try to mark every message in the -RT kernel that signals
> > some sort of anomaly with a 'BUG:' prefix - that makes it easy to do a
> > 'dmesg | grep BUG:' to find out whether anything bad is going on. All
> > other messages should be benign.)
> 
> Okay, I've got multiple other BUG: messages within 2-3 minutes of 
> booting that highlight problems in areas other than ACPI. Are they 
> useful to you?

yeah, please send them too - typically it's the first message that 
matters most (especially if the system crashes - which isnt the case 
here) - but sometimes the other ones are independent.

> > yes, this is a problem. You can probably work it around by disabling
> > ACPI, but it would be better to debug and fix it. The message was
> > generated because the kernel spent too much time [more than 10 seconds]
> > in acpi_processor_idle(), and the softlockup-thread (which runs at
> > SCHED_FIFO prio 99) was not scheduled for that amount of time. [or it
> > thought it was not scheduled.] Was there any suspend/resume activity
> > while you got that message?
> 
> No, this is during bootup that it occurs. Suspend and resume do work 
> and are compiled in on my laptop, but were never utilised.

was there a 10 seconds delay during bootup for such a message to be 
generated? Nothing should delay the softlockup threads. (but maybe their 
initial timekeeping is somehow impacted.)

> I've got a pair of nearly identical traces that highlight a 2645us 
> latency in smp_apic_timer_interrupt. I don't know how the trace is 
> formatted, so I can't tell if it occurred before or after this 
> function call. I also can't see how a ~1000us latency translates to a 
> ~2600us latency in the trace.
> 
> Since both traces were under 6K each, and I think the list limit is 
> higher, I risked it and have attached both.

thanks. They do show a real regression. softirq--3 got woken up at 
timestamp 1us:

  <idle>-0     0dnh2    1us : try_to_wake_up <softirq--3> (69 8c)

then we return from the (presumably timer) interrupt at timestamp 3us:

  <idle>-0     0dnh.    3us < (608)

( '<' in the trace signals return activity - can happen for syscalls and 
for interrupts.)

but the ACPI code is busy going to sleep:

  <idle>-0     0dn..    3us : acpi_hw_register_write (acpi_set_register)
  <idle>-0     0dn..    4us : acpi_hw_low_level_write (acpi_hw_register_write)
  <idle>-0     0dn..    4us+: acpi_os_write_port (acpi_hw_low_level_write)
  <idle>-0     0dn..    7us!: acpi_hw_low_level_write (acpi_hw_register_write)
  <idle>-0     0dnh. 2645us : smp_apic_timer_interrupt (c0252485 0 0)

and doesnt return for another 2638 microseconds!

the bug is probably that the ACPI code became interruptible when we 
introduced the IRQ soft-flag. This is clearly visible from the "d" flag:

                 _------=> CPU#
                / _-----=> irqs-off
               | / _----=> need-resched
               || / _---=> hardirq/softirq
               ||| / _--=> preempt-depth
               |||| /
               |||||     delay
   cmd     pid ||||| time  |   caller
      \   /    |||||   \   |   /
  <idle>-0     0dn..    3us : acpi_hw_register_write (acpi_set_register)
    /-----------^
 here

small 'd' means the soft IRQ-flag was disabled. Capital 'D' means that 
the CPU's irq-flag got disabled too. The ACPI code, when it prepares to 
sleep, has to disable direct interrupts too, otherwise the above 
scenario may occur. If a timer interrupt hits the ACPI code in that 
small window where it has already checked for need_resched(), but has 
not gone to sleep yet (so it cannot react to the timer IRQ by waking 
up), then we lose the wakeup.

could you try the patch below (or the -51-05 patch that i just 
uploaded), does it fix this latency?

	Ingo

Index: linux/arch/i386/kernel/process.c
===================================================================
--- linux.orig/arch/i386/kernel/process.c
+++ linux/arch/i386/kernel/process.c
@@ -211,7 +211,7 @@ EXPORT_SYMBOL_GPL(cpu_idle_wait);
  */
 static void mwait_idle(void)
 {
-	local_irq_enable();
+	raw_local_irq_enable();
 
 	if (!need_resched() && !need_resched_delayed()) {
 		set_thread_flag(TIF_POLLING_NRFLAG);
Index: linux/drivers/acpi/processor_idle.c
===================================================================
--- linux.orig/drivers/acpi/processor_idle.c
+++ linux/drivers/acpi/processor_idle.c
@@ -179,14 +179,14 @@ static void acpi_processor_idle (void)
 	 * Interrupts must be disabled during bus mastering calculations and
 	 * for C2/C3 transitions.
 	 */
-	local_irq_disable();
+	raw_local_irq_disable();
 
 	/*
 	 * Check whether we truly need to go idle, or should
 	 * reschedule:
 	 */
 	if (unlikely(need_resched())) {
-		local_irq_enable();
+		raw_local_irq_enable();
 		return;
 	}
 
@@ -248,7 +248,7 @@ static void acpi_processor_idle (void)
 		 *      issues (e.g. floppy DMA transfer overrun/underrun).
 		 */
 		if (pr->power.bm_activity & cx->demotion.threshold.bm) {
-			local_irq_enable();
+			raw_local_irq_enable();
 			next_state = cx->demotion.state;
 			goto end;
 		}
@@ -272,7 +272,7 @@ static void acpi_processor_idle (void)
 		if (pm_idle_save)
 			pm_idle_save();
 		else
-			safe_halt();
+			raw_safe_halt();
 		/*
                  * TBD: Can't get time duration while in C1, as resumes
 		 *      go to an ISR rather than here.  Need to instrument
@@ -291,7 +291,7 @@ static void acpi_processor_idle (void)
 		/* Get end time (ticks) */
 		t2 = inl(acpi_fadt.xpm_tmr_blk.address);
 		/* Re-enable interrupts */
-		local_irq_enable();
+		raw_local_irq_enable();
 		/* Compute time (ticks) that we were actually asleep */
 		sleep_ticks = ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD;
 		break;
@@ -310,13 +310,13 @@ static void acpi_processor_idle (void)
 		/* Enable bus master arbitration */
 		acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_DO_NOT_LOCK);
 		/* Re-enable interrupts */
-		local_irq_enable();
+		raw_local_irq_enable();
 		/* Compute time (ticks) that we were actually asleep */
 		sleep_ticks = ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD;
 		break;
 
 	default:
-		local_irq_enable();
+		raw_local_irq_enable();
 		return;
 	}
 
@@ -392,7 +392,7 @@ end:
 	if (pm_idle_save)
 		pm_idle_save();
 	else
-		safe_halt();
+		raw_safe_halt();
 	return;
 }
 
Index: linux/include/asm-i386/system.h
===================================================================
--- linux.orig/include/asm-i386/system.h
+++ linux/include/asm-i386/system.h
@@ -469,8 +469,6 @@ struct alt_instr { 
 
 #include <linux/rt_irq.h>
 
-#define safe_halt()	do { local_irq_enable(); __asm__ __volatile__("hlt": : :"memory"); } while (0)
-
 /*
  * disable hlt during certain critical i/o operations
  */

  reply	other threads:[~2005-07-07  2:28 UTC|newest]

Thread overview: 101+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-06 11:57 Realtime Preemption, 2.6.12, Beginners Guide? Alistair John Strachan
2005-07-06 12:51 ` Alistair John Strachan
2005-07-06 13:39   ` Ingo Molnar
2005-07-06 15:58     ` Alistair John Strachan
2005-07-06 16:28       ` Ingo Molnar
2005-07-06 16:31         ` Alistair John Strachan
2005-07-06 13:31 ` Ingo Molnar
2005-07-06 15:55   ` Alistair John Strachan
2005-07-06 16:24     ` Ingo Molnar [this message]
2005-07-06 16:37       ` Alistair John Strachan
2005-07-06 16:56         ` Alistair John Strachan
2005-07-06 17:01           ` Ingo Molnar
2005-07-06 17:14             ` Alistair John Strachan
2005-07-06 17:27               ` Ingo Molnar
2005-07-06 18:23                 ` Alistair John Strachan
2005-07-06 18:38                   ` Ingo Molnar
2005-07-06 18:41                     ` Ingo Molnar
2005-07-06 19:47                       ` Alistair John Strachan
2005-07-06 20:44                         ` Ingo Molnar
2005-07-06 21:00                           ` Alistair John Strachan
2005-07-06 21:02                             ` Ingo Molnar
2005-07-06 22:15                               ` Alistair John Strachan
2005-07-06 23:08                                 ` Fernando Lopez-Lezcano
2005-07-07  6:04                                   ` Michal Schmidt
2005-07-07 10:25                                     ` Ingo Molnar
2005-07-07  9:46                           ` Alistair John Strachan
2005-07-07 11:21                             ` Alistair John Strachan
2005-07-07 11:29                               ` Ingo Molnar
2005-07-07 11:37                                 ` Alistair John Strachan
2005-07-07 11:42                                   ` Ingo Molnar
2005-07-07 12:15                                     ` Alistair John Strachan
2005-07-07 12:29                                       ` Ingo Molnar
2005-07-07 13:38                                         ` Alistair John Strachan
2005-07-07 12:33                                       ` Alistair John Strachan
2005-07-08  9:47                                     ` Alistair John Strachan
2005-07-08 11:46                                       ` Ingo Molnar
2005-07-08 18:38                                         ` Alistair John Strachan
2005-07-08 19:12                                           ` USB storage does not work with 3GB of RAM, but does with 2G of RAM Jon Schindler
2005-07-08 19:25                                           ` Realtime Preemption, 2.6.12, Beginners Guide? Ingo Molnar
2005-07-08 19:31                                           ` Ingo Molnar
2005-07-08 19:34                                             ` Ingo Molnar
2005-07-08 19:48                                           ` Ingo Molnar
2005-07-08 19:55                                             ` Alistair John Strachan
2005-07-08 20:45                                             ` Alistair John Strachan
2005-07-09 11:58                                               ` Ingo Molnar
2005-07-09 14:07                                                 ` Alistair John Strachan
2005-07-09 14:55                                                   ` Ingo Molnar
2005-07-09 15:57                                                   ` Ingo Molnar
2005-07-09 16:02                                                     ` Ingo Molnar
2005-07-09 16:04                                                     ` Alistair John Strachan
2005-07-11 13:55                                                       ` Alistair John Strachan
2005-07-11 14:12                                                         ` Ingo Molnar
2005-07-11 14:16                                                           ` Ingo Molnar
2005-07-11 14:38                                                             ` Alistair John Strachan
2005-07-11 14:43                                                               ` Ingo Molnar
2005-07-11 15:50                                                                 ` Alistair John Strachan
2005-07-13 14:45                                                                   ` Ingo Molnar
2005-07-13 15:30                                                                     ` Ingo Molnar
2005-07-14 19:58                                                                       ` Alistair John Strachan
2005-07-14 20:16                                                                         ` Lee Revell
2005-07-15 22:12                                                                           ` Alistair John Strachan
2005-07-12  2:56                                                               ` Lee Revell
2005-07-11 15:07                                                             ` Ingo Molnar
2005-07-12 20:09                                                               ` Lee Revell
2005-07-12 21:01                                                                 ` Chuck Harding
2005-07-13 10:39                                                                   ` Ingo Molnar
2005-07-13 12:29                                                                     ` Gene Heskett
2005-07-13 14:01                                                                     ` K.R. Foley
2005-07-13 19:41                                                                       ` Chuck Harding
2005-07-13 19:45                                                                         ` Ingo Molnar
2005-07-14 13:39                                                                           ` K.R. Foley
2005-07-14 12:50                                                                       ` Karsten Wiese
2005-07-14 13:56                                                                         ` K.R. Foley
2005-07-14 14:10                                                                           ` K.R. Foley
2005-07-14 14:11                                                                             ` K.R. Foley
2005-07-14 19:49                                                                         ` Chuck Harding
2005-07-16 17:15                                                                         ` Ingo Molnar
2005-07-16 19:01                                                                           ` K.R. Foley
2005-07-17 12:07                                                                           ` Karsten Wiese
2005-07-18 15:46                                                                             ` K.R. Foley
2005-07-19 11:14                                                                             ` Karsten Wiese
2005-07-19 13:35                                                                               ` Gene Heskett
2005-07-19 13:57                                                                               ` Ingo Molnar
2005-07-19 15:19                                                                                 ` Gene Heskett
2005-07-19 23:00                                                                                   ` Karsten Wiese
2005-07-09 12:41                                               ` Ingo Molnar
2005-07-09 12:46                                                 ` Ingo Molnar
2005-07-09 13:05                                                 ` Ingo Molnar
2005-07-11 22:48                                                   ` William Weston
2005-07-12 13:53                                                     ` Ingo Molnar
2005-07-09 13:13                                                 ` Ingo Molnar
2005-07-09 13:26                                                 ` Ingo Molnar
2005-07-10 19:01                                                   ` PCMCIA stack reduction patch [Was: Re: Realtime Preemption, 2.6.12, Beginners Guide?] Dominik Brodowski
2005-07-09 13:36                                                 ` Realtime Preemption, 2.6.12, Beginners Guide? Ingo Molnar
2005-07-11 13:28                                                 ` Paulo Marques
2005-07-08 11:48                                       ` Ingo Molnar
2005-07-08 17:42                                         ` Alistair John Strachan
2005-07-08 17:48                                           ` Jakub Jelinek
2005-07-08 18:12                                             ` Alistair John Strachan
     [not found] <20050713063310.GA12661@elte.hu>
2005-07-13 10:30 ` karsten wiese
2005-07-13 18:38   ` Chuck Harding

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=20050706162457.GA24728@elte.hu \
    --to=mingo@elte.hu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=s0348365@sms.ed.ac.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).