Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1090497ybi; Fri, 24 May 2019 17:07:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyuU6DWmYP+OFxBMjIPwkH0tJiRNZa8xOWBoJ3bGHttlOXtB9t+8atWH3PB6AS+znYmUoyE X-Received: by 2002:a65:56cb:: with SMTP id w11mr89271389pgs.236.1558742874154; Fri, 24 May 2019 17:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558742874; cv=none; d=google.com; s=arc-20160816; b=wXXzeOjzRlmJ6cTjfuztiCP3RTkaV+BbW6sbO3spz2Fl2A9oJztnf8YaHYLXX2Jxk3 yHfqobqB5NZq1cA/Rcl7KcdyF/0Ji3rSC8ACprMYAKvBhw8EKQEcYq9KVGhNdIjTEIZW TI5QyryR2ESlgOuUtJEvvOwKFP0kCefBS+cpQt8T6jIYAZhOs3lO/4EEUHmFUqPMwjQS ONyHUldeTnwFl8yDfT8MmKHW783Ttl9CTkZMf/94Vs0RsLELYUZ8xRJv3xHcJ8VhKzFu I4YsYZhzmvlLSeAajg7+zt+k2BzztgCA2q++ERYKIV2ygW1wt47ZSXOR/CX2TeERzui9 VCyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=dD68gZinzH+yO5be0C9nP+B81LnMem6+XbrHy4Ti9bQ=; b=o6RLOuz7XlBHduba9gx4SUUDT7ZknoDgO8eCHA9ziT5vJRZStD2pIWEePaRPy1TnYJ xBDL4TUFlMi7sHDwLvPURF9w0TjrAc/5t9G+RETaeLnQjarkpqQULZjdtOL2E73TLudT p00+dlNM1ELkvXMIt3x15taFyVAxnbW+V84KvexlmVG2bx03FEvo0xrnnJA9rs0innie kYiGKj2VnNi507PUwgbTOT85ZfQKyLlBEIeD0UG2RWNe7L84DrCDuhk1N5qN15sdMnkn zXPMU9wveCcX4AIBrt+Hl1h1CXAByT6+kuslPuIGDXcQRFHcXfuKNnHRJdXgRoC0aQ/G VpKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v23si6495101pgi.527.2019.05.24.17.07.39; Fri, 24 May 2019 17:07:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726191AbfEYAFQ (ORCPT + 99 others); Fri, 24 May 2019 20:05:16 -0400 Received: from mga01.intel.com ([192.55.52.88]:36240 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725996AbfEYAFQ (ORCPT ); Fri, 24 May 2019 20:05:16 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 May 2019 17:05:15 -0700 X-ExtLoop1: 1 Received: from romley-ivt3.sc.intel.com ([172.25.110.60]) by orsmga005.jf.intel.com with ESMTP; 24 May 2019 17:05:15 -0700 From: Fenghua Yu To: "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "H Peter Anvin" , "Andy Lutomirski" , "Andrew Cooper" , "Ashok Raj" , "Tony Luck" , "Ravi V Shankar" Cc: "linux-kernel" , "x86" , Fenghua Yu Subject: [PATCH v3 0/5] x86/umwait: Enable user wait instructions Date: Fri, 24 May 2019 16:55:57 -0700 Message-Id: <1558742162-73402-1-git-send-email-fenghua.yu@intel.com> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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: 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 | 179 ++++++++++++++++++ 5 files changed, 206 insertions(+) create mode 100644 arch/x86/power/umwait.c -- 2.19.1