From: Noah Goldstein <goldstein.w.n@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: goldstein.w.n@gmail.com, tglx@linutronix.de, mingo@redhat.com,
bp@alien8.de, x86@kernel.org, hpa@zytor.com, luto@kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v1] x86/fpu: Remove opmask state from avx512_timestamp check
Date: Mon, 20 Sep 2021 00:39:53 -0500 [thread overview]
Message-ID: <20210920053951.4093668-1-goldstein.w.n@gmail.com> (raw)
This commit creates a new mask, XFEATURE_MASK_ZMM, to test against
xfeatures for conditionally updating the axx512_timestamp.
Based on the comments, the avx512 state is meant to track when the
state would cause frequencey throttling. The opmasks (k0-k7) do not
cause frequency throttling, so they don't make sense to include.
The current implementation, as well as the old, still does have a
false positive on ymm16-ymm31 and xmm16-31 because
XFEATURE_MASK_Hi16_ZMM includes them.
Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
---
Issue is reproducible with the following code on x86_64:
```
.global _start
.text
_start:
korq %k0, %k0, %k0
loop:
jmp loop
movl $60, %eax
xorl %edi, %edi
syscall
```
Pretending run as executable named "foo":
$> cat /proc/$(pidof foo)/arch_status
This should yield -1 as no frequency changing AVX512 instructions
where used but instead tracks the process.
Note there still is a false positive with ymm16-ymm31 and xmm16-xmm31
but since there is no state to distinguish between there use and
zmm16-31 that seems inevitable.
arch/x86/include/asm/fpu/types.h | 2 ++
arch/x86/kernel/fpu/core.c | 4 +++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/fpu/types.h b/arch/x86/include/asm/fpu/types.h
index f5a38a5f3ae1..a4816fa7d541 100644
--- a/arch/x86/include/asm/fpu/types.h
+++ b/arch/x86/include/asm/fpu/types.h
@@ -141,6 +141,8 @@ enum xfeature {
#define XFEATURE_MASK_AVX512 (XFEATURE_MASK_OPMASK \
| XFEATURE_MASK_ZMM_Hi256 \
| XFEATURE_MASK_Hi16_ZMM)
+#define XFEATURE_MASK_ZMM (XFEATURE_MASK_ZMM_Hi256 \
+ | XFEATURE_MASK_Hi16_ZMM)
#define FIRST_EXTENDED_XFEATURE XFEATURE_YMM
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index 7ada7bd03a32..342620a2e8ef 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -104,8 +104,10 @@ void save_fpregs_to_fpstate(struct fpu *fpu)
/*
* AVX512 state is tracked here because its use is
* known to slow the max clock speed of the core.
+ * Note: This has a false positive on Hi16 ymm and
+ * xmm registers.
*/
- if (fpu->state.xsave.header.xfeatures & XFEATURE_MASK_AVX512)
+ if (fpu->state.xsave.header.xfeatures & XFEATURE_MASK_ZMM)
fpu->avx512_timestamp = jiffies;
return;
}
--
2.25.1
next reply other threads:[~2021-09-20 5:40 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-20 5:39 Noah Goldstein [this message]
2021-09-27 18:02 ` [PATCH v1] x86/fpu: Remove opmask state from avx512_timestamp check Noah Goldstein
2021-10-13 22:36 ` Noah Goldstein
2021-10-14 8:28 ` Borislav Petkov
2021-10-14 15:49 ` Noah Goldstein
2021-10-15 14:40 ` Borislav Petkov
2021-10-15 15:25 ` Dave Hansen
2021-10-15 17:30 ` Noah Goldstein
2021-10-15 20:47 ` [PATCH v2 1/2] x86/fpu: Add helper function for tracking AVX512 status Noah Goldstein
2021-10-26 23:15 ` Noah Goldstein
2021-10-15 20:47 ` [PATCH v2 2/2] x86/xstate: Make AVX512 status tracking more accurate Noah Goldstein
2021-10-27 11:07 ` Borislav Petkov
2021-10-27 16:28 ` Noah Goldstein
2021-10-27 16:58 ` Borislav Petkov
2021-10-27 17:18 ` Noah Goldstein
2021-10-27 16:26 ` [PATCH v3 1/2] x86/fpu: Add helper function for tracking AVX512 status Noah Goldstein
2021-10-27 16:26 ` [PATCH v3 2/2] x86/xstate: Make AVX512 status tracking more accurate Noah Goldstein
2021-10-27 17:11 ` Borislav Petkov
2021-10-27 17:37 ` Noah Goldstein
2021-10-27 17:45 ` Borislav Petkov
2021-10-27 18:21 ` Noah Goldstein
2021-11-03 20:22 ` Noah Goldstein
2021-11-03 20:48 ` Borislav Petkov
2021-11-03 20:56 ` Noah Goldstein
2021-10-27 17:17 ` [PATCH v4 1/2] x86/fpu: Add helper function for tracking AVX512 status Noah Goldstein
2021-10-27 17:17 ` [PATCH v4 2/2] x86/xstate: Make AVX512 status tracking more accurate Noah Goldstein
2021-10-27 18:21 ` [PATCH v5 1/2] x86/fpu: Add helper function for tracking AVX512 status Noah Goldstein
2021-10-27 18:21 ` [PATCH v5 2/2] x86/xstate: Make AVX512 status tracking more accurate Noah Goldstein
2021-11-16 16:21 ` [PATCH] x86/fpu: Correct AVX512 state tracking Borislav Petkov
2021-11-16 16:49 ` Noah Goldstein
2021-11-17 18:29 ` [tip: x86/fpu] " tip-bot2 for Noah Goldstein
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210920053951.4093668-1-goldstein.w.n@gmail.com \
--to=goldstein.w.n@gmail.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).