All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Lutomirski <luto@kernel.org>
To: David Laight <David.Laight@aculab.com>
Cc: Andy Lutomirski <luto@kernel.org>, Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"torvalds@linux-foundation.org" <torvalds@linux-foundation.org>,
	"ganeshgr@chelsio.com" <ganeshgr@chelsio.com>,
	"nirranjan@chelsio.com" <nirranjan@chelsio.com>,
	"indranil@chelsio.com" <indranil@chelsio.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Fenghua Yu <fenghua.yu@intel.com>,
	Eric Biggers <ebiggers3@gmail.com>,
	Rik van Riel <riel@redhat.com>
Subject: Re: [RFC PATCH 0/3] kernel: add support for 256-bit IO access
Date: Wed, 21 Mar 2018 00:39:53 +0000	[thread overview]
Message-ID: <CALCETrV8d5HD2q_qmiRfs-vB=JkiDm3yDx-5KcYqu7yEQrdu0A@mail.gmail.com> (raw)
In-Reply-To: <c1eac43cd8e143d09477a34ed6de6302@AcuMS.aculab.com>

On Tue, Mar 20, 2018 at 3:10 PM, David Laight <David.Laight@aculab.com> wrote:
> From: Andy Lutomirski
>> Sent: 20 March 2018 14:57
> ...
>> I'd rather see us finally finish the work that Rik started to rework
>> this differently.  I'd like kernel_fpu_begin() to look like:
>>
>> if (test_thread_flag(TIF_NEED_FPU_RESTORE)) {
>>   return; // we're already okay.  maybe we need to check
>> in_interrupt() or something, though?
>> } else {
>>   XSAVES/XSAVEOPT/XSAVE;
>>   set_thread_flag(TIF_NEED_FPU_RESTORE):
>> }
>>
>> and kernel_fpu_end() does nothing at all.
>
> I guess it might need to set (clear?) the CFLAGS bit for a process
> that isn't using the fpu at all - which seems a sensible feature.

What do you mean "CFLAGS"?

But we no longer have any concept of "isn't using the fpu at all" --
we got rid of that.

>
>> We take the full performance hit for a *single* kernel_fpu_begin() on
>> an otherwise short syscall or interrupt, but there's no additional
>> cost for more of them or for long-enough-running things that we
>> schedule in the middle.
>
> It might be worth adding a parameter to kernel_fpu_begin() to indicate
> which registers are needed, and a return value to say what has been
> granted.
> Then a driver could request AVX2 (for example) and use a fallback path
> if the register set isn't available (for any reason).
> A call from an ISR could always fail.

Last time I benchmarked it, XSAVEC on none of the state wasn't a whole
lot faster than XSAVEC for all of it.

>
>> As I remember, the main hangup was that this interacts a bit oddly
>> with PKRU, but that's manageable.
>
> WTF PKRU ??

PKRU is uniquely demented.  All the rest of the XSAVEC state only
affects code that explicitly references that state.  PKRU affects
every single access to user pages, so we need PKRU to match the
current task at all times in the kernel.  This means that, if we start
deferring XRSTORS until prepare_exit_to_usermode(), we need to start
restoring PKRU using WRPKRU in __switch_to().  Of course, *that*
interacts a bit oddly with XINUSE, but maybe we don't care.

Phooey on you, Intel, for putting PKRU into xstate and not giving a
fast instruction to control XINUSE.

WARNING: multiple messages have this Message-ID (diff)
From: Andy Lutomirski <luto@kernel.org>
To: David Laight <David.Laight@aculab.com>
Cc: Andy Lutomirski <luto@kernel.org>, Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"torvalds@linux-foundation.org" <torvalds@linux-foundation.org>,
	"ganeshgr@chelsio.com" <ganeshgr@chelsio.com>,
	"nirranjan@chelsio.com" <nirranjan@chelsio.com>,
	"indranil@chelsio.com" <indranil@chelsio.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Fenghua Yu <fenghua.yu@intel.com>,
	Eric Bi
Subject: Re: [RFC PATCH 0/3] kernel: add support for 256-bit IO access
Date: Wed, 21 Mar 2018 00:39:53 +0000	[thread overview]
Message-ID: <CALCETrV8d5HD2q_qmiRfs-vB=JkiDm3yDx-5KcYqu7yEQrdu0A@mail.gmail.com> (raw)
In-Reply-To: <c1eac43cd8e143d09477a34ed6de6302@AcuMS.aculab.com>

On Tue, Mar 20, 2018 at 3:10 PM, David Laight <David.Laight@aculab.com> wrote:
> From: Andy Lutomirski
>> Sent: 20 March 2018 14:57
> ...
>> I'd rather see us finally finish the work that Rik started to rework
>> this differently.  I'd like kernel_fpu_begin() to look like:
>>
>> if (test_thread_flag(TIF_NEED_FPU_RESTORE)) {
>>   return; // we're already okay.  maybe we need to check
>> in_interrupt() or something, though?
>> } else {
>>   XSAVES/XSAVEOPT/XSAVE;
>>   set_thread_flag(TIF_NEED_FPU_RESTORE):
>> }
>>
>> and kernel_fpu_end() does nothing at all.
>
> I guess it might need to set (clear?) the CFLAGS bit for a process
> that isn't using the fpu at all - which seems a sensible feature.

What do you mean "CFLAGS"?

But we no longer have any concept of "isn't using the fpu at all" --
we got rid of that.

>
>> We take the full performance hit for a *single* kernel_fpu_begin() on
>> an otherwise short syscall or interrupt, but there's no additional
>> cost for more of them or for long-enough-running things that we
>> schedule in the middle.
>
> It might be worth adding a parameter to kernel_fpu_begin() to indicate
> which registers are needed, and a return value to say what has been
> granted.
> Then a driver could request AVX2 (for example) and use a fallback path
> if the register set isn't available (for any reason).
> A call from an ISR could always fail.

Last time I benchmarked it, XSAVEC on none of the state wasn't a whole
lot faster than XSAVEC for all of it.

>
>> As I remember, the main hangup was that this interacts a bit oddly
>> with PKRU, but that's manageable.
>
> WTF PKRU ??

PKRU is uniquely demented.  All the rest of the XSAVEC state only
affects code that explicitly references that state.  PKRU affects
every single access to user pages, so we need PKRU to match the
current task at all times in the kernel.  This means that, if we start
deferring XRSTORS until prepare_exit_to_usermode(), we need to start
restoring PKRU using WRPKRU in __switch_to().  Of course, *that*
interacts a bit oddly with XINUSE, but maybe we don't care.

Phooey on you, Intel, for putting PKRU into xstate and not giving a
fast instruction to control XINUSE.

  reply	other threads:[~2018-03-21  0:40 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-19 14:20 [RFC PATCH 0/3] kernel: add support for 256-bit IO access Rahul Lakkireddy
2018-03-19 14:20 ` [RFC PATCH 1/3] include/linux: add 256-bit IO accessors Rahul Lakkireddy
2018-03-19 14:20 ` [RFC PATCH 2/3] x86/io: implement 256-bit IO read and write Rahul Lakkireddy
2018-03-19 14:43   ` Thomas Gleixner
2018-03-20 13:32     ` Rahul Lakkireddy
2018-03-20 13:44       ` Andy Shevchenko
2018-03-21 12:27         ` Rahul Lakkireddy
2018-03-20 14:40       ` David Laight
2018-03-21 12:28         ` Rahul Lakkireddy
2018-03-20 14:42       ` Alexander Duyck
2018-03-21 12:28         ` Rahul Lakkireddy
2018-03-22  1:26         ` Linus Torvalds
2018-03-22 10:48           ` David Laight
2018-03-22 17:16             ` Linus Torvalds
2018-03-19 14:20 ` [RFC PATCH 3/3] cxgb4: read on-chip memory 256-bits at a time Rahul Lakkireddy
2018-03-19 14:53 ` [RFC PATCH 0/3] kernel: add support for 256-bit IO access David Laight
2018-03-19 15:05   ` Thomas Gleixner
2018-03-19 15:19     ` David Laight
2018-03-19 15:37       ` Thomas Gleixner
2018-03-19 15:53         ` David Laight
2018-03-19 16:29           ` Linus Torvalds
2018-03-20  8:26         ` Ingo Molnar
2018-03-20  8:26           ` Ingo Molnar
2018-03-20  8:38           ` Thomas Gleixner
2018-03-20  9:08             ` Ingo Molnar
2018-03-20  9:41               ` Thomas Gleixner
2018-03-20  9:59                 ` David Laight
2018-03-20 10:54                 ` Ingo Molnar
2018-03-20 13:30                   ` David Laight
2018-04-03  8:49                   ` Pavel Machek
2018-04-03  8:49                     ` Pavel Machek
2018-04-03 10:36                     ` Ingo Molnar
2018-04-03 10:36                       ` Ingo Molnar
2018-03-20 14:57           ` Andy Lutomirski
2018-03-20 14:57             ` Andy Lutomirski
2018-03-20 15:10             ` David Laight
2018-03-21  0:39               ` Andy Lutomirski [this message]
2018-03-21  0:39                 ` Andy Lutomirski
2018-03-20 18:01           ` Linus Torvalds
2018-03-21  6:32             ` Ingo Molnar
2018-03-21 15:45               ` Andy Lutomirski
2018-03-21 15:45                 ` Andy Lutomirski
2018-03-22  9:36                 ` Ingo Molnar
2018-03-21  7:46             ` Ingo Molnar
2018-03-21 18:15               ` Linus Torvalds
2018-03-22  9:33                 ` Ingo Molnar
2018-03-22 17:40                   ` Alexei Starovoitov
2018-03-22 17:40                     ` Alexei Starovoitov
2018-03-22 17:44                     ` Andy Lutomirski
2018-03-22 17:44                       ` Andy Lutomirski
2018-03-22 10:35                 ` David Laight
2018-03-22 12:48                   ` David Laight
2018-03-22 17:07                     ` Linus Torvalds
2018-03-19 15:27 ` Christoph Hellwig
2018-03-20 13:45   ` Rahul Lakkireddy

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='CALCETrV8d5HD2q_qmiRfs-vB=JkiDm3yDx-5KcYqu7yEQrdu0A@mail.gmail.com' \
    --to=luto@kernel.org \
    --cc=David.Laight@aculab.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=ebiggers3@gmail.com \
    --cc=fenghua.yu@intel.com \
    --cc=ganeshgr@chelsio.com \
    --cc=hpa@zytor.com \
    --cc=indranil@chelsio.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=nirranjan@chelsio.com \
    --cc=rahul.lakkireddy@chelsio.com \
    --cc=riel@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.