mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Davide Libenzi <davidel@xmailserver.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: Andi Kleen <ak@suse.de>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@osdl.org>, Linus Torvalds <torvalds@osdl.org>
Subject: Re: [patch] ioport-cache-2.6.8.1.patch
Date: Tue, 24 Aug 2004 08:15:50 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.58.0408240754140.4132@bigblue.dev.mdolabs.com> (raw)
In-Reply-To: <20040824071928.GA7697@elte.hu>

On Tue, 24 Aug 2004, Ingo Molnar wrote:

> another issue is that this code doesnt solve the 64K ports issue: even
> with a perfect decoder ioperm() apps still see a ~80 usecs copying
> latency (plus related cache trash effects) upon the first GPF - either
> IO related or not. I dont think coupling this into the GPF handler is
> all that good.

So, correct me if I'm wrong, you want this price to be paid at *every* 
context switch, isn't it? Independently from the fact that the task does 
or does not I/O operations.



> since 100% of Linux ioperm() apps currently use 1024 ports or less, i'd
> prefer the 128 bytes (one cacheline on a P4) copy over any asynchronous
> solution. (if someone wants more ports the price goes up. It should be
> rare. I dont think X will ever go above 1024 ports.) We've already had
> one security exploit in the lazy IO bitmap code, which further underlies
> how dangerous such asynchronity is.

It was in the lazy FPU code ;) and this patch is utterly simple and sets 
the most restrictive policy, by later verifying in the GPF code. It does 
not leave stale bitmaps from previous tasks in search of optimizations.



> there's yet another danger: apps that _do_ use IO ports frequently will
> see the most serious overhead via the GPF solution. They will most
> likely switch to iopl(3) - which is an even less safe API than ioperm()
> - so robustness suffers. So i think it's wrong policy too. Sorry :-|

Apps that do use I/O a lot will likely issue more than one I/O per context 
switch, and the cost of even one I/O op will be greater than the GPF cost. 
This w/out even accounting the cost saved on context switches where no I/O 
is done. Talking about X for example, yesterday test (that I should better 
confirm today) revealed that more than 60% of context switches do *not* 
trigger the GPF fault, that is, for in 60+% of context switches X does not 
use I/O operations. This is not a surprise given the way the X server works.



> but there's one additional step we can do ontop of the ports-max code to
> get rid of copying in X.org's case: cache the last task that set up the
> IO bitmap. This means we can set the offset to invalid and keep the IO
> bitmap of that task, and switch back to a valid offset (without any
> copying) when switching back to that task. (or do a copy if there is
> another ioperm task we switch to.)

Personally Ingo, I do not like logics like:

if (io_apps <= 1) pretty_good(); then screwed();

But that's just a matter of personal taste. Anyway, today I'll recode with 
Brian get/put_cpu suggestion and on top of var-bitmap bits, and I'll 
repost. Then if you guys like it you take it, otherwise we keep the 
current memcpy/memset on switch_to.



- Davide


  reply	other threads:[~2004-08-24 15:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-23 21:23 [patch] lazy TSS's I/O bitmap copy Davide Libenzi
2004-08-23 21:32 ` Andi Kleen
2004-08-23 21:39   ` Davide Libenzi
2004-08-23 22:07     ` Linus Torvalds
2004-08-23 22:18       ` Davide Libenzi
2004-08-23 22:27         ` Linus Torvalds
2004-08-28 19:15         ` Alan Cox
2004-08-23 22:54       ` Davide Libenzi
2004-08-23 23:09         ` Linus Torvalds
2004-08-23 23:33           ` Davide Libenzi
2004-08-24  7:19     ` [patch] ioport-cache-2.6.8.1.patch Ingo Molnar
2004-08-24 15:15       ` Davide Libenzi [this message]
2004-08-24 19:38       ` Ryan Cumming
2004-08-24 20:20         ` Ingo Molnar
2004-08-24  1:53 ` [patch] lazy TSS's I/O bitmap copy Brian Gerst
2004-08-24  2:17   ` Linus Torvalds
2004-08-24  4:30   ` Davide Libenzi
2004-08-24  6:51 ` Arjan van de Ven
2004-08-24 15:13   ` Davide Libenzi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.58.0408240754140.4132@bigblue.dev.mdolabs.com \
    --to=davidel@xmailserver.org \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®