Re: [patch 5/9] x86/ioport: Reduce ioperm impact for sane usage further

From: Linus Torvalds
Date: Thu Nov 07 2019 - 14:54:37 EST


On Thu, Nov 7, 2019 at 11:24 AM Brian Gerst <brgerst@xxxxxxxxx> wrote:
>
> Here is a different idea: We already map the TSS virtually in
> cpu_entry_area. Why not page-align the IO bitmap and remap it to the
> task's bitmap on task switch? That would avoid all copying on task
> switch.

We map the tss _once_, statically, percpu, without ever changing it,
and then we just (potentially) change a couple of fields in it on
process switch.

Your idea isn't horrible, but it would involve a TLB flush for the
page when the io bitmap changes. Which is almost certainly more
expensive than just copying the bitmap intelligently.

Particularly since I do think that the copy can basically be done
effectively never, assuming there really aren't multiple concurrent
users of ioperm() (and iopl).

Linus