[RFT] Port 0x80 I/O speed
- From: Rene Herman <rene.herman@xxxxxxxxx>
- Date: Wed, 12 Dec 2007 00:31:18 +0100
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. /* 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;
}
- Follow-Ups:
- Re: [RFT] Port 0x80 I/O speed
- From: Bauke Jan Douma
- Re: [RFT] Port 0x80 I/O speed
- From: Jan Engelhardt
- Re: [RFT] Port 0x80 I/O speed
- From: Jesper Juhl
- Re: [RFT] Port 0x80 I/O speed
- From: SL Baur
- Re: [RFT] Port 0x80 I/O speed
- From: Török Edwin
- Re: [RFT] Port 0x80 I/O speed
- From: Cyrill Gorcunov
- Re: [RFT] Port 0x80 I/O speed
- From: Ondrej Zary
- [RFT] Port 0x80 I/O speed
- From: Olivér Pintér
- Re: [RFT] Port 0x80 I/O speed
- From: John Stoffel
- Re: [RFT] Port 0x80 I/O speed
- From: Romano Giannetti
- Re: [RFT] Port 0x80 I/O speed
- From: Ville Syrjälä
- Re: [RFT] Port 0x80 I/O speed
- From: Dave Haywood
- Re: [RFT] Port 0x80 I/O speed
- From: Peter Zijlstra
- Re: [RFT] Port 0x80 I/O speed
- From: Luciano Rocha
- Re: [RFT] Port 0x80 I/O speed
- From: Juergen Beisert
- Re: [RFT] Port 0x80 I/O speed
- From: Jiri Slaby
- Re: [RFT] Port 0x80 I/O speed
- From: Dave Young
- Re: [RFT] Port 0x80 I/O speed
- From: Paolo Ornati
- Re: [RFT] Port 0x80 I/O speed
- From: Kyle McMartin
- Re: [RFT] Port 0x80 I/O speed
- From: Mike Lampard
- Re: [RFT] Port 0x80 I/O speed
- From: Randy Dunlap
- Re: [RFT] Port 0x80 I/O speed
- From: Alistair John Strachan
- Re: [RFT] Port 0x80 I/O speed
- From: Nigel Cunningham
- Re: [RFT] Port 0x80 I/O speed
- From: Alejandro Riveira Fernández
- Re: [RFT] Port 0x80 I/O speed
- From: Maxim Levitsky
- Re: [RFT] Port 0x80 I/O speed
- Prev by Date: Re: [PATCH] [NET]: Fix Ooops of napi net_rx_action.
- Next by Date: Re: + e1000e-make-e1000e-default-to-the-same-kconfig-setting-as-e1000.patch added to -mm tree
- Previous by thread: [PATCH] Generic IRQ: Add unlocked version of set_irq_handler()
- Next by thread: Re: [RFT] Port 0x80 I/O speed
- Index(es):
Relevant Pages
|
|