Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3786773pxf; Mon, 29 Mar 2021 11:20:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxO3DrBn2mmANkzkOdSbDBKAZGXekPfqGAOIcdB/tCHNTri6kie76uCMfL3/ku9Z++V/NO X-Received: by 2002:a17:906:2504:: with SMTP id i4mr30116932ejb.115.1617042044817; Mon, 29 Mar 2021 11:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617042044; cv=none; d=google.com; s=arc-20160816; b=qEIdp7k4NBpPl3daEqZVodAGUTMWf9xTGmYHWUR/P5QLBD9viEVGkZs2lGEakOGFMq gEBLcgokUyewd4gqX/DnF5o+STVo6XkOK4XsAV2J4qxGbVy2HElHL97QyOhWfCDVrUBl L5yum6daPb/SElnsouc7ZShlEL0aMOE/ufUVLZdGVDDXzWagA7v4h460jyXEIyc1WrXn jUoB+STDo4km78faArRVp0UX73+hBt9Ue6JLPZUTlu9nt6LMFKzQ52+utzRIP37BXT00 rK/oYK4Fp+ggFwKuRW0L93wUhydbpIjJ8Bsv0D8Vdk92AKOv5L4Bmr6K4LD1orPIHH78 al5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id:date:cc:in-reply-to :from:subject:mime-version:content-transfer-encoding:dkim-signature; bh=8BodsD7dsVnt+VzHAjG94w3biZzppe7s1NeC4YW3R/c=; b=a3NsPrgCkoR/lLQuggK/Qfk69mQ8LdoxO+BQJMVv3RC182zMLGhsP76f3MsWs5A6Zr 4t6gON+bvABm8Psa2gFO770WEhWB2N9GebfoYRJsEXWFDNaYXbDk8mLAIwwZn/9oouaV madxKQ5jfTG/W4rSiBzy1VLwK2JA7m9MMExnxrf1qCgfk5jCzaByUE+eDgOjzGqbCHxz /NTuRprHxFfOi5x10hRPwdBGk7FqykE9aYeY9clwCTr7syLS7dVvA6XduRhrlKu+BSwY uOSjCAqbpTUoV5tLT8UU4MacJLx3z8+L43YgnOjihzguHHMk7n9TIodNURFFzJZSlEmQ BVYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=GNpIT7nz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b6si13441705edd.528.2021.03.29.11.20.21; Mon, 29 Mar 2021 11:20:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=GNpIT7nz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231420AbhC2SRU (ORCPT + 99 others); Mon, 29 Mar 2021 14:17:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230039AbhC2SQz (ORCPT ); Mon, 29 Mar 2021 14:16:55 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37FABC061756 for ; Mon, 29 Mar 2021 11:16:55 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id h25so9951999pgm.3 for ; Mon, 29 Mar 2021 11:16:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=content-transfer-encoding:mime-version:subject:from:in-reply-to:cc :date:message-id:references:to; bh=8BodsD7dsVnt+VzHAjG94w3biZzppe7s1NeC4YW3R/c=; b=GNpIT7nzOTmW1j7uFYG4MsGsQxgaqfSrJP1SkCUw/L5kBaziQANp4Xtap/4+tcFNgC KTvZCQCQVpgIb0fUmLkQ60kWI8HQXJYR6DiQRm4CIU3tIU29oOJJZ+fz+Ocfv5mlWm8x DkEPHuwuZkcS4OKahPd0myLcrYOjKzc6pCbnd6jKrunOdLISD8RsZXHq1DisNJJfQ0gt cMIX92bLePaXILA75sfBZv7pX34Tzjw7R53UoU7TJeFVt5m/Pw3fgpgQJUSVboYdjgGs +CFJcbyeTYn8OpYjuc/wtrHPkmhoJVZn2kGJKbVyDMEBroWuC16FFk0uifhUmu4OJiJw XMEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:mime-version:subject :from:in-reply-to:cc:date:message-id:references:to; bh=8BodsD7dsVnt+VzHAjG94w3biZzppe7s1NeC4YW3R/c=; b=l7ldRbcEbqReXuGV+BFzqp8URZ98n065eixUxLxHqpCp4qZYBAwf1w78CbzYP6C5XC N5EBu7d0VtXAfrT1r5qfQ0YGnvK5R3XWM0OrMJGQqoc6v4COJwAY4IAAqPFgJY0TbL3p uxVgo6T/fnbF5jq+uEN/1eYjK5wk9tXUMzLfNKAuZjkJmgX6HbjtVJFfk+uVGqq+pF1F 2liJlNrVC4iTX3OCKZXEpf6cK2ngEsi6QpUNwCefImQjUQ1h1tuot6cQwteC6D2Cvsmb o6k34pk8G724vNGurlm+m8fKclnM+hdo8S8Q8sRGx/6zY6Niw4zXvS39cYazgmRz8WnP FJWg== X-Gm-Message-State: AOAM530f126UpJXCFsnpz1yqfXKLkaS4eVC6pAuGvS+iomSrS54YbD4w F0SCJlXLVwdra9kGnk12mHy+Qg== X-Received: by 2002:a63:f959:: with SMTP id q25mr25786650pgk.104.1617041814663; Mon, 29 Mar 2021 11:16:54 -0700 (PDT) Received: from ?IPv6:2600:1010:b06a:1311:e806:6d31:5a5:2c5c? ([2600:1010:b06a:1311:e806:6d31:5a5:2c5c]) by smtp.gmail.com with ESMTPSA id mp21sm212574pjb.16.2021.03.29.11.16.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 Mar 2021 11:16:54 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (1.0) Subject: Re: Candidate Linux ABI for Intel AMX and hypothetical new related features From: Andy Lutomirski In-Reply-To: Cc: Greg KH , Andy Lutomirski , "Bae, Chang Seok" , Dave Hansen , X86 ML , LKML , libc-alpha , Florian Weimer , Rich Felker , Kyle Huey , Keno Fischer , Linux API Date: Mon, 29 Mar 2021 11:16:52 -0700 Message-Id: <5F98327E-8EC4-455E-B9E1-74D2F13578C5@amacapital.net> References: To: Len Brown X-Mailer: iPhone Mail (18D61) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Mar 29, 2021, at 8:47 AM, Len Brown wrote: >=20 > =EF=BB=BFOn Sat, Mar 27, 2021 at 5:58 AM Greg KH 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. >=20 > sorry for the confusion. >=20 > mainline =3D main(). >=20 > ie. the part of the program written by you, and not the library you linked= with. >=20 > In particular, the library may use instructions that main() doesn't know e= xist. 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 ope= ning a device node or otherwise requesting access to the device.=20 Real AMX isn=E2=80=99t so different. Programs acquire access either by sysca= ll or by a fault, they use it, and (hopefully) they release it again using T= ILERELEASE. The only thing special about it is that, supposedly, acquiring a= nd releasing access (at least after the first time) is quite fast. But hold= ing access is *not* free =E2=80=94 despite all your assertions to the contra= ry, the kernel *will* correctly context switch it to avoid blowing up power c= onsumption, and this will have overhead. We=E2=80=99ve seen the pattern of programs thinking that, just because somet= hing is a CPU insn, it=E2=80=99s free and no thought is needed before using i= t. 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 screwi= ng up the AVX state machine, and the only way I know about any of the detail= s is that I wrote silly test programs to try to reverse engineer the nonsens= ical 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=E2=80=99s 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 n= ot happened. Let=E2=80=99s list all of them: - SSE. Look for all the MXCSR special cases in the pseudocode and tell me w= ith a straight face that this one works sensibly. - AVX. Also has special cases in the pseudocode. And has transition issues t= hat 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=E2= =80=99s MPX. - PKRU: Should never have been in XSTATE. (Also, having WRPKRU in the ISA wa= s a major mistake, now unfixable, that seriously limits the usefulness of th= e whole feature. I suppose Intel could release PKRU2 with a better ISA and d= eprecate the original PKRU, but I=E2=80=99m not holding my breath.) - AVX512: Yet more uarch-dependent horrible performance issues, and Intel ha= s still not responded about documentation. The web is full of people specul= ating differently about when, exactly, using AVX512 breaks performance. This= is NAKked in kernel until docs arrive. Also, it broke old user programs. I= f 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 somet= hing better.=