linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/5] x86/umwait: Enable user wait instructions
@ 2019-06-07 22:00 Fenghua Yu
  2019-06-07 22:00 ` [PATCH v4 1/5] x86/cpufeatures: Enumerate " Fenghua Yu
                   ` (5 more replies)
  0 siblings, 6 replies; 40+ messages in thread
From: Fenghua Yu @ 2019-06-07 22:00 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H Peter Anvin,
	Andy Lutomirski, Ashok Raj, Tony Luck, Ravi V Shankar
  Cc: linux-kernel, x86, Fenghua Yu

Today, if an application needs to wait for a very short duration
they have to have spinloops. Spinloops consume more power and continue
to use execution resources that could hurt its thread siblings in a core
with hyperthreads. New instructions umonitor, umwait and tpause allow
a low power alternative waiting at the same time could improve the HT
sibling perform while giving it any power headroom. These instructions
can be used in both user space and kernel space.

A new MSR IA32_UMWAIT_CONTROL allows kernel to set a time limit in
TSC-quanta that prevents user applications from waiting for a long time.
This allows applications to yield the CPU and the user application
should consider using other alternatives to wait.

The processor supports two levels of optimized states: a light-weight
power/performance optimized state (C0.1 state) or an improved
power/performance optimized state (C0.2 state with deeper power saving
and higher exit latency). The above MSR can be used to restrict
entry to C0.2 and then any request for C0.2 will revert to C0.1.

This patch set covers feature discovery, provides initial values for
the MSR, adds some sysfs control files for admin to tweak the values
in the MSR if needed.

The sysfs interface files are in /sys/devices/system/cpu/umwait_control/

GCC 9 enables intrinsics for the instructions. To use the instructions,
user applications should include <immintrin.h> and be compiled with
-mwaitpkg.

Detailed information on the instructions, the MSR, and syntax of the
intrinsics can be found in the latest Intel Architecture Instruction
Set Extensions and Future Features Programming Reference and Intel 64
and IA-32 Architectures Software Developer's Manual.

Changelog:
v4:
- Error out when bit[1:0] in IA32_UMWAIT_CONTROL is not zero per
Andy Lutomirski's comment.
- Use umwait_control_cached to cache IA32_UMWAIT_CONTROL MSR. This
variable replaces the two previous variables umwait_max_time and
umwait_c0_2_enabled. The code is simpler than before and the cached MSR
will be easier to be used in future KVM support.

v3:
Address issues pointed out by Andy Lutomirski:
- Change default umwait max time to 100k TSC cycles
- Setting up MSR on BSP during resume suspend/hibernation
- A few other naming and coding changes as suggested
- Some security concerns of the user wait instructions are not issues
of the patches and cannot be addressed in the patch set. They will be
discussed on lkml.

Plus:
- Add ABI document entry for umwait control sysfs interfaces

v2:
- Address comments from Thomas Gleixner and Andy Lutomirski
- Remove vDSO functions
- Add sysfs control file for umwait max time

v1:
Based on comments from Thomas:
- Change user APIs to vDSO functions
- Changed sysfs per comments from Thomas.
- Change patch descriptions etc

Fenghua Yu (5):
  x86/cpufeatures: Enumerate user wait instructions
  x86/umwait: Initialize umwait control values
  x86/umwait: Add sysfs interface to control umwait C0.2 state
  x86/umwait: Add sysfs interface to control umwait maximum time
  x86/umwait: Document umwait control sysfs interfaces

 .../ABI/testing/sysfs-devices-system-cpu      |  21 ++
 arch/x86/include/asm/cpufeatures.h            |   1 +
 arch/x86/include/asm/msr-index.h              |   4 +
 arch/x86/power/Makefile                       |   1 +
 arch/x86/power/umwait.c                       | 182 ++++++++++++++++++
 5 files changed, 209 insertions(+)
 create mode 100644 arch/x86/power/umwait.c

-- 
2.19.1


^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2019-06-18  7:05 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-07 22:00 [PATCH v4 0/5] x86/umwait: Enable user wait instructions Fenghua Yu
2019-06-07 22:00 ` [PATCH v4 1/5] x86/cpufeatures: Enumerate " Fenghua Yu
2019-06-07 22:00 ` [PATCH v4 2/5] x86/umwait: Initialize umwait control values Fenghua Yu
2019-06-08 22:52   ` Andy Lutomirski
2019-06-10  4:13     ` Fenghua Yu
2019-06-10  4:27       ` Andy Lutomirski
2019-06-11 20:46       ` Thomas Gleixner
2019-06-17 20:46         ` Fenghua Yu
2019-06-18  5:43           ` Thomas Gleixner
2019-06-11  8:50   ` Peter Zijlstra
2019-06-11 17:04     ` Fenghua Yu
2019-06-07 22:00 ` [PATCH v4 3/5] x86/umwait: Add sysfs interface to control umwait C0.2 state Fenghua Yu
2019-06-08 22:50   ` Andy Lutomirski
2019-06-10  3:53     ` Fenghua Yu
2019-06-10  4:24       ` Andy Lutomirski
2019-06-10  6:02         ` Fenghua Yu
2019-06-10 13:41           ` Andy Lutomirski
2019-06-17 20:27             ` Fenghua Yu
2019-06-17 23:02               ` Andy Lutomirski
2019-06-17 23:11                 ` Fenghua Yu
2019-06-17 23:41                   ` Andy Lutomirski
2019-06-18  0:00                     ` Fenghua Yu
2019-06-18  0:19                       ` Andy Lutomirski
2019-06-18  2:32                         ` Fenghua Yu
2019-06-08 22:52   ` Andy Lutomirski
2019-06-10  4:04     ` Fenghua Yu
2019-06-10  4:26       ` Andy Lutomirski
2019-06-17 22:48         ` Fenghua Yu
2019-06-17 22:59           ` Andy Lutomirski
2019-06-17 22:51             ` Fenghua Yu
2019-06-11  8:54   ` Peter Zijlstra
2019-06-11 16:04     ` Andy Lutomirski
2019-06-11 17:27       ` Peter Zijlstra
2019-06-17 15:14         ` Andy Lutomirski
2019-06-17 18:11           ` Fenghua Yu
2019-06-07 22:00 ` [PATCH v4 4/5] x86/umwait: Add sysfs interface to control umwait maximum time Fenghua Yu
2019-06-07 22:00 ` [PATCH v4 5/5] x86/umwait: Document umwait control sysfs interfaces Fenghua Yu
2019-06-11  9:01 ` [PATCH v4 0/5] x86/umwait: Enable user wait instructions Peter Zijlstra
2019-06-11 17:37   ` Fenghua Yu
2019-06-17 14:19     ` Peter Zijlstra

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).