Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp433415pxj; Fri, 7 May 2021 11:51:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGgxl1YFgb/pMfqg3qRulh2BmMj6OOnCMaBLaXb/+Ow0pxMwk2hJ0rf30DEIeoK8kDGBmj X-Received: by 2002:a17:906:cd27:: with SMTP id oz39mr11513444ejb.129.1620413510523; Fri, 07 May 2021 11:51:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620413510; cv=none; d=google.com; s=arc-20160816; b=a0bnvUw/03jMnDC8+e+rtbp6Nj/P0xPjq5r3Roj5dT9WF456QOLsj87k96nZ/5Lxwo jHHpGNQMv9FPn88SVToU3hHOo8eV4/KEYrfmc0aWlijD2NXTkEUti3KA3Q/RwVsb+BOo hdZ1bRJMpbJPZGGiORfrdpRqV1hrtwaDCc1nubdArn5NLad/AyJT10hujwlKNxjYvzt5 JfA8ow0eo8egAcOQpQyNjsTGNIrRwgjMTQnekbQIrKl5CGg5sSgvxeWfx52dk5VSrrGs UCXUr0vyzE9zkZ/59DV4WC0JhYf8Wj1Lx7zpkiZTuUt39qir/2Q4vsQSZ6oNFQ/V/FaY 97YA== 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=5/rPnqwcClbhNqzsu5u9ulP3udPJaOLBhc918iwfbwA=; b=cRw7U3EHteXsFgxEAUwzEYZMu9kt7ecQ5N9e9vfeFzkH+h5nLiFw3qfWeALKaM6aBw H7+Ybxv8iY0ZChn4BZ2ZqkbEhtSNj9fxRSYcq+dZevB+6nTdsnWoU/LAVOAroamdjrgj eWKvaOksisNTbSE53IOIpROqKm94TZN2Rdq6lgHYDRV/a9B3swiuc9kL4oFlOkP0SqSi TlfLwpTb+0rB0JMC0ydpjyEfXDtQxMCZCTHAAqYoaPQmnsm7grzd6G9dkklkGMaCwxS5 DuoGsFMRCpxDLMmizEcEfZsxkrOBO+dADSM5BpZTBr2X1Tp26KPLxwU+FX5jlmx13E1x M82g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hrN9Pv39; 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 k19si7199124ejv.98.2021.05.07.11.51.26; Fri, 07 May 2021 11:51:50 -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=hrN9Pv39; 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 S229606AbhEGSvh (ORCPT + 99 others); Fri, 7 May 2021 14:51:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:49298 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229476AbhEGSvg (ORCPT ); Fri, 7 May 2021 14:51:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9600261480 for ; Fri, 7 May 2021 18:50:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620413436; bh=nu9gk8X4jBTmgeiETWHNXdh2I0I6lDvEUX4MoVO8sYY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=hrN9Pv39mSVCQunPwzc5WxTr9Bh+rAVWVBauW8cDRE+TFGBPsIwCUM2g+J6VlNtyf RvgbA+xFvcuvHwrtUibWB0CXkXPM/l/r2gUyhqADinzP5xF9F5LsVPrPopPMorvSR8 rCYN37VvzLmZanUEo3ghIEyNKyRE0XhFlCyAVay2TZ119eeVfX21iwjGcwE6UQZOdn e8YZS8Y1CPqcfcEHCOurNaXf4Al/uk/SwsyK0AICv+casHxJLVmoZGMaZVGiZdzlR+ kpExWwjhjZCwHpxxQw/M7Gbn4afuk7sQDeke84Rp5eUZu6LgKyQMGTCd+IfSAMj5Tn iUkkHPlF07nDw== Received: by mail-ed1-f51.google.com with SMTP id g14so11371775edy.6 for ; Fri, 07 May 2021 11:50:36 -0700 (PDT) X-Gm-Message-State: AOAM532e9lMS5xIq5d2ruQDXY6ajQsVduvMQJmrrhirJNOvc33un/mXe +sLEq0bpJekDXXopuabwB2b9Xutf0xl/WITeXGaEGQ== X-Received: by 2002:a50:fc91:: with SMTP id f17mr13185057edq.23.1620413434996; Fri, 07 May 2021 11:50:34 -0700 (PDT) MIME-Version: 1.0 References: <20210415044258.GA6318@zn.tnic> <20210415052938.GA2325@1wt.eu> <20210415054713.GB6318@zn.tnic> <20210419141454.GE9093@zn.tnic> <20210419191539.GH9093@zn.tnic> <20210419215809.GJ9093@zn.tnic> <87bl9s8kfb.fsf@oldenburg.str.redhat.com> <5d3d513b-77d6-e2e2-779e-ff3ea33deba3@intel.com> <87o8dmmljh.ffs@nanos.tec.linutronix.de> In-Reply-To: <87o8dmmljh.ffs@nanos.tec.linutronix.de> From: Andy Lutomirski Date: Fri, 7 May 2021 11:50:20 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Candidate Linux ABI for Intel AMX and hypothetical new related features To: Thomas Gleixner Cc: Dave Hansen , Florian Weimer , Len Brown , Borislav Petkov , Willy Tarreau , Andy Lutomirski , "Bae, Chang Seok" , 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 Fri, May 7, 2021 at 11:44 AM Thomas Gleixner wrote: > > On Mon, May 03 2021 at 06:43, Dave Hansen wrote: > > On 5/2/21 10:18 PM, Florian Weimer wrote: > >>> 5. If the feature is enabled in XCR0, the user happily uses it. > >>> > >>> For AMX, Linux implements "transparent first use" > >>> so that it doesn't have to allocate 8KB context switch > >>> buffers for tasks that don't actually use AMX. > >>> It does this by arming XFD for all tasks, and taking a #NM > >>> to allocate a context switch buffer only for those tasks > >>> that actually execute AMX instructions. > >> What happens if the kernel cannot allocate that additional context > >> switch buffer? > > > > Well, it's vmalloc()'d and currently smaller that the kernel stack, > > which is also vmalloc()'d. While it can theoretically fail, if it > > happens you have bigger problems on your hands. > > Such a buffer allocation might also exceed a per process/cgroup > limitation. Anything else which is accounted happens in syscall context > which then returns an error on which the application can react. > > So what's the consequence when the allocation fails? Kill it right away > from #NM? Kill it on the first signal? Do nothing and see what happens? > It has to be an immediate signal or kill. A failure to load FPU state is somewhat tolerable (and has to be for CET), but a failure to *save* FPU state on a context switch would be a really nasty can of worms. At the very least we will want arch_prctl(ARCH_ALLOCTE_XSTATE, mask) to allow HPC workloads to manually allocate the state and get an error code if it fails. --Andy