Re: [patch] context-switching overhead in X, ioport(), 2.6.8.1

From: Ryan Cumming
Date: Sun Aug 22 2004 - 00:43:36 EST


On Saturday 21 August 2004 21:46, David S. Miller wrote:
> FWIW, I would recommend a sparse bitmap implementation for the
> ioport stuff.

The problem is that the sparse bitmap would have to be unpacked to the "dense"
bitmap that lives in the TSS on context switch. AFAICS, that would involve
walking the previous task's spare bitmap, clearing all the ports it had
access to, and then walking the next task's sparse bitmap and opening access
to its ports. I doubt this would be a big win over what Ingo says usually
reduces to a 128 byte or less memcpy(), especially when you consider the
added complexity.

The only big speedup I can see is in the case of only one task having anything
set in its IO bitmap at all. I assume that most desktops running a single X
server fall in to this degenerate case, please correct me if I'm wrong. There
we could simply set the TSS's io_bitmap_base to IO_BITMAP_OFFSET when
switching to the IO bitmap'ed task, and set it back to
INVALID_IO_BITMAP_OFFSET when we context switch away. That way the entire
thing is accomplished with a single 4-byte store per context switch until a
second IO bitmap'ed app is started, in which case we'd have to fall back to
memcpy()ing. Seems like too much complexity for what amounts to a
microoptimization, though.

BTW Ingo, have you looked at changing the almost identical code in
arch/x86-64? Or did it not get its bitmap expanded?

-Ryan

Attachment: pgp00000.pgp
Description: PGP signature