Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3038147pxb; Tue, 13 Apr 2021 17:11:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZknb/podXaEWiVv+C8+liHpWp+/B/aAGzZipHiZPYStKG5lgFE+PNUaP7G6wslH8rp+Sh X-Received: by 2002:a17:902:edc4:b029:eb:159f:32b7 with SMTP id q4-20020a170902edc4b02900eb159f32b7mr9674351plk.11.1618359084057; Tue, 13 Apr 2021 17:11:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618359084; cv=none; d=google.com; s=arc-20160816; b=ho5zfprKuo8Zl1bbpf3NR2VBQcxy8YBAYibLvq/kcwQyUSF2d34BapLj6L8i6Nbfum D+CpowlLcb+IE2SSzUg5VTZfvZwXumm/B+lotY2DBZWWH6+Rpe7TVyzjwV97xwmzUTur c+RXFRL1eNX1LUa3OuLMpo3jJe/0QryE98JiwYQwSIMawrcSPpfFrm2xW16WnN+bSNza 1VYw8viYCgaTMaepkap2ukCwTsNezOOkRWbh2n09p2QfQgljrKD0h0wfHsIVAgxDySX5 k0P65h1CYSIzk0imQF7z4pIL6VcbYFZZuE3yCr9iJibA/iUU9CqYEyPA0slfonx0oXSp ozfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=OyIpFtid8sZtpW4KmMNRNzsP7yl7goENSIz/TqeBtF4=; b=ZqRZJq4x9sjZeHIrE6LAiaND3ISKczhOjNvWg+M22Zvkoy0AiolKkmaISOPokfO2ym 7AAcraHuJ22pouen+ZKi1dhyqQRKklUM2XpVFq9fHEyDe9HZvkI2nWJ2N5oTjR2lv9IB Ftn4yCF4KHlAz9VH2o20NZn6mKx9qMc+lO/YwrXagH56C+p/IWBW85BCezAH2NLgz3FP 9BwH8EtqnO3XElvT+7AzZ7smzKsWn3v302+UR3VcaHsqRT72LZS6Zj5cv/4jnSEnRRgd O+S5UdbRm9F4eWCr3hNgxgrD0IupTwCG/bLKZzyeQiuyvkzLBd4fGW1FfRgfopcI3/pU ux4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uFTx73jL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m190si4646547pga.378.2021.04.13.17.11.11; Tue, 13 Apr 2021 17:11:24 -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=@kernel.org header.s=k20201202 header.b=uFTx73jL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348157AbhDMURA (ORCPT + 99 others); Tue, 13 Apr 2021 16:17:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:48006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229590AbhDMURA (ORCPT ); Tue, 13 Apr 2021 16:17:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F316161242 for ; Tue, 13 Apr 2021 20:16:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618345000; bh=018/wT7YNp41Opa/wOlmQasGzutY4YJko3lMFOUYFkU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=uFTx73jL2VN8tGeX/xS4VRQQEnRCaJMsw+8u4HZa2mlUUgFPXWNvef27/irWxa38o oXuYsjbNHVxp/mdgNSFtZbmRRlsVUms/ULYQsQIwyRNDVloi5PGrQEeOEyp04wVxdM yw5ZyTNQlZCPppcmp1f+5QI40eAq3mydIZZLIpsmo/4S9nB9dvkn3yANO54pmA81n+ itSuME8eZYjKe2dRFcAQChPsuWRUyK60CCxB7iQF7PrtudQ9rM20m6FNjpDBxnHiNX etlD+IcrURJKi2o7VUaEN0Xm+wUdCQ2wA6ke1athykkb2kgWJh7gj/ZDcp1Hk9Zg0O DhVUAMpsqp8Wg== Received: by mail-ed1-f54.google.com with SMTP id 18so20925459edx.3 for ; Tue, 13 Apr 2021 13:16:39 -0700 (PDT) X-Gm-Message-State: AOAM530Py8j/kzdMTHLgBkE1sZcCcVXhGRvfuVBXVttJ5LD/ojmvXVkY c2qoeS/k/6QNXYWQGGpuON3/2XJQzaCL3BNz2F0boQ== X-Received: by 2002:a05:6402:30ae:: with SMTP id df14mr36407363edb.97.1618344998640; Tue, 13 Apr 2021 13:16:38 -0700 (PDT) MIME-Version: 1.0 References: <87lf9nk2ku.fsf@oldenburg.str.redhat.com> In-Reply-To: From: Andy Lutomirski Date: Tue, 13 Apr 2021 13:16:27 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Candidate Linux ABI for Intel AMX and hypothetical new related features To: Len Brown , Willy Tarreau Cc: Andy Lutomirski , Florian Weimer , "Bae, Chang Seok" , Dave Hansen , X86 ML , LKML , linux-abi@vger.kernel.org, "libc-alpha@sourceware.org" , Rich Felker , Kyle Huey , Keno Fischer Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 12, 2021 at 4:46 PM Len Brown wrote: > > On Mon, Apr 12, 2021 at 11:21 AM Andy Lutomirski wrote: > > > AMX: Multiplying a 4x4 matrix probably looks *great* in a > > microbenchmark. Do it once and you permanently allocate 8kB (is that > > even a constant? can it grow in newer parts?), potentially hurts all > > future context switches, and does who-knows-what to Turbo licenses and > > such. > > Intel expects that AMX will be extremely valuable to key workloads. > It is true that you may never run that kind of workload on the machine > in front of you, > and so you have every right to be doubtful about the value of AMX. I fully believe that AMX will be amazing when used for the right workload. The problem is that a library may have no way to tell whether a workload is the type of computationally intensive workload for which it makes sense. Imagine you have a little function: int matrix_times_vector(int dim, float *out, const float *matrix, const float *vector); A clever library might use AMX for this. If dim == 4 and the caller is planning to call it in a long, tight loop, maybe this even makes sense. If dim == 4 and it's being called once, AMX is probably a losing proposition. With previous technologies, at least the impact was limited to the function itself and maybe once per call to the caller. But now, with AMX, the program that invoked this takes a performance and memory hit *forever* if it uses AMX once. Beyond that, we have the signal handling issue. One solution, going off of what WIlly mentioned, is: bool amx_begin(void *signal_save_buffer); void amx_end(); In the amx_begin() region, if you get a signal, the AMX state is saved in the buffer. Outside the region, if you get a signal and AMX is in use, the kernel will either unceremoniously kill the task or will deliver SIGYOUBLEWIT. [0] I'm really hoping some userspace people can chime in. [0] We really ought to have a SIGSIGNALFAILURE or something for the case where normal signal delivery fails. This is the userspace equivalent of #DF. SIGYOUBLEWIT could be folded in. There would be a flag in the signal frame saying "don't even try to sigreturn".