Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp346432pxv; Wed, 30 Jun 2021 07:01:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRYbv3xH6LvERwLpw8AkKKpLYrZ0KuIDvdhxtzxARw19y2n9T0czUHjA9A+lIDm0NHNdny X-Received: by 2002:a05:6000:1842:: with SMTP id c2mr39249919wri.426.1625061711293; Wed, 30 Jun 2021 07:01:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625061711; cv=none; d=google.com; s=arc-20160816; b=kuH4MFDyBPBvA2o8N5CIMvYkrz/UXtaMiAhq7mRgGKTbBWqrIE07G7gOPPVMtmDhfD WeZRKzv0mLV0fQb5cZ+yt4Cke3BlyAXEzEzgvgtyPcv5o9ncDHcYiawIEfgPhnTq5/5F KL5Xm0k9e91803c0sqQaazJ04ZmDh/3hZlU9ieOdURv2dutkHiYdJmcrd+eueGaZDcfB vqPxlvAmcfDu8lESHYZggeoVmvADbAXrFkSEuoRb0MT1aOA2CRKilSIV0kwZPnbzHkpt nqE4f+J4MBqcqg/WBM1xgclEDrXRNpZ5xfN6/v6jgNKLShYn2Fi+wOx2qceYzCubMlN0 EyIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=ryJMWFsMBGWTHYwXX6f94Yvaxu1LMrrKMrA22wo6Wq0=; b=kMrbti871eFbKkHn615H2ICkLZixb8kHZto/nZy7hB74pz5OSSmc4HsGQYzkxmPEbQ giq1xEODWMgPHOTmzvBhfqPrag9zY4T2HB1Hcl+oacUrVC9Zq+J14fgoiky9LHgUeGeW 7jvGoTw2gk1dF6FGHOf6UxOF1r/yRCKsq/RNNGHrbgXojfC+oRI1m/YheHDMoMV8p6cJ ycE4asJPev2Msuga5D0CgQ3kHzoXSpMbuAJ2Dzw/7jKyDPMouzFM0PYOwm/64lzUPdWH QO6DHRArLIaueNRWYdf1YpyDn9NM5cUBlEyS8zGnwlVpPCKdWBnbCymVUBhtKZUPRNym XqfA== 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bz7si19872888ejc.650.2021.06.30.07.01.20; Wed, 30 Jun 2021 07:01:51 -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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235860AbhF3OBa (ORCPT + 99 others); Wed, 30 Jun 2021 10:01:30 -0400 Received: from mga17.intel.com ([192.55.52.151]:33469 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234935AbhF3OAq (ORCPT ); Wed, 30 Jun 2021 10:00:46 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10030"; a="188729655" X-IronPort-AV: E=Sophos;i="5.83,312,1616482800"; d="scan'208";a="188729655" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2021 06:55:54 -0700 X-IronPort-AV: E=Sophos;i="5.83,312,1616482800"; d="scan'208";a="641716350" Received: from vkodithy-mobl.amr.corp.intel.com (HELO [10.209.94.253]) ([10.209.94.253]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2021 06:55:53 -0700 Subject: Re: Candidate Linux ABI for Intel AMX and hypothetical new related features To: "Enrico Weigelt, metux IT consult" , Florian Weimer Cc: Len Brown , Peter Zijlstra , Dave Hansen via Libc-alpha , Dave Hansen , Rich Felker , Linux API , "Bae, Chang Seok" , X86 ML , LKML , Kyle Huey , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , Keno Fischer , Willy Tarreau References: <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> <87wnqkzklg.fsf@oldenburg.str.redhat.com> <93e3b500-5992-a674-18e6-445d1db7b1f0@metux.net> <87tulirw5y.fsf@oldenburg.str.redhat.com> <84be3cfd-e825-ae75-bbae-2bbd3360daa7@metux.net> From: Arjan van de Ven Message-ID: <0978e79c-33ad-c05b-3897-99334c381396@linux.intel.com> Date: Wed, 30 Jun 2021 06:55:52 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <84be3cfd-e825-ae75-bbae-2bbd3360daa7@metux.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/30/2021 5:22 AM, Enrico Weigelt, metux IT consult wrote: >> >> AMX will be shown as enabled in the hardware, but trap into the kernel >> on first use.  The kernel developers prefer a model where it is checked >> that the process has previously enabled the feature explicitly, instead >> relying on lazy initialization as part of the trap (as intended by the >> hardware design).  This means that the usual CPUID/XCR0 approach (which >> is reflected in the glibc feature) will not work. > > Ah, now I'm beginning to get it: > > * this feature needs to be initialized first, before it can be used > * on first use (when not initialized yet), it traps into the kernel > * we don't want to always initialize it at boot > > Correct ? not really, the init is PER PROCESS and then there is a per thread 8Kb state allocation that needs to be context switched/etc once you actually use AMX. > > What I'm wondering: why shall the process explicitly ask for it and > why isn't the initialization be done either on bootup or on first use ? the kernel needs to be able to say "no" in a graceful way, there are several scenarios (from the sysadmin wanting to manage power/performance/resources to outright compatibility where the kernel wants or needs to say "no". Most obvious example: if a process asked for an sigaltstack, we can't let the process use AMX since that stack will be too small most likely to hold the stackframe) If you do this on "first use of the instruction" there is no graceful way to say "no".