public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: David Mosberger <davidm@napali.hpl.hp.com>
To: linux-ia64@vger.kernel.org
Subject: Re: [Linux-ia64] avoid exceptions in copy_from_user?
Date: Fri, 02 May 2003 07:13:12 +0000	[thread overview]
Message-ID: <marc-linux-ia64-105590723705629@msgid-missing> (raw)
In-Reply-To: <marc-linux-ia64-105590723705628@msgid-missing>

>>>>> On Fri, 2 May 2003 16:43:37 +1000, Martin Pool <mbp@samba.org> said:

  Martin> This is probably a flawed idea but I was just curious: could
  Martin> the kernel use speculative loads to avoid taking exceptions
  Martin> when a copy_from_user or related function faults?
  Martin> (Something like the routine below.)

You're right, it's flawed. ;-)

First problem: why optimize the _exceptional_ case?  Show me one
application which suffers from the cost of the exception handling and
I'll buy you a beer (or two or three).  OTOH, almost every application
benefits from optimizing the common case of exception-free execution.

Second (and perhaps more important) problem: kernel code must not
assume that a speculative load fails only if the load cannot possibly
execute successfully (in ia64 lingo, this is called the "recovery"
model, as opposed to the "no-recovery" model, which I'm not a fan of).
For example, depending on the DCR settings, a speculative load may
also fail on a TLB miss.  Of course, you don't want the code to fail
just because of a TLB miss.

  Martin> I suspect the answer is that it's not worthwhile, because if
  Martin> the copy fails then the kernel is about to go and do
  Martin> something expensive like paging or killing the task, and so
  Martin> a little more overhead is not important, and anyhow adding
  Martin> instructions to the non-failing case is undesirable.

Yup.

My experience so far is that speculative loads are best left to the
compiler.  Human beings are just not very good at writing recovery
code and keeping it in sync with the main code (e.g., we had some
painful experiences with the strncpy() routine).

	--david


      reply	other threads:[~2003-05-02  7:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-02  6:43 [Linux-ia64] avoid exceptions in copy_from_user? Martin Pool
2003-05-02  7:13 ` David Mosberger [this message]

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=marc-linux-ia64-105590723705629@msgid-missing \
    --to=davidm@napali.hpl.hp.com \
    --cc=linux-ia64@vger.kernel.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