Skip to content

x86/xsaves: Optimize xstate context switch by xsaves/xrstors

Fenghua Yu lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest15 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/15x86/xsaves: Detect xsaves/xrstors featurearch/x86/include/asm/cpufeature.h arch/x86/include/uapi/asm/msr-index.h arch/x86/kernel/cpu/scattered.c+5 -00 replies
2/15x86/xsaves: Add kernel parameter to disable xsaves/xrstorsDocumentation/kernel-parameters.txt arch/x86/kernel/cpu/common.c+17 -00 replies
3/15x86/alternative: Add alternative_input_2arch/x86/include/asm/alternative.h+13 -00 replies
4/15x86/xsaves: Change compacted format xsave area headerarch/x86/include/asm/processor.h+2 -20 replies
5/15x86/xsaves: Define macros for xsave instructionsarch/x86/include/asm/xsave.h+6 -00 replies
6/15x86/xsaves: Define macro for handle xsave/xrstor faultarch/x86/include/asm/xsave.h+7 -00 replies
7/15x86/xsaves: Use xsaves/xrstors for saving and restoring xsave areaarch/x86/include/asm/xsave.h+62 -200 replies
8/15x86/xsaves: Use xsaves/xrstors for context switcharch/x86/include/asm/xsave.h+12 -250 replies
9/15x86/xsaves: Use xsave/xrstor for saving and restoring user space contextarch/x86/include/asm/xsave.h+18 -150 replies
10/15x86/xsaves: Clear reserved bits in xsave headerarch/x86/kernel/i387.c+1 -10 replies
11/15x86/xsaves: Add xsaves and xrstors support for booting timearch/x86/include/asm/xsave.h+60 -00 replies
12/15x86/xsaves: Save xstate to task's xsave area in __save_fpu during booting timearch/x86/include/asm/fpu-internal.h+6 -30 replies
13/15x86/xsaves: Call booting time xsaves and xrstors in setup_init_fpu_bufarch/x86/kernel/xsave.c+8 -20 replies
14/15x86/xsaves: Enable xsaves/xrstorsarch/x86/kernel/xsave.c+32 -60 replies
15/15Define kernel API to get address of each state in xsave areaarch/x86/include/asm/xsave.h arch/x86/kernel/process.c arch/x86/kernel/xsave.c+68 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/15] x86/xsaves: Optimize xstate context switch by xsaves/xrstors

From: Fenghua Yu <[email protected]>

With ever growing extended state registers (xstate) on x86 processors, kernel needs to cope with issue of growing memory space occupied by xstate. The xsave area is holding more and more xstate registers, growing from legacy FP and SSE to AVX, AVX2, AVX-512, MPX, and Intel PT.

The recently introduced compacted format of xsave area saves xstates only for enabled states. This patch set saves the xsave area space per process in compacted format by xsaves/xrstors instructions.

xsaves/xrstors also supports modified optimization which tracks modified xstates and only saves modified xstates to xsave area to improve saving performance.

For more information about xsaves/xrstors instructions, please refer to latest Intel X86 SDM.

Fenghua Yu (15):
x86/xsaves: Detect xsaves/xrstors feature
x86/xsaves: Add kernel parameter to disable xsaves/xrstors x86/alternative: Add alternative_input_2
x86/xsaves: Change compacted format xsave area header x86/xsaves: Define macros for xsave instructions x86/xsaves: Define macro for handle xsave/xrstor fault x86/xsaves: Use xsaves/xrstors for saving and restoring xsave area x86/xsaves: Use xsaves/xrstors for context switch x86/xsaves: Use xsave/xrstor for saving and restoring user space
context
x86/xsaves: Clear reserved bits in xsave header x86/xsaves: Add xsaves and xrstors support for booting time x86/xsaves: Save xstate to task's xsave area in __save_fpu during
booting time
x86/xsaves: Call booting time xsaves and xrstors in setup_init_fpu_buf x86/xsaves: Enable xsaves/xrstors
Define kernel API to get address of each state in xsave area

 Documentation/kernel-parameters.txt   |   9 ++
 arch/x86/include/asm/alternative.h    |  13 ++
 arch/x86/include/asm/cpufeature.h     |   2 +
 arch/x86/include/asm/fpu-internal.h   |   9 +-
 arch/x86/include/asm/processor.h      |   4 +-
 arch/x86/include/asm/xsave.h          | 220 +++++++++++++++++++++++++---------
 arch/x86/include/uapi/asm/msr-index.h |   2 +
 arch/x86/kernel/cpu/common.c          |   8 ++
 arch/x86/kernel/cpu/scattered.c       |   1 +
 arch/x86/kernel/i387.c                |   2 +-
 arch/x86/kernel/process.c             |   1 +
 arch/x86/kernel/xsave.c               | 112 +++++++++++++++--
 12 files changed, 313 insertions(+), 70 deletions(-)
Signature · 1 line
1.8.1.2