Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4519504pxf; Tue, 30 Mar 2021 09:40:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJYE1Gxtyr94QiWu9iZ2M1qVNPU9rZwiqsnzcJDwzus5owUbCQAAJ10L7WklWMHftk45am X-Received: by 2002:a17:906:1408:: with SMTP id p8mr33660156ejc.89.1617122426231; Tue, 30 Mar 2021 09:40:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617122426; cv=none; d=google.com; s=arc-20160816; b=b6EYH5VYCs2RyDgxKdDmgeEkrc7KQCRiuY9p7UHFdvE0tLIfNTL28mWlLCe7g5tcXX jZwEEfJ1elsr4jyD+U2I1AUI1O0pMJqS0F1tTPlRwV3tFX3HWi5iA9RoY5KOIQNvvrZo EjBFQQZlNUNdD745QYYpuKlTZXpBaWpLxZ2A3OBoRW8HBF40+OeKwKgM+QI6Vdo7hvrS BY3kt59qMxP/Ke8Hzzn0FEB/eSirc6B9M3zsnExg2nzARwKuNPG95wL0OEXXj8cIQWNQ yNk5nuox1WgNRAOzFfQIV934coRW9wRma66yBIhE/fXsCKTcyFNfNMQ+Q8et25jvP2C8 g8sA== 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=brTbFJ3l/AhVj/GuXWRgZxcXsdvUH+rOgnTlTOkQOkQ=; b=CuQIrq6WRL/j+TP63QVDxYVi40/GfmjMZ4QIUjdzTxfn314eUBavx5FCskf4pr0355 mbfvJIh+Leu6kcYw/nLjAyFAdi0M43N6talGxnsBzk+Lem8lr1ZPuGXZ6n/OnLmvPzGn 5MwmuQDCtec6KuCLn+8Qb3HiDlaaOwZVk0rBZ24/4S8NrLux7Q1SvdOGMxS9jU2+SIxF /Nv/8qUjhQH1HYEt+2A1DgzdT6iOaIMJNuGL9yjEdRXxz4ocjTSWKUwL7iJTGGN7RvSQ GuLjKaJcWdyQXwudl56iXVkdCjq/tsDzUy87njUGqbFAfIadjet1R9WxjsHRIvg8y3ri RFQA== 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 cw1si15162333edb.412.2021.03.30.09.40.03; Tue, 30 Mar 2021 09:40:26 -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 S232001AbhC3QjF (ORCPT + 99 others); Tue, 30 Mar 2021 12:39:05 -0400 Received: from mail-ej1-f49.google.com ([209.85.218.49]:40812 "EHLO mail-ej1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232340AbhC3Qib (ORCPT ); Tue, 30 Mar 2021 12:38:31 -0400 Received: by mail-ej1-f49.google.com with SMTP id u9so25772498ejj.7 for ; Tue, 30 Mar 2021 09:38:30 -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=brTbFJ3l/AhVj/GuXWRgZxcXsdvUH+rOgnTlTOkQOkQ=; b=tzeh7+ZC5tdYwdXTYB5Ul0P2vaSif5LygpdbG+8vo+2tbHmJdcy/aX0/wl0kwsO0Kk ieA1o34kBw02T5qSQxPQz5ZoGewVWFhqQlV6nrc8cpO8FvkR1NHvMaNsj++BIS/UyrK4 KLm0zxExxGDka+8lnNiUlYDYapYLkqEeJtqqF7BA3JjgdkZIF2sZ85zfhwTVYBoodBC9 W2cJThIRjhwYpuAy9I1+A85tcada+Q/Exc+NAl+Mi0FgaP0ivG17wM/Q0V2ALIyNi2Su as0VRZWxzyDxE9osUO1mUEt4w/wCJ78UO+fX9FmSn0J9wnyi8HesiaKwziDH3haEybP6 gnrA== X-Gm-Message-State: AOAM530k63kKCOdhL0ydRDhcVWJcH/MxIwG3nhZt8/TtImWBo4PpzL9v Ttob6fE0rWE/Iul54ZZup2HnAltmx3HRPeMkL1U= X-Received: by 2002:a17:906:340f:: with SMTP id c15mr21573839ejb.317.1617122310278; Tue, 30 Mar 2021 09:38:30 -0700 (PDT) MIME-Version: 1.0 References: <20210221185637.19281-1-chang.seok.bae@intel.com> <20210221185637.19281-15-chang.seok.bae@intel.com> <87o8fda2ye.fsf@nanos.tec.linutronix.de> <87r1jyaxum.ffs@nanos.tec.linutronix.de> <87ft0d7q2q.ffs@nanos.tec.linutronix.de> <8735wd6o67.ffs@nanos.tec.linutronix.de> In-Reply-To: <8735wd6o67.ffs@nanos.tec.linutronix.de> From: Len Brown Date: Tue, 30 Mar 2021 12:38:19 -0400 Message-ID: Subject: Re: [PATCH v4 14/22] x86/fpu/xstate: Expand the xstate buffer on the first use of dynamic user state To: Thomas Gleixner Cc: "Chang S. Bae" , Borislav Petkov , Andy Lutomirski , Ingo Molnar , X86 ML , "Brown, Len" , Dave Hansen , "Liu, Jing2" , "Ravi V. Shankar" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 30, 2021 at 4:28 AM Thomas Gleixner wrote: > > Len, > > On Mon, Mar 29 2021 at 18:16, Len Brown wrote: > > On Mon, Mar 29, 2021 at 2:49 PM Thomas Gleixner wrote: > > Let me know if this problem description is fair: > > > > Many-core Xeon servers will support AMX, and when I run an AMX application > > on one, when I take an interrupt with AMX INIT=0, Linux may go idle on my CPU. > > If Linux cpuidle requests C6, the hardware will demote to C1E. > > > > The concern is that a core in C1E will negatively impact power of > > self, or performance > > of a neighboring core. > > > > This is what we are talking about, right? > > Correct. > > > I'm delighted that there are Xeon customers, who care about this power savings. > > Unfortunately, they are the exception, not the rule. > > That maybe true or not. The point is that there is some side effect and > from a correctness point of view it needs to be addressed. I don't see how demoting C6 to C1E is a "correctness" issue. There is nothing "incorrect" about demoting to C1E when software permits C6, and as I mentioned, this happens all the time. All architectural state, including the AMX state, is preserved by hardware. I do agree that there is the possibility that this scenario can result may not be optimal power savings. It isn't clear how often that situation might occur. > >> - Use TILERELEASE on context switch after XSAVES? > > > > Yes, that would be perfectly reasonable. > > > >> - Any other mechanism on context switch > > > > XRESTOR of a context with INIT=1 would also do it. > > > >> - Clear XFD[18] when going idle and issue TILERELEASE depending > >> on the last state > > > > I think you mean to *set* XFD. > > When the task touched AMX, he took a #NM, and we cleared XFD for that task. > > So when we get here, XFD is already clear (unarmed). > > Nevertheless, the setting of XFD is moot here. > > No. We set XFD when the task which used AMX schedules out. If the CPU > reaches idle without going back to user space then XFD is still set and > AMX INIT still 0. So my assumption was that in order to issue > TILERELEASE before going idle, you need to clear XFD[18] first, but I > just saw in the spec that it is not necessary. Right, XFD setting is moot here. > >> - Use any other means to set the thing back into INIT=1 state when > >> going idle > > > > TILERELEASE and XRESTOR are the tools in the toolbox, if necessary. > > > >> There is no option 'shrug and ignore' unfortunately. > > > > I'm not going to say it is impossible that this path will matter. > > If some terrible things go wrong with the hardware, and the hardware > > is configured and used in a very specific way, yes, this could matter. > > So then let me summarize for the bare metal case: > > 1) The paragraph in the specification is unclear and needs to be > rephrased. > > What I understood from your explanations so far: > > When AMX is disabled by clearing XCR0[18:17], by clearing > CR4.OSXSAVE, or by setting IA32_XFD[18], then there are no > negative side effects due to AMX INIT=0 as long as the CPU is > executing. Right. > The only possible side effect is when the CPU goes idle because > AMX INIT=0 limits C states. Right. > 2) As a consequence of #1 there is no further action required on > context switch when XFD[18] is set. I agree. > 3) When the CPU goes idle with AMX INIT=0 then the idle code should > invoke TILERELEASE. Maybe the condition is not even necessary and > TILERELEASE can be invoked unconditionally before trying to enter > idle. > > If that's correct, then this should be part of the next series. If you insist, then that is fine with me. Personally, I would prefer to be able to measure an actual benefit before adding code, but this one is small, and so I'm not religious about it. > > In the grand scheme of things, this is a pretty small issue, say, > > compared to the API discussion. > > No argument about that. > > Thanks, > > tglx -- Len Brown, Intel Open Source Technology Center