OSDN Git Service

x86/umwait: Initialize umwait control values
authorFenghua Yu <fenghua.yu@intel.com>
Thu, 20 Jun 2019 01:33:55 +0000 (18:33 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Sun, 23 Jun 2019 23:44:19 +0000 (01:44 +0200)
commitbd688c69b7e6693de3bd78f38fd63f7850c2711e
treeb611589e854e152a015e34aae595bd5b4fdb32a5
parent6dbbf5ec9e1e9f607a4c51266d0f9a63ba754b63
x86/umwait: Initialize umwait control values

umwait or tpause allows the processor to enter a light-weight
power/performance optimized state (C0.1 state) or an improved
power/performance optimized state (C0.2 state) for a period specified by
the instruction or until the system time limit or until a store to the
monitored address range in umwait.

IA32_UMWAIT_CONTROL MSR register allows the OS to enable/disable C0.2 on
the processor and to set the maximum time the processor can reside in C0.1
or C0.2.

By default C0.2 is enabled so the user wait instructions can enter the
C0.2 state to save more power with slower wakeup time.

Andy Lutomirski proposed to set the maximum umwait time to 100000 cycles by
default. A quote from Andy:

  "What I want to avoid is the case where it works dramatically differently
   on NO_HZ_FULL systems as compared to everything else. Also, UMWAIT may
   behave a bit differently if the max timeout is hit, and I'd like that
   path to get exercised widely by making it happen even on default
   configs."

A sysfs interface to adjust the time and the C0.2 enablement is provided in
a follow up change.

[ tglx: Renamed MSR_IA32_UMWAIT_CONTROL_MAX_TIME to
   MSR_IA32_UMWAIT_CONTROL_TIME_MASK because the constant is used as
   mask throughout the code.
Massaged comments and changelog ]

Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Ashok Raj <ashok.raj@intel.com>
Reviewed-by: Andy Lutomirski <luto@kernel.org>
Cc: "Borislav Petkov" <bp@alien8.de>
Cc: "H Peter Anvin" <hpa@zytor.com>
Cc: "Peter Zijlstra" <peterz@infradead.org>
Cc: "Tony Luck" <tony.luck@intel.com>
Cc: "Ravi V Shankar" <ravi.v.shankar@intel.com>
Link: https://lkml.kernel.org/r/1560994438-235698-3-git-send-email-fenghua.yu@intel.com
arch/x86/include/asm/msr-index.h
arch/x86/kernel/cpu/Makefile
arch/x86/kernel/cpu/umwait.c [new file with mode: 0644]