Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2262750pxj; Sat, 22 May 2021 16:59:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqZ09SrsmXrSTVSPKCKK0+5iOKjWpj4oyrYo1sNp5too48j2M3UwJ7Xoy7bLa2ewOvOxHn X-Received: by 2002:a5d:818c:: with SMTP id u12mr6782037ion.81.1621727946656; Sat, 22 May 2021 16:59:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621727946; cv=none; d=google.com; s=arc-20160816; b=zch23w1U5WTHSYY6sRpBHIo+3c4m53i0r8m4K9Tv0j2lITC2Mbl2K4mSab3I0JoYwy hNbNNCTvCI2Bl/c7wr1Dl/gDckdsyt+MqsMfN/ThzAemllRdEiqcSQAslFkp9BKdXe7G mU1bTgac3lJ/7twSwQQ69aVl6Xw54UDD8amR/As6CGOaSOV2L3PSqZlk2B1T6NO5j2JJ VUDdj7LSXkQg4xpaV0n2xOSkPhaBoUaTPoQWxI/grSidOezlcSrBFteJ4SLHpDahZhoT JH3I9C56966v6ihhbe/HWFOR6vtz4rblfftZaJZIS2Wxw+AfIAoifjonmtTudpaOBpLK eyLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=NoFRaG3pQC697KoozdsVfntgxYM1vr90lHmRImt8y0k=; b=QciM2AhQ5zOgmm15BdpvJVgSa8n5ZzR8I5fN2CrRTjNhg5mx4LpLBmxdDL0rgTb6Dr L0bMkB9pU5QfRENQiqKCpYnoc96vGwAWCF9KLP6D/NNgW2LyEgTyNaL3nnhEC2Wg6tIH 4rYdSggxFyKdFvP+186cRQzH8SP+mnrxvveC0RuXOOwLsDr4J12jyRfTxbncHtJ2YJRS 8McbF6H8513P5w1ua8Y79YVSrLalcySyVACtbqPR2METPDinkNPrbk+J2AqeoEGuBtem u0PL58dQeGWSUlWSNmGtgrXFmcZaX0zj1WijXcmxkaEQU+r0gQoPOQf1Xyh6RW20P472 ZnsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t2dtZYHN; 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 l27si9186424jaq.51.2021.05.22.16.58.53; Sat, 22 May 2021 16:59:06 -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=t2dtZYHN; 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 S231446AbhEVX5Y (ORCPT + 99 others); Sat, 22 May 2021 19:57:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:42482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231440AbhEVX5X (ORCPT ); Sat, 22 May 2021 19:57:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2198B61182 for ; Sat, 22 May 2021 23:55:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621727758; bh=6dXbeile7lzsbpeK/x/mWQ+Zr2cMohG3GFCCGvZUMNM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=t2dtZYHN4jh0HJtjGL9PAqNUzbTubKtHgUnjKOMeNKvll0rGjq+uk2A0wZbdmyj9y WqvTgKrk4NdcBHxcDIBhCvSarLpFmGF7RzbXCzugFR9Kx8Acgy+lNd10nsb48I6vSQ IzQwSmcLXwu1AqyAk27BtDGeWtrEsFicsPp+vWObkdVLtqQQkrXwvYWPd94VOjQkfi EIQls3REdhYS3+NRof0yu4Lc4XO8M6CLAwnQefbysKWpD51ecrNKoOe2SM28jKFKb5 IYnn571R5veecTo1tC2uSpVOUTLwmLfKDEw/8eL1ntnFmorFUswG6wLpWCVTg1A+SM nfr3XqBQoZHhA== Received: by mail-ej1-f46.google.com with SMTP id lz27so36013383ejb.11 for ; Sat, 22 May 2021 16:55:58 -0700 (PDT) X-Gm-Message-State: AOAM532UVnKfag8GYXJnAbH9fC0BG2B33b2XFMmJGCOGF7g/6UCOeG1p XK657ex1+r1XaKtTEwCUxXC/I07ZC4Vrf01bGhvZIA== X-Received: by 2002:a17:906:c010:: with SMTP id e16mr16823348ejz.214.1621727756732; Sat, 22 May 2021 16:55:56 -0700 (PDT) MIME-Version: 1.0 References: <20210415044258.GA6318@zn.tnic> <20210419191539.GH9093@zn.tnic> <20210419215809.GJ9093@zn.tnic> <874kf11yoz.ffs@nanos.tec.linutronix.de> <87k0ntazyn.ffs@nanos.tec.linutronix.de> <37833625-3e6b-5d93-cc4d-26164d06a0c6@intel.com> <9c8138eb-3956-e897-ed4e-426bf6663c11@intel.com> <87pmxk87th.fsf@oldenburg.str.redhat.com> <939ec057-3851-d8fb-7b45-993fa07c4cb5@intel.com> <87r1i06ow2.fsf@oldenburg.str.redhat.com> <263a58a9-26d5-4e55-b3e1-3718baf1b81d@www.fastmail.com> <87k0nraonu.ffs@nanos.tec.linutronix.de> <878s47aeni.ffs@nanos.tec.linutronix.de> <877djr5jc3.fsf@oldenburg.str.redhat.com> In-Reply-To: <877djr5jc3.fsf@oldenburg.str.redhat.com> From: Andy Lutomirski Date: Sat, 22 May 2021 16:55:45 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Candidate Linux ABI for Intel AMX and hypothetical new related features To: Florian Weimer Cc: Len Brown , Thomas Gleixner , Andy Lutomirski , Dave Hansen , Dave Hansen via Libc-alpha , Rich Felker , Linux API , "Bae, Chang Seok" , "the arch/x86 maintainers" , Linux Kernel Mailing List , Kyle Huey , Borislav Petkov , Keno Fischer , Arjan van de Ven , Willy Tarreau Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On May 22, 2021, at 12:17 AM, Florian Weimer wrote: > > =EF=BB=BF* Len Brown: > >> A. per-task. If we do it this way, then we will likely wind up >> mandating a GET at the start of every routine in every library that >> touches AMX, and potentially also a PUT. This is because the library >> has no idea what thread called it. The plus is that this will address >> the "used once and sits on a buffer for the rest of the process >> lifetime' scenario. The minus is that high performance users will be >> executing thousands of unnecessary system calls that have zero value. > > We could revive the KTLS proposal (userspace donates memory for use by > the kernel & vDSO), and the thread could reserve (on-stack) buffer space > for kernel use for the duration of the AMX computation. There would be > a pointer to that space in the KTLS area, set upon entry of the AMX > region, and cleared upon exit. It's not extremely cheap (unbounded > alloca has a stack probing loop nowadays). But no system call is > required. > Making this work well would be very nasty. The memory *must* be available at context switch out time, which means it would need to be pinned at context switch in time, which is not great. But also Intel, in its infinite wisdom, decided to mix =E2=80=9Csupervisor= =E2=80=9D states in which the state that user space is permitted to directly access. Putting the supervisor state on the stack would be problematic.