Skip to contentSkip to conversation

context-switching overhead in X, ioport(), 2.6.8.1

PATCH Andi Kleen 3 participants 5 messages Aug 22, 2004 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Andi Kleen

author
#1 lore raw
Quoted 11 lines · Ingo Molnar

while debugging/improving scheduling latencies i got the following strange latency report from Lee Revell:

http://krustophenia.net/testresults.php?dataset=2.6.8.1-P6#/var/www/2.6.8.1-P6

this trace shows a 120 usec latency caused by XFree86, on a 600 MHz x86 system. Looking closer reveals:

00000002 0.006ms (+0.003ms): __switch_to (schedule) 00000002 0.088ms (+0.082ms): finish_task_switch (schedule)

Quoted 6 lines

it took more than 80 usecs for XFree86 to do a context-switch!

it turns out that the reason for this (massive) context-switching overhead is the following change in 2.6.8:

[PATCH] larger IO bitmaps

[...]

At least older XFree86 (4.2/3 time frame) used to only use iopl(). I know it because at some point ioperm() was completely broken on x86-64, but the X server never hit it. I wonder why they changed that. Anyways, perhaps it would be better to just change the X server back to use iopl(), because it will be always faster than using ioperm.

-Andi

#2 lore raw
Quoted 5 lines · Andi Kleen

At least older XFree86 (4.2/3 time frame) used to only use iopl(). I know it because at some point ioperm() was completely broken on x86-64, but the X server never hit it. I wonder why they changed that. Anyways, perhaps it would be better to just change the X server back to use iopl(), because it will be always faster than using

Xorg and XFree assume the kernel will have intelligent limits. When the range went up the EnableIO code in turn switched to ioperm.

The actual code is:

if (ioperm(0, 1024, 1) || iopl(3))
FatalError("xf86EnableIOPorts: Failed to set IOPL for
I/O\n")

(os-support/linux/lnx_video.c:xf86EnableIO)

Flip those around and rebuild.

author
#3 lore raw
Quoted 2 lines

Xorg and XFree assume the kernel will have intelligent limits. When the range went up the EnableIO code in turn switched to ioperm.

Which was the wrong thing to do since it is slower.

Quoted 10 lines

The actual code is:

if (ioperm(0, 1024, 1) || iopl(3))
FatalError("xf86EnableIOPorts: Failed to set IOPL for
I/O\n")

(os-support/linux/lnx_video.c:xf86EnableIO)

Flip those around and rebuild.

It would be better to do that in the official release.

-Andi

#4 lore raw
Quoted 11 lines · Andi Kleen
Quoted 9 lines

The actual code is:

if (ioperm(0, 1024, 1) || iopl(3))
FatalError("xf86EnableIOPorts: Failed to set IOPL for
I/O\n")

(os-support/linux/lnx_video.c:xf86EnableIO)

Flip those around and rebuild.

It would be better to do that in the official release.

The current release is in final code freeze so such a change would need the release wranglers agreement, I can't just go checking it into the tree.

#5 lore raw
In reply to Andi Kleen
Quoted 4 lines · Andi Kleen
Quoted 2 lines

Xorg and XFree assume the kernel will have intelligent limits. When the range went up the EnableIO code in turn switched to ioperm.

Which was the wrong thing to do since it is slower.

it is not significantly slower with older kernels or with the patch applied, and it's safer than an all-ports iopl(3).

Ingo