linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Lutomirski <luto@amacapital.net>
To: Len Brown <lenb@kernel.org>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	Andy Lutomirski <luto@kernel.org>,
	"Bae, Chang Seok" <chang.seok.bae@intel.com>,
	Dave Hansen <dave.hansen@intel.com>, X86 ML <x86@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	libc-alpha <libc-alpha@sourceware.org>,
	Florian Weimer <fweimer@redhat.com>,
	Rich Felker <dalias@libc.org>, Kyle Huey <me@kylehuey.com>,
	Keno Fischer <keno@juliacomputing.com>,
	Linux API <linux-api@vger.kernel.org>
Subject: Re: Candidate Linux ABI for Intel AMX and hypothetical new related features
Date: Mon, 29 Mar 2021 11:16:52 -0700	[thread overview]
Message-ID: <5F98327E-8EC4-455E-B9E1-74D2F13578C5@amacapital.net> (raw)
In-Reply-To: <CAJvTdK=QbPRtZ9zPgu8c9tqxOtaG3apo7u4BBTXP0--qVWA5ig@mail.gmail.com>


> On Mar 29, 2021, at 8:47 AM, Len Brown <lenb@kernel.org> wrote:
> 
> On Sat, Mar 27, 2021 at 5:58 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>>> On Fri, Mar 26, 2021 at 11:39:18PM -0400, Len Brown wrote:
>>> Hi Andy,
>>> Say a mainline links with a math library that uses AMX without the
>>> knowledge of the mainline.
> 
> sorry for the confusion.
> 
> mainline = main().
> 
> ie. the part of the program written by you, and not the library you linked with.
> 
> In particular, the library may use instructions that main() doesn't know exist.

If we pretend for a bit that AMX were a separate device instead of a part of the CPU, this would be a no brainer: something would be responsible for opening a device node or otherwise requesting access to the device. 

Real AMX isn’t so different. Programs acquire access either by syscall or by a fault, they use it, and (hopefully) they release it again using TILERELEASE. The only thing special about it is that, supposedly, acquiring and releasing access (at least after the first time) is quite fast.  But holding access is *not* free — despite all your assertions to the contrary, the kernel *will* correctly context switch it to avoid blowing up power consumption, and this will have overhead.

We’ve seen the pattern of programs thinking that, just because something is a CPU insn, it’s free and no thought is needed before using it. This happened with AVX and AVX512, and it will happen again with AMX. We *still* have a significant performance regression in the kernel due to screwing up the AVX state machine, and the only way I know about any of the details is that I wrote silly test programs to try to reverse engineer the nonsensical behavior of the CPUs.

I might believe that Intel has figured out how to make a well behaved XSTATE feature after Intel demonstrates at least once that it’s possible.  That means full documentation of all the weird issues, no new special cases, and the feature actually making sense in the context of XSTATE.  This has not happened.  Let’s list all of them:

- SSE.  Look for all the MXCSR special cases in the pseudocode and tell me with a straight face that this one works sensibly.

- AVX.  Also has special cases in the pseudocode. And has transition issues that are still problems and still not fully documented. L

- AVX2.  Horrible undocumented performance issues.  Otherwise maybe okay?

- MPX: maybe the best example, but the compat mode part got flubbed and it’s MPX.

- PKRU: Should never have been in XSTATE. (Also, having WRPKRU in the ISA was a major mistake, now unfixable, that seriously limits the usefulness of the whole feature.  I suppose Intel could release PKRU2 with a better ISA and deprecate the original PKRU, but I’m not holding my breath.)

- AVX512: Yet more uarch-dependent horrible performance issues, and Intel has still not responded about documentation.  The web is full of people speculating differently about when, exactly, using AVX512 breaks performance. This is NAKked in kernel until docs arrive. Also, it broke old user programs.  If we had noticed a few years ago, AVX512 enablement would have been reverted.

- AMX: This mess.

The current system of automatic user enablement does not work. We need something better.

  parent reply	other threads:[~2021-03-29 18:17 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CALCETrW2QHa2TLvnUuVxAAheqcbSZ-5_WRXtDSAGcbG8N+gtdQ@mail.gmail.com>
2021-03-26 23:18 ` Candidate Linux ABI for Intel AMX and hypothetical new related features Andy Lutomirski
2021-03-27  3:39   ` Len Brown
2021-03-27  9:14     ` Borislav Petkov
2021-03-27  9:58     ` Greg KH
2021-03-29 15:47       ` Len Brown
2021-03-29 16:38         ` Len Brown
2021-03-29 16:48           ` Florian Weimer
2021-03-29 18:14           ` Andy Lutomirski
2021-03-29 18:16         ` Andy Lutomirski [this message]
2021-03-29 22:38           ` Len Brown
2021-03-30  5:08             ` Andy Lutomirski
2021-03-30  5:50               ` Noah Goldstein
2021-03-30 17:01               ` Len Brown
2021-03-30 17:05                 ` Andy Lutomirski
2021-03-30 17:56                   ` Len Brown
2021-03-30 19:12                     ` Dave Hansen
2021-03-30 20:20                       ` Andy Lutomirski
2021-03-30 20:42                         ` Len Brown
2021-03-30 22:01                           ` David Laight
2021-03-31 16:31                             ` Len Brown
2021-03-31 16:53                               ` Andy Lutomirski
2021-03-31 21:42                                 ` Robert O'Callahan
2021-03-31 22:11                                   ` Len Brown
2021-03-31 22:28                                 ` Len Brown
2021-03-31 22:45                                   ` Andy Lutomirski
2021-04-09 20:52                                     ` Len Brown
2021-04-09 21:44                                       ` Andy Lutomirski
2021-04-11 19:07                                         ` Len Brown
2021-04-12  7:59                                           ` David Laight
2021-04-12 12:19                                           ` Borislav Petkov
2021-04-12 17:14                                           ` Sean Christopherson
2021-03-31 22:52                                   ` Borislav Petkov
2021-04-09 20:55                                     ` Len Brown
2021-03-28  0:53   ` Thomas Gleixner
2021-03-29  7:27     ` Peter Zijlstra
2021-03-29 15:06     ` Dave Hansen
     [not found] <20210415044258.GA6318@zn.tnic>
     [not found] ` <20210415052938.GA2325@1wt.eu>
     [not found]   ` <20210415054713.GB6318@zn.tnic>
     [not found]     ` <CAJvTdKnjzAMh3N_c7KP3kA=e0LgYHgCANg44oJp3LcSm7dtbSQ@mail.gmail.com>
     [not found]       ` <20210419141454.GE9093@zn.tnic>
     [not found]         ` <CAJvTdK=p8mgO3xw9sRxu0c7NTNTG109M442b3UZh8TqLLfkC1Q@mail.gmail.com>
     [not found]           ` <20210419191539.GH9093@zn.tnic>
     [not found]             ` <CAJvTdK=VnG94ECcRVoUi8HrCbVEKc8X4_JmRTkqe+vTttf0Wsg@mail.gmail.com>
     [not found]               ` <20210419215809.GJ9093@zn.tnic>
     [not found]                 ` <CAJvTdKn6JHo02karEs0e5g+6SimS5VUcXKjCkX35WY+xkgAgxw@mail.gmail.com>
     [not found]                   ` <YIMmwhEr46VPAZa4@zn.tnic>
     [not found]                     ` <CAJvTdKnhXnynybS4eNEF_EtF26auyb-mhKLNd1D9_zvCrchZsw@mail.gmail.com>
2021-05-17  9:45                       ` Thomas Gleixner
2021-05-17  9:56                         ` Florian Weimer
2021-05-17 10:18                           ` Thomas Gleixner
2021-05-21 16:29                           ` Len Brown
2021-05-17 13:49                         ` Arjan van de Ven
2021-05-20 15:35                         ` Len Brown
2021-05-20 20:54                           ` Thomas Gleixner
2021-05-20 21:13                             ` Dave Hansen
2021-05-20 21:41                               ` Len Brown
2021-05-20 22:53                                 ` Dave Hansen
2021-05-21  9:41                                   ` Thomas Gleixner
2021-05-21 14:44                                   ` Florian Weimer
2021-05-21 14:49                                     ` Peter Zijlstra
2021-06-23 15:06                                       ` Florian Weimer
2021-06-23 23:11                                         ` Len Brown
2021-06-28 10:14                                           ` Enrico Weigelt, metux IT consult
2021-06-28 12:49                                             ` Florian Weimer
2021-06-30 12:22                                               ` Enrico Weigelt, metux IT consult
2021-06-30 12:41                                                 ` Willy Tarreau
2021-06-30 13:55                                                 ` Arjan van de Ven
2021-06-30 15:20                                                   ` Len Brown
2021-06-30 15:25                                                   ` Enrico Weigelt, metux IT consult
2021-05-21 16:14                                     ` Dave Hansen
2021-05-21 16:19                                       ` Florian Weimer
2021-05-21 16:26                                         ` Len Brown
2021-05-21 16:28                                         ` Dave Hansen
2021-05-21 16:31                                         ` Andy Lutomirski
2021-05-21 19:10                                           ` Thomas Gleixner
2021-05-21 20:07                                             ` Andy Lutomirski
2021-05-21 21:43                                               ` Thomas Gleixner
2021-05-21 22:07                                             ` Len Brown
2021-05-21 22:46                                               ` Thomas Gleixner
2021-05-21 23:31                                                 ` Len Brown
2021-05-22  7:16                                                   ` Florian Weimer
2021-05-22 23:55                                                     ` Andy Lutomirski
2021-05-21 23:06                                               ` Dave Hansen
2021-05-21 23:08                                                 ` Len Brown
2021-05-21 19:05                                         ` Thomas Gleixner
2021-05-20 21:22                             ` Len Brown
2021-05-20 21:41                               ` Thomas Gleixner
2021-05-20 21:49                                 ` Len Brown
2021-05-21  9:26                                   ` Thomas Gleixner

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=5F98327E-8EC4-455E-B9E1-74D2F13578C5@amacapital.net \
    --to=luto@amacapital.net \
    --cc=chang.seok.bae@intel.com \
    --cc=dalias@libc.org \
    --cc=dave.hansen@intel.com \
    --cc=fweimer@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=keno@juliacomputing.com \
    --cc=lenb@kernel.org \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=me@kylehuey.com \
    --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).