netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: torvalds@linux-foundation.org
Cc: hpa@zytor.com, bhutchings@solarflare.com, tglx@linutronix.de,
	mingo@redhat.com, netdev@vger.kernel.org,
	linux-net-drivers@solarflare.com, x86@kernel.org
Subject: Re: [PATCH 2/3] x86_64: Define 128-bit memory-mapped I/O operations
Date: Wed, 22 Aug 2012 14:38:19 -0700 (PDT)	[thread overview]
Message-ID: <20120822.143819.1261952354301786625.davem@davemloft.net> (raw)
In-Reply-To: <CA+55aFxxSFMiohu80BZCObA0APPe08h1-7eAZ_BLoAZDWqqv0Q@mail.gmail.com>

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Wed, 22 Aug 2012 14:28:50 -0700

> On Wed, Aug 22, 2012 at 2:14 PM, David Miller <davem@davemloft.net> wrote:
>>
>> BTW, just to clarify, I'm not saying that we should save the FPU on
>> every trap where we find the FPU enabled or anything stupid like that.
>>
>> Definitely keep the kern_fpu_begin()/kern_fpu_end() type markers
>> around FPU usage, but allow some kind of nesting facility.
> 
> So nesting shouldn't be horrible, but the thing that really screws
> with people like the crypto use is not nesting, but the fact that
> sometimes you can't save at all, and the whole "kernel_fpu_possible()"
> or whatever we call the checking function.
> 
> IOW, in [soft]irq context, to avoid races with the irq happening as
> the process is going to do something with the FPU state, we don't
> allow saving and changing state, because that would mean that the
> normal FP state paths would have to be irq-safe, and they aren't.
> 
> And once you have to have that fpu possible check, if it happens to
> also disallow nested use, I doubt that's going to really affect
> anybody. The code has to take the case of "I'm not allowed to change
> FPU state" case into account regardless.

I don't think you really have to do anything special to handle
interrupts properly.

Let's assume that we use some variable length save area at the end of
thread_info to do this nested saving.

When you are asked for FPU usage, you first figure out how much you're
going to save.

Then you advance the allocation pointer in the thread_info, and save
into the space you allocated.

If an interrupt wants to use the FPU, that should be fine as well.
Whether the interrupt FPU save does it's save after you did, or
before, it should work out fine.

I suppose you might have some issues in determining whether we need to
do the full fxsave stuff or not.  There could be a state bit for that,
or similar.

Another idea, instead of doing this in thread_info, is to do it on the
local stack.  That way if we're in an interrupt, we'll use that
interrupt type's kernel stack.

You might be able to get away with always doing the full FPU
save/restore in that situation.

  reply	other threads:[~2012-08-22 21:38 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-22  1:17 [PATCH 0/3] x86_64, sfc: 128-bit memory-mapped I/O Ben Hutchings
2012-08-22  1:20 ` [PATCH 1/3] x86_64: Define 128-bit types for kernel code only Ben Hutchings
2012-08-22  1:23 ` [PATCH 2/3] x86_64: Define 128-bit memory-mapped I/O operations Ben Hutchings
2012-08-22  1:37   ` H. Peter Anvin
2012-08-22  2:04     ` Ben Hutchings
2012-08-22  2:34       ` David Miller
2012-08-22  3:24         ` H. Peter Anvin
2012-08-22  3:29           ` David Miller
2012-08-22  3:49             ` H. Peter Anvin
2012-08-22  3:52           ` Linus Torvalds
2012-08-22  3:59             ` H. Peter Anvin
2012-08-22  4:14               ` David Miller
2012-08-22 21:14                 ` David Miller
2012-08-22 21:28                   ` Linus Torvalds
2012-08-22 21:38                     ` David Miller [this message]
2012-08-22  4:35               ` Linus Torvalds
2012-08-22  5:00                 ` David Miller
2012-08-22 14:06                   ` Linus Torvalds
2012-08-22  4:42             ` Linus Torvalds
2012-08-22 13:26             ` Ben Hutchings
2012-08-22 14:20               ` Linus Torvalds
2012-08-22 14:24                 ` Ben Hutchings
2012-08-22 14:30                   ` Benjamin LaHaise
2012-08-22 14:58                     ` Ben Hutchings
2012-08-22 15:13                       ` H. Peter Anvin
2012-08-22 15:27                         ` David Laight
2012-08-22 15:49                           ` H. Peter Anvin
2012-08-22 15:51                           ` Ben Hutchings
2012-08-22 15:54                             ` H. Peter Anvin
2012-08-22 16:44                               ` Ben Hutchings
2012-08-22 16:49                                 ` H. Peter Anvin
2012-08-22 16:55                                 ` Linus Torvalds
2012-08-22 17:09                                   ` Ben Hutchings
2012-08-22 17:12                                     ` H. Peter Anvin
2012-08-22 17:27                                       ` Ben Hutchings
2012-08-22 17:54                                         ` Linus Torvalds
2012-08-22 18:11                                           ` Ben Hutchings
2012-08-22 18:18                                             ` H. Peter Anvin
2012-08-22 18:28                                             ` Linus Torvalds
2012-08-22 19:01                                               ` Ben Hutchings
2012-08-22 17:26                                     ` Linus Torvalds
2012-08-22 16:51                               ` Linus Torvalds
2012-08-22 16:59                                 ` H. Peter Anvin
2012-08-22 15:51                           ` H. Peter Anvin
2012-08-22 14:50                   ` Linus Torvalds
2012-08-22 14:56                     ` Linus Torvalds
2012-08-22 15:05                       ` David Laight
2012-08-22 15:16                         ` Linus Torvalds
2012-08-22 15:41                     ` Ben Hutchings
2012-08-22 14:42                 ` David Laight
2012-08-22  1:26 ` [PATCH 3/3] sfc: Use __raw_writeo() to perform TX descriptor push where possible Ben Hutchings
2012-08-22  1:38 ` [PATCH 0/3] x86_64, sfc: 128-bit memory-mapped I/O H. Peter Anvin
2012-08-22  1:43   ` Ben Hutchings
2012-08-22  1:59     ` H. Peter Anvin
2012-08-22  2:10       ` Ben Hutchings
2012-08-22  2:31         ` H. Peter Anvin

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=20120822.143819.1261952354301786625.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=bhutchings@solarflare.com \
    --cc=hpa@zytor.com \
    --cc=linux-net-drivers@solarflare.com \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@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;
as well as URLs for NNTP newsgroup(s).