From: Aubrey Li <aubrey.li@intel.com>
To: tglx@linutronix.de, mingo@redhat.com, peterz@infradead.org,
hpa@zytor.com
Cc: ak@linux.intel.com, tim.c.chen@linux.intel.com,
dave.hansen@intel.com, arjan@linux.intel.com,
aubrey.li@intel.com, linux-kernel@vger.kernel.org,
Aubrey Li <aubrey.li@linux.intel.com>
Subject: [PATCH v6 1/3] x86/fpu: track AVX-512 usage of tasks
Date: Tue, 18 Dec 2018 12:22:16 +0800 [thread overview]
Message-ID: <20181218042218.8653-1-aubrey.li@intel.com> (raw)
User space tools which do automated task placement need information
about AVX-512 usage of tasks, because AVX-512 usage could cause core
turbo frequency drop and impact the running task on the sibling CPU.
The XSAVE hardware structure has bits that indicate when valid state
is present in registers unique to AVX-512 use. Use these bits to
indicate when AVX-512 has been in use and add per-task AVX-512 state
timestamp tracking to context switch.
Well-written AVX-512 applications are expected to clear the AVX-512
state when not actively using AVX-512 registers, so the tracking
mechanism is imprecise and can theoretically miss AVX-512 usage during
context switch. But it has been measured to be precise enough to be
useful under real-world workloads like tensorflow and linpack.
If higher precision is required, suggest user space tools to use the
PMU-based mechanisms in combination.
Signed-off-by: Aubrey Li <aubrey.li@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Arjan van de Ven <arjan@linux.intel.com>
---
arch/x86/include/asm/fpu/internal.h | 7 +++++++
arch/x86/include/asm/fpu/types.h | 7 +++++++
2 files changed, 14 insertions(+)
diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h
index a38bf5a1e37a..8778ac172255 100644
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -411,6 +411,13 @@ static inline int copy_fpregs_to_fpstate(struct fpu *fpu)
{
if (likely(use_xsave())) {
copy_xregs_to_kernel(&fpu->state.xsave);
+
+ /*
+ * AVX512 state is tracked here because its use is
+ * known to slow the max clock speed of the core.
+ */
+ if (fpu->state.xsave.header.xfeatures & XFEATURE_MASK_AVX512)
+ fpu->avx512_timestamp = jiffies_64;
return 1;
}
diff --git a/arch/x86/include/asm/fpu/types.h b/arch/x86/include/asm/fpu/types.h
index 202c53918ecf..81393dabdb46 100644
--- a/arch/x86/include/asm/fpu/types.h
+++ b/arch/x86/include/asm/fpu/types.h
@@ -302,6 +302,13 @@ struct fpu {
*/
unsigned char initialized;
+ /*
+ * @avx512_timestamp:
+ *
+ * Records the timestamp of AVX512 use during last context switch.
+ */
+ u64 avx512_timestamp;
+
/*
* @state:
*
--
2.17.1
next reply other threads:[~2018-12-18 11:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-18 4:22 Aubrey Li [this message]
2018-12-18 4:22 ` [PATCH v6 2/3] proc: add AVX-512 usage elapsed time to /proc/pid/status Aubrey Li
2018-12-18 4:22 ` [PATCH v6 3/3] Documentation/filesystems/proc.txt: add AVX512_elapsed_ms Aubrey Li
2018-12-18 14:14 ` [PATCH v6 1/3] x86/fpu: track AVX-512 usage of tasks Thomas Gleixner
2018-12-18 15:11 ` Li, Aubrey
2018-12-18 15:32 ` Thomas Gleixner
2018-12-18 16:28 ` Li, Aubrey
2018-12-18 21:38 ` Andi Kleen
2018-12-18 21:44 ` Dave Hansen
2018-12-18 22:05 ` Andi Kleen
2018-12-19 0:26 ` Li, Aubrey
2018-12-19 9:45 ` Thomas Gleixner
2018-12-18 17:14 ` Dave Hansen
2018-12-18 23:23 ` Li, Aubrey
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=20181218042218.8653-1-aubrey.li@intel.com \
--to=aubrey.li@intel.com \
--cc=ak@linux.intel.com \
--cc=arjan@linux.intel.com \
--cc=aubrey.li@linux.intel.com \
--cc=dave.hansen@intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=tim.c.chen@linux.intel.com \
/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