Re: [RFT] Port 0x80 I/O speed



On Dec 12, 2007 7:31 AM, Rene Herman <rene.herman@xxxxxxxxx> wrote:
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;
}



dave@darkstar:~/work/tmp$ sudo ./port80
cycles: out 2522, in 1788
dave@darkstar:~/work/tmp$ sudo ./port80
cycles: out 2522, in 1795
dave@darkstar:~/work/tmp$ sudo ./port80
cycles: out 2523, in 1788
dave@darkstar:~/work/tmp$ sudo ./port80
cycles: out 2516, in 1788
dave@darkstar:~/work/tmp$ sudo ./port80
cycles: out 2516, in 1798
dave@darkstar:~/work/tmp$ sudo ./port80
cycles: out 2523, in 1788
dave@darkstar:~/work/tmp$ sudo ./port80
cycles: out 2518, in 1788
dave@darkstar:~/work/tmp$ sudo ./port80
cycles: out 2517, in 1788
dave@darkstar:~/work/tmp$ sudo ./port80
cycles: out 2523, in 1788
dave@darkstar:~/work/tmp$ sudo ./port80
cycles: out 2517, in 1788

dave@darkstar:~$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Pentium(R) D CPU 2.80GHz
stepping : 7
cpu MHz : 2793.194
cache size : 1024 KB
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • [RFT] Port 0x80 I/O speed
    ... It measures in CPU cycles so CPU speed is crucial in reporting. ... unsigned long long overhead; ... overhead = rdtsc() - start; ...
    (Linux-Kernel)
  • Re: Atmel releasing FLASH AVR32 ?
    ... A dual thread 40 MHz CPU can replace two 20 MHz CPUs. ... that a thread can only run max 1/2 or 1/3rd of the cycles ... switch at the start of the pipeline, ... equivalent to the interrupt latency. ...
    (comp.arch.embedded)
  • Re: Apple II Disk Drive Question
    ... derived from the Apple II CPU clock which runs at ... which will write one bit every four CPU cycles, ... adjusting the speed of the two drives to create the necessary ... know the rotation speed of both the writing and reading drives, ...
    (comp.sys.apple2)
  • Re: Apple II Disk Drive Question
    ... which will write one bit every four CPU cycles, ... disk is spinning. ... adjusting the speed of the two drives to create the necessary ...
    (comp.sys.apple2)
  • Re: interactive task starvation
    ... Where exactly are those extra cycles going I wonder? ... blows my mind though for reasons I've just said. ... in other processes which are starvating the CPU (eg: ... as no other workload has been identified. ...
    (Linux-Kernel)