From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by sourceware.org (Postfix) with ESMTPS id BC60A385381C for ; Fri, 7 May 2021 18:50:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BC60A385381C Received: by mail.kernel.org (Postfix) with ESMTPSA id AB6B761483 for ; Fri, 7 May 2021 18:50:36 +0000 (UTC) Received: by mail-ed1-f48.google.com with SMTP id u13so11367923edd.3 for ; Fri, 07 May 2021 11:50:36 -0700 (PDT) X-Gm-Message-State: AOAM533szMZk405noieMOfkh/PZ9c14/VxODc7Nw2PPmmEE63TGHgUv1 SoKNiRdXTYti69tDWqHBz6evzE0Llrpw1K/NQp76tQ== X-Google-Smtp-Source: ABdhPJwaDCEq2PmFhwg76/x6fKTGXB1Im1noTBYi9pl4gmoPbTsfXNBKILjGmSRRSTT+Yg5CHU832WaiPIQvIFmIRFM= 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" X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 May 2021 18:50:39 -0000 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