mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: john stultz <johnstul@us.ibm.com>
To: Thomas Schlichter <schlicht@uni-mannheim.de>
Cc: "Prakash K. Cheemplavam" <prakashpublic@gmx.de>,
	"Ronny V. Vindenes" <s864@ii.uib.no>,
	Andrew Morton <akpm@osdl.org>,
	lkml <linux-kernel@vger.kernel.org>,
	cat@zip.com.au, gawain@freda.homelinux.org,
	gene.heskett@verizon.net, papadako@csd.uoc.gr
Subject: Re: Terrible interactivity with 2.6.0-t9-mm3
Date: 17 Nov 2003 13:27:21 -0800	[thread overview]
Message-ID: <1069104441.11424.1979.camel@cog.beaverton.ibm.com> (raw)
In-Reply-To: <200311172046.17736.schlicht@uni-mannheim.de>

On Mon, 2003-11-17 at 11:46, Thomas Schlichter wrote:
> On Monday 17 November 2003 14:12, Prakash K. Cheemplavam wrote:
> > Ronny V. Vindenes wrote:
> > > I've found that neither linus.patch nor
> > > context-switch-accounting-fix.patch is causing the problem, but rather
> > > acpi-pm-timer-fixes.patch & acpi-pm-timer.patch
> > >
> > > With these applied my cpu (athlon64) is detected as 0.0Mhz, bogomips
> > > drops to 50% and anything cpu intensive destroys interactivity. Revert
> > > them and performance is back at -mm2 level.
> >
> > Yup, works for me too. Reverting those patches and my machine is smooth
> > again. :)

Not configuring the ACPI PM time source in should also work as well. 

> I was able to reproduce the interactivity problem, too. My simple testcase 
> was:
> 1. open a KDE Konsole
> 2. execute "while true; do a=2; done" in the Konsole
> 3. Move the Konsole window.
> 
> With test9-mm3 booted with "clock=pit" or "clock=pmtmr" moving the window was 
> very sluggish... Booted with "clock=tsc" made it work fine again. (Btw. which 
> kind of hardware is needed to make "clock=hpet" work?)
> 
> The problem is that sched_clock() uses the TSC if the hardware supports it. 
> But the needed scaling factors are only initialized in init_tsc() and 
> init_hpet(). So there are 2 possibilities to fix this:
> 1. Call the neccessary parts of init_tsc() in init_pmtmr() and init_pit().
> 2. Use the TSC in sched_clock() only if "clock=tsc" was set.


As far as sched_clock() goes, I haven't followed its development
closely, but it seem that it is very close to monotonic_clock() in
functionality. The benefit of monotonic_clock is that it is implemented
for each time source (however its not implemented for every arch). For
i386 at least, we may want to make sched_clock just call
monotonic_clock, but I need to look into the details. 


> I've attached a small patch that does the 2nd thing. For me it fixed the 
> interactivity problem...

That tentatively looks OK to me, but I suspect that sched_clock needs
further work on i386. 


> Btw. the BogoMIPS value is the argument for the __delay() function needed to 
> wait 1 jiffy. The difference is that the TSC version of this function uses 
> the clock cycle count as its argument whereas the PMTMR and PIT versions take 
> the count of loops to wait as their argument. Well, and it seems that each 
> loop iteration needs 2 clock cycles.

__delay() is called with loops as an argument. calibrate_delay() sets
loops_per_jiffy such that mdelay() and udelay() will delay for the
proper amount of time. BogoMIPS may not line up w/ your cpu frequency,
but don't let that worry you. 


> The problem with the shown CPU frequency is, that cpu_khz is only set in 
> init_tsc() and init_hpet(). But I don't know how this can be fixed without 
> using the TSC...

You're correct, I forgot to initialize cpu_khz in the ACPI PM timesource
init code. This patch fixes that. 

thanks for the great testing and feedback!
-john

diff -Nru a/arch/i386/kernel/timers/common.c b/arch/i386/kernel/timers/common.c
--- a/arch/i386/kernel/timers/common.c	Mon Nov 17 13:23:43 2003
+++ b/arch/i386/kernel/timers/common.c	Mon Nov 17 13:23:43 2003
@@ -137,3 +137,23 @@
 }
 #endif
 
+/* calculate cpu_khz */
+void __init init_cpu_khz(void)
+{
+	if (cpu_has_tsc) {
+		unsigned long tsc_quotient = calibrate_tsc();
+		if (tsc_quotient) {
+			/* report CPU clock rate in Hz.
+			 * The formula is (10^6 * 2^32) / (2^32 * 1 / (clocks/us)) =
+			 * clock/second. Our precision is about 100 ppm.
+			 */
+			{	unsigned long eax=0, edx=1000;
+				__asm__("divl %2"
+		       		:"=a" (cpu_khz), "=d" (edx)
+        	       		:"r" (tsc_quotient),
+	                	"0" (eax), "1" (edx));
+				printk("Detected %lu.%03lu MHz processor.\n", cpu_khz / 1000, cpu_khz % 1000);
+			}
+		}
+	}
+}
diff -Nru a/arch/i386/kernel/timers/timer_cyclone.c b/arch/i386/kernel/timers/timer_cyclone.c
--- a/arch/i386/kernel/timers/timer_cyclone.c	Mon Nov 17 13:23:43 2003
+++ b/arch/i386/kernel/timers/timer_cyclone.c	Mon Nov 17 13:23:43 2003
@@ -212,27 +212,8 @@
 		}
 	}
 
-	/* init cpu_khz.
-	 * XXX - This should really be done elsewhere, 
-	 * 		and in a more generic fashion. -johnstul@us.ibm.com
-	 */
-	if (cpu_has_tsc) {
-		unsigned long tsc_quotient = calibrate_tsc();
-		if (tsc_quotient) {
-			/* report CPU clock rate in Hz.
-			 * The formula is (10^6 * 2^32) / (2^32 * 1 / (clocks/us)) =
-			 * clock/second. Our precision is about 100 ppm.
-			 */
-			{	unsigned long eax=0, edx=1000;
-				__asm__("divl %2"
-		       		:"=a" (cpu_khz), "=d" (edx)
-        	       		:"r" (tsc_quotient),
-	                	"0" (eax), "1" (edx));
-				printk("Detected %lu.%03lu MHz processor.\n", cpu_khz / 1000, cpu_khz % 1000);
-			}
-		}
-	}
-
+	init_cpu_khz();
+	
 	/* Everything looks good! */
 	return 0;
 }
diff -Nru a/arch/i386/kernel/timers/timer_pm.c b/arch/i386/kernel/timers/timer_pm.c
--- a/arch/i386/kernel/timers/timer_pm.c	Mon Nov 17 13:23:43 2003
+++ b/arch/i386/kernel/timers/timer_pm.c	Mon Nov 17 13:23:43 2003
@@ -57,14 +57,18 @@
 		if (value2 == value1) 
 			continue;
 		if (value2 > value1)
-			return 0;
+			goto pm_good;
 		if ((value2 < value1) && ((value2) < 0xFFF))
-			return 0;
+			goto pm_good;
 		printk(KERN_INFO "PM-Timer had inconsistent results: 0x%#x, 0x%#x - aborting.\n", value1, value2);
 		return -EINVAL;
 	}
 	printk(KERN_INFO "PM-Timer had no reasonable result: 0x%#x - aborting.\n", value1);
 	return -ENODEV;
+
+pm_good:
+	init_cpu_khz();
+	return 0;
 }
 
 static inline u32 cyc2us(u32 cycles)
diff -Nru a/include/asm-i386/timer.h b/include/asm-i386/timer.h
--- a/include/asm-i386/timer.h	Mon Nov 17 13:23:43 2003
+++ b/include/asm-i386/timer.h	Mon Nov 17 13:23:43 2003
@@ -39,6 +39,7 @@
 #endif
 
 extern unsigned long calibrate_tsc(void);
+extern void init_cpu_khz(void);
 #ifdef CONFIG_HPET_TIMER
 extern struct timer_opts timer_hpet;
 extern unsigned long calibrate_tsc_hpet(unsigned long *tsc_hpet_quotient_ptr);




  reply	other threads:[~2003-11-17 21:32 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-17 12:11 Ronny V. Vindenes
2003-11-17 13:12 ` Prakash K. Cheemplavam
2003-11-17 19:46   ` Thomas Schlichter
2003-11-17 21:27     ` john stultz [this message]
2003-11-17 22:44       ` john stultz
2003-11-17 22:51       ` Prakash K. Cheemplavam
2003-11-17 22:55         ` john stultz
2003-11-17 23:04           ` john stultz
2003-11-17 23:46             ` Thomas Schlichter
2003-11-18 22:59               ` linux-2.6.0-test9-mm3_acpi-pm-monotonic-fix_A0 john stultz
2003-11-19  7:34                 ` linux-2.6.0-test9-mm3_acpi-pm-monotonic-fix_A0 Thomas Schlichter
2003-11-18 13:24             ` Terrible interactivity with 2.6.0-t9-mm3 Prakash K. Cheemplavam
2003-11-18 16:11               ` Prakash K. Cheemplavam
2003-11-18 18:28                 ` john stultz
2003-11-18 16:15               ` Prakash K. Cheemplavam
2003-11-17 13:15 ` Felipe Alfaro Solana
2003-11-17 19:36 ` Andrew Morton
2003-11-17 19:35   ` john stultz
2003-11-18 18:56     ` Dominik Brodowski
2003-11-18 19:18       ` john stultz
  -- strict thread matches above, loose matches on Subject: below --
2003-11-16 19:26 CaT
2003-11-16 20:24 ` Prakash K. Cheemplavam
2003-11-16 21:42   ` Andrew Morton
2003-11-16 22:06     ` Arnaldo Carvalho de Melo
2003-11-16 22:13       ` Andrew Morton
2003-11-16 22:18         ` CaT
2003-11-17  0:16     ` Panagiotis Papadakos
2003-11-17  2:20     ` Gawain Lynch
2003-11-17  2:49       ` Andrew Morton
2003-11-17  3:11         ` Gawain Lynch
2003-11-17  3:54         ` Gene Heskett
2003-11-17  4:19           ` Nick Piggin
2003-11-17  4:47             ` Gene Heskett
2003-11-17  5:17               ` Nick Piggin

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=1069104441.11424.1979.camel@cog.beaverton.ibm.com \
    --to=johnstul@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=cat@zip.com.au \
    --cc=gawain@freda.homelinux.org \
    --cc=gene.heskett@verizon.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=papadako@csd.uoc.gr \
    --cc=prakashpublic@gmx.de \
    --cc=s864@ii.uib.no \
    --cc=schlicht@uni-mannheim.de \
    /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

all inboxes | Powered by JetHome®