linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFT] Port 0x80 I/O speed
@ 2007-12-11 23:31 Rene Herman
  2007-12-11 23:40 ` Maxim Levitsky
                   ` (24 more replies)
  0 siblings, 25 replies; 68+ messages in thread
From: Rene Herman @ 2007-12-11 23:31 UTC (permalink / raw)
  To: Linux Kernel
  Cc: dpreed, Alan Cox, pavel, andi, rol, Krzysztof Halasa, david, hpa,
	john, linux-os

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

Good day.

Would some people on x86 (both 32 and 64) be kind enough to compile and run 
the attached program? This is about testing how long I/O port access to port 
0x80 takes. It measures in CPU cycles so CPU speed is crucial in reporting.

Posted a previous incarnation of this before, buried in the outb 0x80 thread 
which had a serialising problem. This one should as far as I can see measure 
the right thing though. Please yell if you disagree...

For me, on a Duron 1300 (AMD756 chipset) I have a constant:

rene@7ixe4:~/src/port80$ su -c ./port80
cycles: out 2400, in 2400

and on a PII 400 (Intel 440BX chipset) a constant:

rene@6bap:~/src/port80$ su -c ./port80
cycles: out 553, in 251

Results are (mostly) independent of compiler optimisation, but testing with 
an -O2 compile should be most useful. Thanks!

Rene.

[-- Attachment #2: port80.c --]
[-- Type: text/plain, Size: 1138 bytes --]

/* gcc -W -Wall -O2 -o port80 port80.c */

#include <stdlib.h>
#include <stdio.h>

#include <sys/io.h>

#define LOOPS 10000

inline unsigned long long rdtsc(void)
{
	unsigned long long tsc;

	asm volatile ("rdtsc": "=A" (tsc));

	return tsc;
}

inline void serialize(void)
{
	asm volatile ("cpuid": : : "eax", "ebx", "ecx", "edx");
}

int main(void)
{
	unsigned long long start;
	unsigned long long overhead; 
	unsigned long long output;
	unsigned long long input;
	int i;

	if (iopl(3) < 0) {
		perror("iopl");
		return EXIT_FAILURE;
	}

	asm volatile ("cli");
	start = rdtsc();
	for (i = 0; i < LOOPS; i++) {
	 	serialize();	
		serialize();
	}
	overhead = rdtsc() - start;

	start = rdtsc() + overhead;
	for (i = 0; i < LOOPS; i++) {
		serialize();
		asm volatile ("outb %al, $0x80");
		serialize();
	}
	output = rdtsc() - start;

	start = rdtsc() + overhead;
	for (i = 0; i < LOOPS; i++) {
		serialize();
		asm volatile ("inb $0x80, %%al": : : "al");
		serialize();
	}
	input = rdtsc() - start;
	asm volatile ("sti");

	output /= LOOPS;
	input  /= LOOPS;
	printf("cycles: out %llu, in %llu\n", output, input);

	return EXIT_SUCCESS;
}

^ permalink raw reply	[flat|nested] 68+ messages in thread
* Re: [RFT] Port 0x80 I/O speed
@ 2007-12-12  5:06 Chris Holvenstot
  0 siblings, 0 replies; 68+ messages in thread
From: Chris Holvenstot @ 2007-12-12  5:06 UTC (permalink / raw)
  To: Kernel


cycles: out 1296, in 1243
cycles: out 1312, in 1245
cycles: out 1289, in 1239
cycles: out 1309, in 1245
cycles: out 1308, in 1244
cycles: out 1325, in 1239
cycles: out 1310, in 1245
cycles: out 1289, in 1239
cycles: out 1301, in 1252
cycles: out 1325, in 1249
cycles: out 1307, in 1249
cycles: out 1304, in 1247

AMD 64 X2 4600 + / 2 gig memory - running the 32 bit version of
2.6.24-rc5-git1

>From /proc/cpuinfo

processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 43
model name      : AMD Athlon(tm) 64 X2 Dual Core Processor 4600+
stepping        : 1
cpu MHz         : 2412.378
cache size      : 512 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 2
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
mca cmov
pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt lm
3dnowext 3d
now pni lahf_lm cmp_legacy ts fid vid ttp
bogomips        : 4827.69
clflush size    : 64




^ permalink raw reply	[flat|nested] 68+ messages in thread
* Re: [RFT] Port 0x80 I/O speed
@ 2007-12-12 11:20 linux
  2007-12-12 12:35 ` Paolo Ornati
  2007-12-12 14:48 ` Rene Herman
  0 siblings, 2 replies; 68+ messages in thread
From: linux @ 2007-12-12 11:20 UTC (permalink / raw)
  To: linux-kernel, rene.herman; +Cc: linux

Here are a variety of machines:

600 MHz PIII (Katmai), 440BX chipset, 82371AB/EB/MB PIIX4 ISA bridge:
cycles: out 794, in 348
cycles: out 791, in 348
cycles: out 791, in 349
cycles: out 791, in 348
cycles: out 791, in 348

433 MHz Celeron (Mendocino), 440 BX chipset, same ISA bridge:
cycles: out 624, in 297
cycles: out 623, in 296
cycles: out 624, in 297
cycles: out 623, in 297
cycles: out 623, in 296

1100 MHz Athlon, nForce2 chipset, nForce2 ISA bridge:
cycles: out 1295, in 1162
cycles: out 1295, in 1162
cycles: out 1295, in 1162
cycles: out 1295, in 1162
cycles: out 1295, in 1162

800 MHz Transmeta Crusoe TM5800, Transmeta/ALi M7101 chipset.
cycles: out 1212, in 388
cycles: out 1195, in 375
cycles: out 1197, in 377
cycles: out 1196, in 376
cycles: out 1196, in 377

2200 MHz Athlon 64, K8T890 chipset, VT8237 ISA bridge:
cycles: out 1844674407370814, in 1844674407365758
cycles: out 1844674407370813, in 1844674407365756
cycles: out 1844674407370805, in 1844674407365750
cycles: out 1844674407370813, in 1844674407365755
cycles: out 1844674407370814, in 1844674407365756

Um, huh?  That's gcc 4.2.3 (Debian version 4.2.2-4), -O2.  Very odd.

I can run it with -O0:
cycles: out 4894, in 4894
cycles: out 4905, in 4917
cycles: out 4910, in 4896
cycles: out 4909, in 4896
cycles: out 4894, in 4898
cycles: out 4911, in 4898

or with -O2 -m32:
cycles: out 4914, in 4927
cycles: out 4913, in 4927
cycles: out 4913, in 4913
cycles: out 4914, in 4913
cycles: out 4913, in 4929
cycles: out 4912, in 4912
cycles: out 4913, in 4915

With -O2, the cycle counts come out (before division) as
out: 0xFFFFFFFFFFEA6F4F
in:  0xFFFFFFFFFCE68BB6
I think the "A" constraint doesn't work quite the same in
64-bit code.  The compiler seems to be using %rdx rather than
%edx:%eax.

^ permalink raw reply	[flat|nested] 68+ messages in thread
[parent not found: <9zmRR-3pA-25@gated-at.bofh.it>]
[parent not found: <9A0cz-7xy-13@gated-at.bofh.it>]

end of thread, other threads:[~2007-12-22 22:27 UTC | newest]

Thread overview: 68+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-11 23:31 [RFT] Port 0x80 I/O speed Rene Herman
2007-12-11 23:40 ` Maxim Levitsky
2007-12-11 23:44   ` Rene Herman
2007-12-12  0:14     ` Maxim Levitsky
2007-12-12  0:27       ` Rene Herman
2007-12-11 23:43 ` Alejandro Riveira Fernández
2007-12-11 23:51   ` Rene Herman
2007-12-12  0:09     ` Alejandro Riveira Fernández
2007-12-12  0:16       ` Rene Herman
2007-12-12 11:43         ` Alejandro Riveira Fernández
2007-12-12 21:02         ` H. Peter Anvin
     [not found]   ` <Pine.LNX.4.61.0712120753210.4443@chaos.analogic.com>
2007-12-12 13:20     ` Rene Herman
2007-12-12 13:23       ` linux-os (Dick Johnson)
2007-12-11 23:55 ` Nigel Cunningham
2007-12-12  0:01   ` Rene Herman
2007-12-12  2:07     ` Nigel Cunningham
2007-12-12  1:19 ` Alistair John Strachan
2007-12-12  1:28 ` Randy Dunlap
2007-12-12  1:40 ` Mike Lampard
2007-12-12  5:23 ` Kyle McMartin
2007-12-12  7:18   ` Rene Herman
2007-12-13  2:41     ` H. Peter Anvin
2007-12-12 19:25   ` H. Peter Anvin
2007-12-12 19:32     ` Andi Kleen
2007-12-12 19:43       ` H. Peter Anvin
2007-12-12  8:17 ` Paolo Ornati
2007-12-12  8:38   ` Edwin de Caluwé
2007-12-12  8:35 ` Dave Young
2007-12-12  8:48 ` Jiri Slaby
2007-12-12 11:25   ` Jiri Slaby
2007-12-12 15:50     ` Rene Herman
2007-12-12 15:53     ` Rene Herman
2007-12-12 18:44     ` H. Peter Anvin
2007-12-12 19:19       ` Rene Herman
2007-12-13 15:19         ` Jiri Slaby
2007-12-12  8:59 ` Juergen Beisert
2007-12-12 14:30   ` Rene Herman
2007-12-12 15:12     ` Juergen Beisert
2007-12-12  9:55 ` Luciano Rocha
2007-12-12  9:57 ` Romano Giannetti
2007-12-12 16:27   ` Rene Herman
2007-12-12 10:28 ` Peter Zijlstra
2007-12-12 10:34 ` Dave Haywood
2007-12-12 11:57 ` Ville Syrjälä
2007-12-13 16:42   ` Ville Syrjälä
2007-12-12 16:16 ` John Stoffel
2007-12-12 16:39 ` Olivér Pintér
2007-12-12 16:53 ` Ondrej Zary
2007-12-12 17:00   ` H. Peter Anvin
2007-12-12 16:59 ` Cyrill Gorcunov
2007-12-12 17:27 ` Török Edwin
2007-12-12 18:54   ` David P. Reed
2007-12-12 18:39 ` SL Baur
2007-12-12 19:06   ` Rene Herman
2007-12-12 21:32 ` Jesper Juhl
2007-12-12 23:54 ` Jan Engelhardt
2007-12-13  0:13   ` Jan Engelhardt
2007-12-13  2:06   ` H. Peter Anvin
2007-12-22 22:27 ` Bauke Jan Douma
2007-12-12  5:06 Chris Holvenstot
2007-12-12 11:20 linux
2007-12-12 12:35 ` Paolo Ornati
2007-12-12 14:48 ` Rene Herman
     [not found] <9zmRR-3pA-25@gated-at.bofh.it>
2007-12-13 16:27 ` James Kosin
2007-12-13 22:07   ` Rene Herman
2007-12-13 22:30     ` Jesper Juhl
2007-12-13 22:37       ` Rene Herman
     [not found] <9A0cz-7xy-13@gated-at.bofh.it>
     [not found] ` <9A0cz-7xy-11@gated-at.bofh.it>
     [not found]   ` <9A4pU-69z-15@gated-at.bofh.it>
2007-12-14 14:08     ` James Kosin

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).