Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp886656pxj; Fri, 21 May 2021 01:12:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLKL2aZ2og8pr5YetxiyLwuo4jdKq0oLyegLU4ySgKlEkfVfWxwsOzdUefpHzcuE4e1bTB X-Received: by 2002:aa7:cd6b:: with SMTP id ca11mr9863101edb.115.1621584741626; Fri, 21 May 2021 01:12:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621584741; cv=none; d=google.com; s=arc-20160816; b=eepDgSEPxcAvhTiftye1FLtegc+ru7S7O6S/L5mmxYDtPVm9B1Hdh2qK0xCXrDdUsm bxatWG5dX+/vOmuTJmjhnMUbvVhd+0uLpO175N9If3zVLJFqE/OGyq/NU7WPfB9XM+QQ 178A22TZs2la+/nLAzlUgnRJbU2FcZqDSSQ02dRcb6hSODuyQzwOnke/9OKa8t6DUBYS fz6GAAnR+S3KUcrwYPbif9tqXWsXatY4ZYi+T+P8LJucPW0onoKOBzyklDk3HBZwdfDY t+P0hYS5vnd1pUimzkk/wjoITwbxA0L+sb68a/QoupMPaYm84eM0/TxsrrWmNGWnhwdA l1XQ== 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; bh=f/4LtIOBD6wxF9iMPhLoPX028a1rtI0NTUTVZTA+F+Y=; b=YOEBZ0TIgxEyqhK4hfBFcPtP08TTY3kQMS3Lg5EVdsDnjgzi0nustgof+Y3pJHQTlw 3oxsPaJfrNUQy572GgpHmC0ywB3XtMdbobVmr8QwaEzR9z9+DUh+nftcBmM+GsiOnoDf 1qNblS82hxuW8bx3F+jIhEOgMzRqj0FUrWjTw5ADmlhBea2Qf3vaRi2egvI8HZ8BVZcU 0Ur/NGDfM+2hlUuzx1beiWiVYEduhfyv1Q402fJrvgyS/8rZdXPAs311TaIUTjoIOb8b w+oDYjBq3VB4aKdTyJy6WNDZ9lkdDckbWlmMGPDxRlCME15gZ0QDvbcxxysfNWEfnOIW 3Lzw== ARC-Authentication-Results: i=1; mx.google.com; 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 g18si5119987edt.478.2021.05.21.01.11.57; Fri, 21 May 2021 01:12:21 -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; 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 S230320AbhETVnV (ORCPT + 99 others); Thu, 20 May 2021 17:43:21 -0400 Received: from mail-ed1-f50.google.com ([209.85.208.50]:42688 "EHLO mail-ed1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230300AbhETVnU (ORCPT ); Thu, 20 May 2021 17:43:20 -0400 Received: by mail-ed1-f50.google.com with SMTP id i13so21060287edb.9; Thu, 20 May 2021 14:41:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=f/4LtIOBD6wxF9iMPhLoPX028a1rtI0NTUTVZTA+F+Y=; b=e/66uxwhiRj7tkxVG5eko1XYFVp5SO5oyTL9gKy8ufon3KM7iqvREhclsOH/BLeG0f nqm+jUFb89AyeMXHfjbJ9SUD9lrBgXOVCTMSwK/xWuzj2gxw/aeCzFutUH3PlrsBxAYK umCTrbVBZzicVfdh+Q/JxKCw5dzEpqL6yoerQbjU/7XnaZKSl5Hk+XZ4lrf7FBH6unI4 gccxEVWQ1VxLlKWriCYlrTjxFmF/Fj/jFyc6x/d0qw/NAAZeW++JzEiRGChuQGfQ+XBy UAXlYNjISdAEV+IDmrRtdXwQQBBaH7K14RxefWAUilB+oG7eDDjYlwP5zOZLIkZKEPz6 8G7Q== X-Gm-Message-State: AOAM532P8K9Sro7ZIMuoD45tcbmgUMICkgEZG6Rk9QlN70IGNJqoxENw cLBuNDRTe/F7VKqwpwZx16oKq38A2xV/4B5xf1vGT3BI X-Received: by 2002:aa7:c6cd:: with SMTP id b13mr7100076eds.94.1621546917061; Thu, 20 May 2021 14:41:57 -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> <874kf11yoz.ffs@nanos.tec.linutronix.de> <87k0ntazyn.ffs@nanos.tec.linutronix.de> <37833625-3e6b-5d93-cc4d-26164d06a0c6@intel.com> In-Reply-To: <37833625-3e6b-5d93-cc4d-26164d06a0c6@intel.com> From: Len Brown Date: Thu, 20 May 2021 17:41:45 -0400 Message-ID: Subject: Re: Candidate Linux ABI for Intel AMX and hypothetical new related features To: Dave Hansen Cc: Thomas Gleixner , Borislav Petkov , Willy Tarreau , Andy Lutomirski , Florian Weimer , "Bae, Chang Seok" , X86 ML , LKML , Linux API , "libc-alpha@sourceware.org" , Rich Felker , Kyle Huey , Keno Fischer , Arjan van de Ven Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 20, 2021 at 5:13 PM Dave Hansen wrote: > >> Regarding error return for allocation failures. ... > * vmalloc() can fail (the memory.kmem cgroup limit is probably the most > likely place to be exposed to this) > * vmalloc() failure in a fault (like #NM) will result in SIGSEGV > * vmalloc() failure in a syscall can be handled with -ENOMEM Thanks for clarifying this, Dave. We added the explicit-allocate to v5, which should be on the list by tomorrow. So the questions are: 1. who calls it -- a call/thread or process? the application? a library -- which library? 2. is it optional, or mandatory? 3. if it is mandatory, what is the best way to enforce it? 4. should we have a "release" system call too? 1. Every thread needs a context switch buffer. Does every thread make the system call? It seems sort of awkward for a library to always make a system call before doing a TMUL. It would be functionally harmless, but it would add latency to an otherwise low-latency operation. If some central library does it, and caches that it has done it before, then it would be ugly, but at least it would remove an unnecessary user/kernel transition. 2. If it is optional, then v5 is code complete -- because it allows you to allocate either explicitly via prtcl, or transparently via #NM. 3. If it is mandatory, then we should re-purpose the XFD mechanism: app starts with XFD armed, by default if app touches AMX before prctl, it takes a signal (and dies). When app calls prctl, allocate buffer disarm XFD for that app (exactly what #NM trap does today). 4. I don't see a justification for a release concept, but it is possible -- though sort of sticky with possible nested calls from combinations of apps and libraries. If that were sorted out by a central library, then the actual system call on the last release per thread would re-arm XFD to prevent access until the next explicit request. Unclear if it is important that the kernel actually do the free -- some things might run faster if we keep it around... Len Brown, Intel Open Source Technology Center