aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2018-06-03 04:11:50 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2018-06-03 04:11:50 -0400
commitba8042a85e8aebc8043deee2d396459f2c39a66d (patch)
treed49d006d853267469de3fda52d4f031afb476061
parentb04e217704b7f879c6b91222b066983a44a7a09f (diff)
parent201d4f50fef3c10856022b21cfd9fd81358a62ef (diff)
Merge branch 'turbostat' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux
Pull turbostat utility updates for v4.18 from Len Brown. * 'turbostat' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux: (65 commits) tools/power turbostat: update version number tools/power turbostat: Add Node in output tools/power turbostat: add node information into turbostat calculations tools/power turbostat: remove num_ from cpu_topology struct tools/power turbostat: rename num_cores_per_pkg to num_cores_per_node tools/power turbostat: track thread ID in cpu_topology tools/power turbostat: Calculate additional node information for a package tools/power turbostat: Fix node and siblings lookup data tools/power turbostat: set max_num_cpus equal to the cpumask length tools/power turbostat: if --num_iterations, print for specific number of iterations tools/power turbostat: Add Cannon Lake support tools/power turbostat: delete duplicate #defines x86: msr-index.h: Correct SNB_C1/C3_AUTO_UNDEMOTE defines tools/power turbostat: Correct SNB_C1/C3_AUTO_UNDEMOTE defines tools/power turbostat: add POLL and POLL% column tools/power turbostat: Fix --hide Pk%pc10 tools/power turbostat: Build-in "Low Power Idle" counters support tools/power turbostat: Don't make man pages executable tools/power turbostat: remove blank lines tools/power turbostat: a small C-states dump readability immprovement ...
-rw-r--r--MAINTAINERS9
-rw-r--r--arch/nds32/Kconfig7
-rw-r--r--arch/nds32/Kconfig.cpu5
-rw-r--r--arch/nds32/Makefile7
-rw-r--r--arch/nds32/include/asm/Kbuild2
-rw-r--r--arch/nds32/include/asm/bitfield.h3
-rw-r--r--arch/nds32/include/asm/cacheflush.h2
-rw-r--r--arch/nds32/include/asm/io.h2
-rw-r--r--arch/nds32/include/asm/page.h3
-rw-r--r--arch/nds32/include/asm/pgtable.h1
-rw-r--r--arch/nds32/kernel/ex-entry.S2
-rw-r--r--arch/nds32/kernel/head.S28
-rw-r--r--arch/nds32/kernel/setup.c3
-rw-r--r--arch/nds32/kernel/stacktrace.c2
-rw-r--r--arch/nds32/kernel/vdso.c10
-rw-r--r--arch/nds32/lib/copy_page.S3
-rw-r--r--arch/nds32/mm/alignment.c9
-rw-r--r--arch/nds32/mm/cacheflush.c74
-rw-r--r--arch/nds32/mm/init.c1
-rw-r--r--arch/s390/purgatory/Makefile2
-rw-r--r--arch/x86/include/asm/msr-index.h4
-rw-r--r--drivers/crypto/inside-secure/safexcel.c4
-rw-r--r--drivers/input/mouse/elan_i2c_smbus.c22
-rw-r--r--drivers/input/mouse/synaptics.c6
-rw-r--r--drivers/nvme/host/core.c2
-rw-r--r--drivers/platform/x86/asus-wmi.c23
-rw-r--r--drivers/s390/block/dasd.c7
-rw-r--r--fs/afs/security.c10
-rw-r--r--fs/afs/vlclient.c19
-rw-r--r--fs/inode.c1
-rw-r--r--kernel/trace/trace.c12
-rw-r--r--kernel/trace/trace.h11
-rw-r--r--kernel/trace/trace_events_trigger.c15
-rw-r--r--security/selinux/ss/services.c2
-rw-r--r--tools/power/x86/turbostat/Makefile2
-rw-r--r--tools/power/x86/turbostat/turbostat.826
-rw-r--r--tools/power/x86/turbostat/turbostat.c908
-rw-r--r--tools/power/x86/x86_energy_perf_policy/Makefile2
38 files changed, 894 insertions, 357 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index ca4afd68530c..0d00b6c5370b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14371,6 +14371,15 @@ S: Maintained
14371F: drivers/tc/ 14371F: drivers/tc/
14372F: include/linux/tc.h 14372F: include/linux/tc.h
14373 14373
14374TURBOSTAT UTILITY
14375M: "Len Brown" <lenb@kernel.org>
14376L: linux-pm@vger.kernel.org
14377B: https://bugzilla.kernel.org
14378Q: https://patchwork.kernel.org/project/linux-pm/list/
14379T: git git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux.git turbostat
14380S: Supported
14381F: tools/power/x86/turbostat/
14382
14374TW5864 VIDEO4LINUX DRIVER 14383TW5864 VIDEO4LINUX DRIVER
14375M: Bluecherry Maintainers <maintainers@bluecherrydvr.com> 14384M: Bluecherry Maintainers <maintainers@bluecherrydvr.com>
14376M: Anton Sviridenko <anton@corp.bluecherry.net> 14385M: Anton Sviridenko <anton@corp.bluecherry.net>
diff --git a/arch/nds32/Kconfig b/arch/nds32/Kconfig
index 249f38d3388f..b7404f2dcf5b 100644
--- a/arch/nds32/Kconfig
+++ b/arch/nds32/Kconfig
@@ -9,6 +9,12 @@ config NDS32
9 select CLKSRC_MMIO 9 select CLKSRC_MMIO
10 select CLONE_BACKWARDS 10 select CLONE_BACKWARDS
11 select COMMON_CLK 11 select COMMON_CLK
12 select GENERIC_ASHLDI3
13 select GENERIC_ASHRDI3
14 select GENERIC_LSHRDI3
15 select GENERIC_CMPDI2
16 select GENERIC_MULDI3
17 select GENERIC_UCMPDI2
12 select GENERIC_ATOMIC64 18 select GENERIC_ATOMIC64
13 select GENERIC_CPU_DEVICES 19 select GENERIC_CPU_DEVICES
14 select GENERIC_CLOCKEVENTS 20 select GENERIC_CLOCKEVENTS
@@ -82,6 +88,7 @@ endmenu
82 88
83menu "Kernel Features" 89menu "Kernel Features"
84source "kernel/Kconfig.preempt" 90source "kernel/Kconfig.preempt"
91source "kernel/Kconfig.freezer"
85source "mm/Kconfig" 92source "mm/Kconfig"
86source "kernel/Kconfig.hz" 93source "kernel/Kconfig.hz"
87endmenu 94endmenu
diff --git a/arch/nds32/Kconfig.cpu b/arch/nds32/Kconfig.cpu
index ba44cc539da9..b8c8984d1456 100644
--- a/arch/nds32/Kconfig.cpu
+++ b/arch/nds32/Kconfig.cpu
@@ -1,10 +1,11 @@
1comment "Processor Features" 1comment "Processor Features"
2 2
3config CPU_BIG_ENDIAN 3config CPU_BIG_ENDIAN
4 bool "Big endian" 4 def_bool !CPU_LITTLE_ENDIAN
5 5
6config CPU_LITTLE_ENDIAN 6config CPU_LITTLE_ENDIAN
7 def_bool !CPU_BIG_ENDIAN 7 bool "Little endian"
8 default y
8 9
9config HWZOL 10config HWZOL
10 bool "hardware zero overhead loop support" 11 bool "hardware zero overhead loop support"
diff --git a/arch/nds32/Makefile b/arch/nds32/Makefile
index 91f933d5a962..513bb2e9baf9 100644
--- a/arch/nds32/Makefile
+++ b/arch/nds32/Makefile
@@ -23,9 +23,6 @@ export TEXTADDR
23# If we have a machine-specific directory, then include it in the build. 23# If we have a machine-specific directory, then include it in the build.
24core-y += arch/nds32/kernel/ arch/nds32/mm/ 24core-y += arch/nds32/kernel/ arch/nds32/mm/
25libs-y += arch/nds32/lib/ 25libs-y += arch/nds32/lib/
26LIBGCC_PATH := \
27 $(shell $(CC) $(KBUILD_CFLAGS) $(KCFLAGS) -print-libgcc-file-name)
28libs-y += $(LIBGCC_PATH)
29 26
30ifneq '$(CONFIG_NDS32_BUILTIN_DTB)' '""' 27ifneq '$(CONFIG_NDS32_BUILTIN_DTB)' '""'
31BUILTIN_DTB := y 28BUILTIN_DTB := y
@@ -35,8 +32,12 @@ endif
35 32
36ifdef CONFIG_CPU_LITTLE_ENDIAN 33ifdef CONFIG_CPU_LITTLE_ENDIAN
37KBUILD_CFLAGS += $(call cc-option, -EL) 34KBUILD_CFLAGS += $(call cc-option, -EL)
35KBUILD_AFLAGS += $(call cc-option, -EL)
36LDFLAGS += $(call cc-option, -EL)
38else 37else
39KBUILD_CFLAGS += $(call cc-option, -EB) 38KBUILD_CFLAGS += $(call cc-option, -EB)
39KBUILD_AFLAGS += $(call cc-option, -EB)
40LDFLAGS += $(call cc-option, -EB)
40endif 41endif
41 42
42boot := arch/nds32/boot 43boot := arch/nds32/boot
diff --git a/arch/nds32/include/asm/Kbuild b/arch/nds32/include/asm/Kbuild
index 06bdf8167f5a..142e612aa639 100644
--- a/arch/nds32/include/asm/Kbuild
+++ b/arch/nds32/include/asm/Kbuild
@@ -16,6 +16,7 @@ generic-y += dma.h
16generic-y += emergency-restart.h 16generic-y += emergency-restart.h
17generic-y += errno.h 17generic-y += errno.h
18generic-y += exec.h 18generic-y += exec.h
19generic-y += export.h
19generic-y += fb.h 20generic-y += fb.h
20generic-y += fcntl.h 21generic-y += fcntl.h
21generic-y += ftrace.h 22generic-y += ftrace.h
@@ -49,6 +50,7 @@ generic-y += switch_to.h
49generic-y += timex.h 50generic-y += timex.h
50generic-y += topology.h 51generic-y += topology.h
51generic-y += trace_clock.h 52generic-y += trace_clock.h
53generic-y += xor.h
52generic-y += unaligned.h 54generic-y += unaligned.h
53generic-y += user.h 55generic-y += user.h
54generic-y += vga.h 56generic-y += vga.h
diff --git a/arch/nds32/include/asm/bitfield.h b/arch/nds32/include/asm/bitfield.h
index c73f71d67744..8e84fc385b94 100644
--- a/arch/nds32/include/asm/bitfield.h
+++ b/arch/nds32/include/asm/bitfield.h
@@ -336,7 +336,7 @@
336#define INT_MASK_mskIDIVZE ( 0x1 << INT_MASK_offIDIVZE ) 336#define INT_MASK_mskIDIVZE ( 0x1 << INT_MASK_offIDIVZE )
337#define INT_MASK_mskDSSIM ( 0x1 << INT_MASK_offDSSIM ) 337#define INT_MASK_mskDSSIM ( 0x1 << INT_MASK_offDSSIM )
338 338
339#define INT_MASK_INITAIAL_VAL 0x10003 339#define INT_MASK_INITAIAL_VAL (INT_MASK_mskDSSIM|INT_MASK_mskIDIVZE)
340 340
341/****************************************************************************** 341/******************************************************************************
342 * ir15: INT_PEND (Interrupt Pending Register) 342 * ir15: INT_PEND (Interrupt Pending Register)
@@ -396,6 +396,7 @@
396#define MMU_CTL_D8KB 1 396#define MMU_CTL_D8KB 1
397#define MMU_CTL_UNA ( 0x1 << MMU_CTL_offUNA ) 397#define MMU_CTL_UNA ( 0x1 << MMU_CTL_offUNA )
398 398
399#define MMU_CTL_CACHEABLE_NON 0
399#define MMU_CTL_CACHEABLE_WB 2 400#define MMU_CTL_CACHEABLE_WB 2
400#define MMU_CTL_CACHEABLE_WT 3 401#define MMU_CTL_CACHEABLE_WT 3
401 402
diff --git a/arch/nds32/include/asm/cacheflush.h b/arch/nds32/include/asm/cacheflush.h
index 1240f148ec0f..10b48f0d8e85 100644
--- a/arch/nds32/include/asm/cacheflush.h
+++ b/arch/nds32/include/asm/cacheflush.h
@@ -32,6 +32,8 @@ void flush_anon_page(struct vm_area_struct *vma,
32 32
33#define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE 33#define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE
34void flush_kernel_dcache_page(struct page *page); 34void flush_kernel_dcache_page(struct page *page);
35void flush_kernel_vmap_range(void *addr, int size);
36void invalidate_kernel_vmap_range(void *addr, int size);
35void flush_icache_range(unsigned long start, unsigned long end); 37void flush_icache_range(unsigned long start, unsigned long end);
36void flush_icache_page(struct vm_area_struct *vma, struct page *page); 38void flush_icache_page(struct vm_area_struct *vma, struct page *page);
37#define flush_dcache_mmap_lock(mapping) xa_lock_irq(&(mapping)->i_pages) 39#define flush_dcache_mmap_lock(mapping) xa_lock_irq(&(mapping)->i_pages)
diff --git a/arch/nds32/include/asm/io.h b/arch/nds32/include/asm/io.h
index 966e71b3c960..71cd226d6863 100644
--- a/arch/nds32/include/asm/io.h
+++ b/arch/nds32/include/asm/io.h
@@ -4,6 +4,8 @@
4#ifndef __ASM_NDS32_IO_H 4#ifndef __ASM_NDS32_IO_H
5#define __ASM_NDS32_IO_H 5#define __ASM_NDS32_IO_H
6 6
7#include <linux/types.h>
8
7extern void iounmap(volatile void __iomem *addr); 9extern void iounmap(volatile void __iomem *addr);
8#define __raw_writeb __raw_writeb 10#define __raw_writeb __raw_writeb
9static inline void __raw_writeb(u8 val, volatile void __iomem *addr) 11static inline void __raw_writeb(u8 val, volatile void __iomem *addr)
diff --git a/arch/nds32/include/asm/page.h b/arch/nds32/include/asm/page.h
index e27365c097b6..947f0491c9a7 100644
--- a/arch/nds32/include/asm/page.h
+++ b/arch/nds32/include/asm/page.h
@@ -27,6 +27,9 @@ extern void copy_user_highpage(struct page *to, struct page *from,
27 unsigned long vaddr, struct vm_area_struct *vma); 27 unsigned long vaddr, struct vm_area_struct *vma);
28extern void clear_user_highpage(struct page *page, unsigned long vaddr); 28extern void clear_user_highpage(struct page *page, unsigned long vaddr);
29 29
30void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
31 struct page *to);
32void clear_user_page(void *addr, unsigned long vaddr, struct page *page);
30#define __HAVE_ARCH_COPY_USER_HIGHPAGE 33#define __HAVE_ARCH_COPY_USER_HIGHPAGE
31#define clear_user_highpage clear_user_highpage 34#define clear_user_highpage clear_user_highpage
32#else 35#else
diff --git a/arch/nds32/include/asm/pgtable.h b/arch/nds32/include/asm/pgtable.h
index 6783937edbeb..d3e19a55cf53 100644
--- a/arch/nds32/include/asm/pgtable.h
+++ b/arch/nds32/include/asm/pgtable.h
@@ -152,6 +152,7 @@ extern void __pgd_error(const char *file, int line, unsigned long val);
152#define PAGE_CACHE_L1 __pgprot(_HAVE_PAGE_L | _PAGE_V | _PAGE_M_KRW | _PAGE_D | _PAGE_E | _PAGE_G | _PAGE_CACHE) 152#define PAGE_CACHE_L1 __pgprot(_HAVE_PAGE_L | _PAGE_V | _PAGE_M_KRW | _PAGE_D | _PAGE_E | _PAGE_G | _PAGE_CACHE)
153#define PAGE_MEMORY __pgprot(_HAVE_PAGE_L | _PAGE_V | _PAGE_M_KRW | _PAGE_D | _PAGE_E | _PAGE_G | _PAGE_CACHE_SHRD) 153#define PAGE_MEMORY __pgprot(_HAVE_PAGE_L | _PAGE_V | _PAGE_M_KRW | _PAGE_D | _PAGE_E | _PAGE_G | _PAGE_CACHE_SHRD)
154#define PAGE_KERNEL __pgprot(_PAGE_V | _PAGE_M_KRW | _PAGE_D | _PAGE_E | _PAGE_G | _PAGE_CACHE_SHRD) 154#define PAGE_KERNEL __pgprot(_PAGE_V | _PAGE_M_KRW | _PAGE_D | _PAGE_E | _PAGE_G | _PAGE_CACHE_SHRD)
155#define PAGE_SHARED __pgprot(_PAGE_V | _PAGE_M_URW_KRW | _PAGE_D | _PAGE_CACHE_SHRD)
155#define PAGE_DEVICE __pgprot(_PAGE_V | _PAGE_M_KRW | _PAGE_D | _PAGE_G | _PAGE_C_DEV) 156#define PAGE_DEVICE __pgprot(_PAGE_V | _PAGE_M_KRW | _PAGE_D | _PAGE_G | _PAGE_C_DEV)
156#endif /* __ASSEMBLY__ */ 157#endif /* __ASSEMBLY__ */
157 158
diff --git a/arch/nds32/kernel/ex-entry.S b/arch/nds32/kernel/ex-entry.S
index a72e83d804f5..b8ae4e9a6b93 100644
--- a/arch/nds32/kernel/ex-entry.S
+++ b/arch/nds32/kernel/ex-entry.S
@@ -118,7 +118,7 @@ common_exception_handler:
118 /* interrupt */ 118 /* interrupt */
1192: 1192:
120#ifdef CONFIG_TRACE_IRQFLAGS 120#ifdef CONFIG_TRACE_IRQFLAGS
121 jal arch_trace_hardirqs_off 121 jal trace_hardirqs_off
122#endif 122#endif
123 move $r0, $sp 123 move $r0, $sp
124 sethi $lp, hi20(ret_from_intr) 124 sethi $lp, hi20(ret_from_intr)
diff --git a/arch/nds32/kernel/head.S b/arch/nds32/kernel/head.S
index 71f57bd70f3b..c5fdae174ced 100644
--- a/arch/nds32/kernel/head.S
+++ b/arch/nds32/kernel/head.S
@@ -57,14 +57,32 @@ _nodtb:
57 isb 57 isb
58 mtsr $r4, $L1_PPTB ! load page table pointer\n" 58 mtsr $r4, $L1_PPTB ! load page table pointer\n"
59 59
60/* set NTC0 cacheable/writeback, mutliple page size in use */ 60#ifdef CONFIG_CPU_DCACHE_DISABLE
61 #define MMU_CTL_NTCC MMU_CTL_CACHEABLE_NON
62#else
63 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
64 #define MMU_CTL_NTCC MMU_CTL_CACHEABLE_WT
65 #else
66 #define MMU_CTL_NTCC MMU_CTL_CACHEABLE_WB
67 #endif
68#endif
69
70/* set NTC cacheability, mutliple page size in use */
61 mfsr $r3, $MMU_CTL 71 mfsr $r3, $MMU_CTL
62 li $r0, #~MMU_CTL_mskNTC0 72#if CONFIG_MEMORY_START >= 0xc0000000
63 and $r3, $r3, $r0 73 ori $r3, $r3, (MMU_CTL_NTCC << MMU_CTL_offNTC3)
74#elif CONFIG_MEMORY_START >= 0x80000000
75 ori $r3, $r3, (MMU_CTL_NTCC << MMU_CTL_offNTC2)
76#elif CONFIG_MEMORY_START >= 0x40000000
77 ori $r3, $r3, (MMU_CTL_NTCC << MMU_CTL_offNTC1)
78#else
79 ori $r3, $r3, (MMU_CTL_NTCC << MMU_CTL_offNTC0)
80#endif
81
64#ifdef CONFIG_ANDES_PAGE_SIZE_4KB 82#ifdef CONFIG_ANDES_PAGE_SIZE_4KB
65 ori $r3, $r3, #(MMU_CTL_mskMPZIU|(MMU_CTL_CACHEABLE_WB << MMU_CTL_offNTC0)) 83 ori $r3, $r3, #(MMU_CTL_mskMPZIU)
66#else 84#else
67 ori $r3, $r3, #(MMU_CTL_mskMPZIU|(MMU_CTL_CACHEABLE_WB << MMU_CTL_offNTC0)|MMU_CTL_D8KB) 85 ori $r3, $r3, #(MMU_CTL_mskMPZIU|MMU_CTL_D8KB)
68#endif 86#endif
69#ifdef CONFIG_HW_SUPPORT_UNALIGNMENT_ACCESS 87#ifdef CONFIG_HW_SUPPORT_UNALIGNMENT_ACCESS
70 li $r0, #MMU_CTL_UNA 88 li $r0, #MMU_CTL_UNA
diff --git a/arch/nds32/kernel/setup.c b/arch/nds32/kernel/setup.c
index ba910e9e4ecb..2f5b2ccebe47 100644
--- a/arch/nds32/kernel/setup.c
+++ b/arch/nds32/kernel/setup.c
@@ -293,6 +293,9 @@ void __init setup_arch(char **cmdline_p)
293 /* paging_init() sets up the MMU and marks all pages as reserved */ 293 /* paging_init() sets up the MMU and marks all pages as reserved */
294 paging_init(); 294 paging_init();
295 295
296 /* invalidate all TLB entries because the new mapping is created */
297 __nds32__tlbop_flua();
298
296 /* use generic way to parse */ 299 /* use generic way to parse */
297 parse_early_param(); 300 parse_early_param();
298 301
diff --git a/arch/nds32/kernel/stacktrace.c b/arch/nds32/kernel/stacktrace.c
index bc70113c0e84..8b231e910ea6 100644
--- a/arch/nds32/kernel/stacktrace.c
+++ b/arch/nds32/kernel/stacktrace.c
@@ -9,6 +9,7 @@ void save_stack_trace(struct stack_trace *trace)
9{ 9{
10 save_stack_trace_tsk(current, trace); 10 save_stack_trace_tsk(current, trace);
11} 11}
12EXPORT_SYMBOL_GPL(save_stack_trace);
12 13
13void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace) 14void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
14{ 15{
@@ -45,3 +46,4 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
45 fpn = (unsigned long *)fpp; 46 fpn = (unsigned long *)fpp;
46 } 47 }
47} 48}
49EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
diff --git a/arch/nds32/kernel/vdso.c b/arch/nds32/kernel/vdso.c
index f1198d7a5654..016f15891f6d 100644
--- a/arch/nds32/kernel/vdso.c
+++ b/arch/nds32/kernel/vdso.c
@@ -23,7 +23,7 @@
23#include <asm/vdso_timer_info.h> 23#include <asm/vdso_timer_info.h>
24#include <asm/cache_info.h> 24#include <asm/cache_info.h>
25extern struct cache_info L1_cache_info[2]; 25extern struct cache_info L1_cache_info[2];
26extern char vdso_start, vdso_end; 26extern char vdso_start[], vdso_end[];
27static unsigned long vdso_pages __ro_after_init; 27static unsigned long vdso_pages __ro_after_init;
28static unsigned long timer_mapping_base; 28static unsigned long timer_mapping_base;
29 29
@@ -66,16 +66,16 @@ static int __init vdso_init(void)
66 int i; 66 int i;
67 struct page **vdso_pagelist; 67 struct page **vdso_pagelist;
68 68
69 if (memcmp(&vdso_start, "\177ELF", 4)) { 69 if (memcmp(vdso_start, "\177ELF", 4)) {
70 pr_err("vDSO is not a valid ELF object!\n"); 70 pr_err("vDSO is not a valid ELF object!\n");
71 return -EINVAL; 71 return -EINVAL;
72 } 72 }
73 /* Creat a timer io mapping to get clock cycles counter */ 73 /* Creat a timer io mapping to get clock cycles counter */
74 get_timer_node_info(); 74 get_timer_node_info();
75 75
76 vdso_pages = (&vdso_end - &vdso_start) >> PAGE_SHIFT; 76 vdso_pages = (vdso_end - vdso_start) >> PAGE_SHIFT;
77 pr_info("vdso: %ld pages (%ld code @ %p, %ld data @ %p)\n", 77 pr_info("vdso: %ld pages (%ld code @ %p, %ld data @ %p)\n",
78 vdso_pages + 1, vdso_pages, &vdso_start, 1L, vdso_data); 78 vdso_pages + 1, vdso_pages, vdso_start, 1L, vdso_data);
79 79
80 /* Allocate the vDSO pagelist */ 80 /* Allocate the vDSO pagelist */
81 vdso_pagelist = kcalloc(vdso_pages, sizeof(struct page *), GFP_KERNEL); 81 vdso_pagelist = kcalloc(vdso_pages, sizeof(struct page *), GFP_KERNEL);
@@ -83,7 +83,7 @@ static int __init vdso_init(void)
83 return -ENOMEM; 83 return -ENOMEM;
84 84
85 for (i = 0; i < vdso_pages; i++) 85 for (i = 0; i < vdso_pages; i++)
86 vdso_pagelist[i] = virt_to_page(&vdso_start + i * PAGE_SIZE); 86 vdso_pagelist[i] = virt_to_page(vdso_start + i * PAGE_SIZE);
87 vdso_spec[1].pages = &vdso_pagelist[0]; 87 vdso_spec[1].pages = &vdso_pagelist[0];
88 88
89 return 0; 89 return 0;
diff --git a/arch/nds32/lib/copy_page.S b/arch/nds32/lib/copy_page.S
index 4a2ff85f17ee..f8701ed161a8 100644
--- a/arch/nds32/lib/copy_page.S
+++ b/arch/nds32/lib/copy_page.S
@@ -2,6 +2,7 @@
2// Copyright (C) 2005-2017 Andes Technology Corporation 2// Copyright (C) 2005-2017 Andes Technology Corporation
3 3
4#include <linux/linkage.h> 4#include <linux/linkage.h>
5#include <asm/export.h>
5#include <asm/page.h> 6#include <asm/page.h>
6 7
7 .text 8 .text
@@ -16,6 +17,7 @@ ENTRY(copy_page)
16 popm $r2, $r10 17 popm $r2, $r10
17 ret 18 ret
18ENDPROC(copy_page) 19ENDPROC(copy_page)
20EXPORT_SYMBOL(copy_page)
19 21
20ENTRY(clear_page) 22ENTRY(clear_page)
21 pushm $r1, $r9 23 pushm $r1, $r9
@@ -35,3 +37,4 @@ ENTRY(clear_page)
35 popm $r1, $r9 37 popm $r1, $r9
36 ret 38 ret
37ENDPROC(clear_page) 39ENDPROC(clear_page)
40EXPORT_SYMBOL(clear_page)
diff --git a/arch/nds32/mm/alignment.c b/arch/nds32/mm/alignment.c
index b96a01b10ca7..e1aed9dc692d 100644
--- a/arch/nds32/mm/alignment.c
+++ b/arch/nds32/mm/alignment.c
@@ -19,7 +19,7 @@
19#define RA(inst) (((inst) >> 15) & 0x1FUL) 19#define RA(inst) (((inst) >> 15) & 0x1FUL)
20#define RB(inst) (((inst) >> 10) & 0x1FUL) 20#define RB(inst) (((inst) >> 10) & 0x1FUL)
21#define SV(inst) (((inst) >> 8) & 0x3UL) 21#define SV(inst) (((inst) >> 8) & 0x3UL)
22#define IMM(inst) (((inst) >> 0) & 0x3FFFUL) 22#define IMM(inst) (((inst) >> 0) & 0x7FFFUL)
23 23
24#define RA3(inst) (((inst) >> 3) & 0x7UL) 24#define RA3(inst) (((inst) >> 3) & 0x7UL)
25#define RT3(inst) (((inst) >> 6) & 0x7UL) 25#define RT3(inst) (((inst) >> 6) & 0x7UL)
@@ -28,6 +28,9 @@
28#define RA5(inst) (((inst) >> 0) & 0x1FUL) 28#define RA5(inst) (((inst) >> 0) & 0x1FUL)
29#define RT4(inst) (((inst) >> 5) & 0xFUL) 29#define RT4(inst) (((inst) >> 5) & 0xFUL)
30 30
31#define GET_IMMSVAL(imm_value) \
32 (((imm_value >> 14) & 0x1) ? (imm_value - 0x8000) : imm_value)
33
31#define __get8_data(val,addr,err) \ 34#define __get8_data(val,addr,err) \
32 __asm__( \ 35 __asm__( \
33 "1: lbi.bi %1, [%2], #1\n" \ 36 "1: lbi.bi %1, [%2], #1\n" \
@@ -467,7 +470,7 @@ static inline int do_32(unsigned long inst, struct pt_regs *regs)
467 } 470 }
468 471
469 if (imm) 472 if (imm)
470 shift = IMM(inst) * len; 473 shift = GET_IMMSVAL(IMM(inst)) * len;
471 else 474 else
472 shift = *idx_to_addr(regs, RB(inst)) << SV(inst); 475 shift = *idx_to_addr(regs, RB(inst)) << SV(inst);
473 476
@@ -552,7 +555,7 @@ static struct ctl_table alignment_tbl[3] = {
552 555
553static struct ctl_table nds32_sysctl_table[2] = { 556static struct ctl_table nds32_sysctl_table[2] = {
554 { 557 {
555 .procname = "unaligned_acess", 558 .procname = "unaligned_access",
556 .mode = 0555, 559 .mode = 0555,
557 .child = alignment_tbl}, 560 .child = alignment_tbl},
558 {} 561 {}
diff --git a/arch/nds32/mm/cacheflush.c b/arch/nds32/mm/cacheflush.c
index 6eb786a399a2..ce8fd34497bf 100644
--- a/arch/nds32/mm/cacheflush.c
+++ b/arch/nds32/mm/cacheflush.c
@@ -147,6 +147,25 @@ void flush_cache_vunmap(unsigned long start, unsigned long end)
147 cpu_icache_inval_all(); 147 cpu_icache_inval_all();
148} 148}
149 149
150void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
151 struct page *to)
152{
153 cpu_dcache_wbinval_page((unsigned long)vaddr);
154 cpu_icache_inval_page((unsigned long)vaddr);
155 copy_page(vto, vfrom);
156 cpu_dcache_wbinval_page((unsigned long)vto);
157 cpu_icache_inval_page((unsigned long)vto);
158}
159
160void clear_user_page(void *addr, unsigned long vaddr, struct page *page)
161{
162 cpu_dcache_wbinval_page((unsigned long)vaddr);
163 cpu_icache_inval_page((unsigned long)vaddr);
164 clear_page(addr);
165 cpu_dcache_wbinval_page((unsigned long)addr);
166 cpu_icache_inval_page((unsigned long)addr);
167}
168
150void copy_user_highpage(struct page *to, struct page *from, 169void copy_user_highpage(struct page *to, struct page *from,
151 unsigned long vaddr, struct vm_area_struct *vma) 170 unsigned long vaddr, struct vm_area_struct *vma)
152{ 171{
@@ -156,11 +175,9 @@ void copy_user_highpage(struct page *to, struct page *from,
156 pto = page_to_phys(to); 175 pto = page_to_phys(to);
157 pfrom = page_to_phys(from); 176 pfrom = page_to_phys(from);
158 177
178 local_irq_save(flags);
159 if (aliasing(vaddr, (unsigned long)kfrom)) 179 if (aliasing(vaddr, (unsigned long)kfrom))
160 cpu_dcache_wb_page((unsigned long)kfrom); 180 cpu_dcache_wb_page((unsigned long)kfrom);
161 if (aliasing(vaddr, (unsigned long)kto))
162 cpu_dcache_inval_page((unsigned long)kto);
163 local_irq_save(flags);
164 vto = kremap0(vaddr, pto); 181 vto = kremap0(vaddr, pto);
165 vfrom = kremap1(vaddr, pfrom); 182 vfrom = kremap1(vaddr, pfrom);
166 copy_page((void *)vto, (void *)vfrom); 183 copy_page((void *)vto, (void *)vfrom);
@@ -198,21 +215,25 @@ void flush_dcache_page(struct page *page)
198 if (mapping && !mapping_mapped(mapping)) 215 if (mapping && !mapping_mapped(mapping))
199 set_bit(PG_dcache_dirty, &page->flags); 216 set_bit(PG_dcache_dirty, &page->flags);
200 else { 217 else {
201 int i, pc; 218 unsigned long kaddr, flags;
202 unsigned long vto, kaddr, flags; 219
203 kaddr = (unsigned long)page_address(page); 220 kaddr = (unsigned long)page_address(page);
204 cpu_dcache_wbinval_page(kaddr);
205 pc = CACHE_SET(DCACHE) * CACHE_LINE_SIZE(DCACHE) / PAGE_SIZE;
206 local_irq_save(flags); 221 local_irq_save(flags);
207 for (i = 0; i < pc; i++) { 222 cpu_dcache_wbinval_page(kaddr);
208 vto = 223 if (mapping) {
209 kremap0(kaddr + i * PAGE_SIZE, page_to_phys(page)); 224 unsigned long vaddr, kto;
210 cpu_dcache_wbinval_page(vto); 225
211 kunmap01(vto); 226 vaddr = page->index << PAGE_SHIFT;
227 if (aliasing(vaddr, kaddr)) {
228 kto = kremap0(vaddr, page_to_phys(page));
229 cpu_dcache_wbinval_page(kto);
230 kunmap01(kto);
231 }
212 } 232 }
213 local_irq_restore(flags); 233 local_irq_restore(flags);
214 } 234 }
215} 235}
236EXPORT_SYMBOL(flush_dcache_page);
216 237
217void copy_to_user_page(struct vm_area_struct *vma, struct page *page, 238void copy_to_user_page(struct vm_area_struct *vma, struct page *page,
218 unsigned long vaddr, void *dst, void *src, int len) 239 unsigned long vaddr, void *dst, void *src, int len)
@@ -251,7 +272,7 @@ void copy_from_user_page(struct vm_area_struct *vma, struct page *page,
251void flush_anon_page(struct vm_area_struct *vma, 272void flush_anon_page(struct vm_area_struct *vma,
252 struct page *page, unsigned long vaddr) 273 struct page *page, unsigned long vaddr)
253{ 274{
254 unsigned long flags; 275 unsigned long kaddr, flags, ktmp;
255 if (!PageAnon(page)) 276 if (!PageAnon(page))
256 return; 277 return;
257 278
@@ -261,7 +282,12 @@ void flush_anon_page(struct vm_area_struct *vma,
261 local_irq_save(flags); 282 local_irq_save(flags);
262 if (vma->vm_flags & VM_EXEC) 283 if (vma->vm_flags & VM_EXEC)
263 cpu_icache_inval_page(vaddr & PAGE_MASK); 284 cpu_icache_inval_page(vaddr & PAGE_MASK);
264 cpu_dcache_wbinval_page((unsigned long)page_address(page)); 285 kaddr = (unsigned long)page_address(page);
286 if (aliasing(vaddr, kaddr)) {
287 ktmp = kremap0(vaddr, page_to_phys(page));
288 cpu_dcache_wbinval_page(ktmp);
289 kunmap01(ktmp);
290 }
265 local_irq_restore(flags); 291 local_irq_restore(flags);
266} 292}
267 293
@@ -272,6 +298,25 @@ void flush_kernel_dcache_page(struct page *page)
272 cpu_dcache_wbinval_page((unsigned long)page_address(page)); 298 cpu_dcache_wbinval_page((unsigned long)page_address(page));
273 local_irq_restore(flags); 299 local_irq_restore(flags);
274} 300}
301EXPORT_SYMBOL(flush_kernel_dcache_page);
302
303void flush_kernel_vmap_range(void *addr, int size)
304{
305 unsigned long flags;
306 local_irq_save(flags);
307 cpu_dcache_wb_range((unsigned long)addr, (unsigned long)addr + size);
308 local_irq_restore(flags);
309}
310EXPORT_SYMBOL(flush_kernel_vmap_range);
311
312void invalidate_kernel_vmap_range(void *addr, int size)
313{
314 unsigned long flags;
315 local_irq_save(flags);
316 cpu_dcache_inval_range((unsigned long)addr, (unsigned long)addr + size);
317 local_irq_restore(flags);
318}
319EXPORT_SYMBOL(invalidate_kernel_vmap_range);
275 320
276void flush_icache_range(unsigned long start, unsigned long end) 321void flush_icache_range(unsigned long start, unsigned long end)
277{ 322{
@@ -283,6 +328,7 @@ void flush_icache_range(unsigned long start, unsigned long end)
283 cpu_cache_wbinval_range(start, end, 1); 328 cpu_cache_wbinval_range(start, end, 1);
284 local_irq_restore(flags); 329 local_irq_restore(flags);
285} 330}
331EXPORT_SYMBOL(flush_icache_range);
286 332
287void flush_icache_page(struct vm_area_struct *vma, struct page *page) 333void flush_icache_page(struct vm_area_struct *vma, struct page *page)
288{ 334{
diff --git a/arch/nds32/mm/init.c b/arch/nds32/mm/init.c
index 93ee0160720b..c713d2ad55dc 100644
--- a/arch/nds32/mm/init.c
+++ b/arch/nds32/mm/init.c
@@ -30,6 +30,7 @@ extern unsigned long phys_initrd_size;
30 * zero-initialized data and COW. 30 * zero-initialized data and COW.
31 */ 31 */
32struct page *empty_zero_page; 32struct page *empty_zero_page;
33EXPORT_SYMBOL(empty_zero_page);
33 34
34static void __init zone_sizes_init(void) 35static void __init zone_sizes_init(void)
35{ 36{
diff --git a/arch/s390/purgatory/Makefile b/arch/s390/purgatory/Makefile
index e9525bc1b4a6..1ace023cbdce 100644
--- a/arch/s390/purgatory/Makefile
+++ b/arch/s390/purgatory/Makefile
@@ -21,7 +21,7 @@ LDFLAGS_purgatory.ro += -z nodefaultlib
21KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes 21KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes
22KBUILD_CFLAGS += -Wno-pointer-sign -Wno-sign-compare 22KBUILD_CFLAGS += -Wno-pointer-sign -Wno-sign-compare
23KBUILD_CFLAGS += -fno-zero-initialized-in-bss -fno-builtin -ffreestanding 23KBUILD_CFLAGS += -fno-zero-initialized-in-bss -fno-builtin -ffreestanding
24KBUILD_CFLAGS += -c -MD -Os -m64 24KBUILD_CFLAGS += -c -MD -Os -m64 -msoft-float
25KBUILD_CFLAGS += $(call cc-option,-fno-PIE) 25KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
26 26
27$(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE 27$(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index fda2114197b3..68b2c3150de1 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -62,8 +62,8 @@
62#define NHM_C3_AUTO_DEMOTE (1UL << 25) 62#define NHM_C3_AUTO_DEMOTE (1UL << 25)
63#define NHM_C1_AUTO_DEMOTE (1UL << 26) 63#define NHM_C1_AUTO_DEMOTE (1UL << 26)
64#define ATM_LNC_C6_AUTO_DEMOTE (1UL << 25) 64#define ATM_LNC_C6_AUTO_DEMOTE (1UL << 25)
65#define SNB_C1_AUTO_UNDEMOTE (1UL << 27) 65#define SNB_C3_AUTO_UNDEMOTE (1UL << 27)
66#define SNB_C3_AUTO_UNDEMOTE (1UL << 28) 66#define SNB_C1_AUTO_UNDEMOTE (1UL << 28)
67 67
68#define MSR_MTRRcap 0x000000fe 68#define MSR_MTRRcap 0x000000fe
69 69
diff --git a/drivers/crypto/inside-secure/safexcel.c b/drivers/crypto/inside-secure/safexcel.c
index d4a81be0d7d2..b6be62025325 100644
--- a/drivers/crypto/inside-secure/safexcel.c
+++ b/drivers/crypto/inside-secure/safexcel.c
@@ -152,8 +152,8 @@ static int eip197_load_firmwares(struct safexcel_crypto_priv *priv)
152 EIP197_PE_ICE_SCRATCH_CTRL_CHANGE_ACCESS; 152 EIP197_PE_ICE_SCRATCH_CTRL_CHANGE_ACCESS;
153 writel(val, EIP197_PE(priv) + EIP197_PE_ICE_SCRATCH_CTRL); 153 writel(val, EIP197_PE(priv) + EIP197_PE_ICE_SCRATCH_CTRL);
154 154
155 memset(EIP197_PE(priv) + EIP197_PE_ICE_SCRATCH_RAM, 0, 155 memset_io(EIP197_PE(priv) + EIP197_PE_ICE_SCRATCH_RAM, 0,
156 EIP197_NUM_OF_SCRATCH_BLOCKS * sizeof(u32)); 156 EIP197_NUM_OF_SCRATCH_BLOCKS * sizeof(u32));
157 157
158 eip197_write_firmware(priv, fw[FW_IFPP], EIP197_PE_ICE_FPP_CTRL, 158 eip197_write_firmware(priv, fw[FW_IFPP], EIP197_PE_ICE_FPP_CTRL,
159 EIP197_PE_ICE_RAM_CTRL_FPP_PROG_EN); 159 EIP197_PE_ICE_RAM_CTRL_FPP_PROG_EN);
diff --git a/drivers/input/mouse/elan_i2c_smbus.c b/drivers/input/mouse/elan_i2c_smbus.c
index 29f99529b187..cfcb32559925 100644
--- a/drivers/input/mouse/elan_i2c_smbus.c
+++ b/drivers/input/mouse/elan_i2c_smbus.c
@@ -130,7 +130,7 @@ static int elan_smbus_get_baseline_data(struct i2c_client *client,
130 bool max_baseline, u8 *value) 130 bool max_baseline, u8 *value)
131{ 131{
132 int error; 132 int error;
133 u8 val[3]; 133 u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
134 134
135 error = i2c_smbus_read_block_data(client, 135 error = i2c_smbus_read_block_data(client,
136 max_baseline ? 136 max_baseline ?
@@ -149,7 +149,7 @@ static int elan_smbus_get_version(struct i2c_client *client,
149 bool iap, u8 *version) 149 bool iap, u8 *version)
150{ 150{
151 int error; 151 int error;
152 u8 val[3]; 152 u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
153 153
154 error = i2c_smbus_read_block_data(client, 154 error = i2c_smbus_read_block_data(client,
155 iap ? ETP_SMBUS_IAP_VERSION_CMD : 155 iap ? ETP_SMBUS_IAP_VERSION_CMD :
@@ -170,7 +170,7 @@ static int elan_smbus_get_sm_version(struct i2c_client *client,
170 u8 *clickpad) 170 u8 *clickpad)
171{ 171{
172 int error; 172 int error;
173 u8 val[3]; 173 u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
174 174
175 error = i2c_smbus_read_block_data(client, 175 error = i2c_smbus_read_block_data(client,
176 ETP_SMBUS_SM_VERSION_CMD, val); 176 ETP_SMBUS_SM_VERSION_CMD, val);
@@ -188,7 +188,7 @@ static int elan_smbus_get_sm_version(struct i2c_client *client,
188static int elan_smbus_get_product_id(struct i2c_client *client, u16 *id) 188static int elan_smbus_get_product_id(struct i2c_client *client, u16 *id)
189{ 189{
190 int error; 190 int error;
191 u8 val[3]; 191 u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
192 192
193 error = i2c_smbus_read_block_data(client, 193 error = i2c_smbus_read_block_data(client,
194 ETP_SMBUS_UNIQUEID_CMD, val); 194 ETP_SMBUS_UNIQUEID_CMD, val);
@@ -205,7 +205,7 @@ static int elan_smbus_get_checksum(struct i2c_client *client,
205 bool iap, u16 *csum) 205 bool iap, u16 *csum)
206{ 206{
207 int error; 207 int error;
208 u8 val[3]; 208 u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
209 209
210 error = i2c_smbus_read_block_data(client, 210 error = i2c_smbus_read_block_data(client,
211 iap ? ETP_SMBUS_FW_CHECKSUM_CMD : 211 iap ? ETP_SMBUS_FW_CHECKSUM_CMD :
@@ -226,7 +226,7 @@ static int elan_smbus_get_max(struct i2c_client *client,
226{ 226{
227 int ret; 227 int ret;
228 int error; 228 int error;
229 u8 val[3]; 229 u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
230 230
231 ret = i2c_smbus_read_block_data(client, ETP_SMBUS_RANGE_CMD, val); 231 ret = i2c_smbus_read_block_data(client, ETP_SMBUS_RANGE_CMD, val);
232 if (ret != 3) { 232 if (ret != 3) {
@@ -246,7 +246,7 @@ static int elan_smbus_get_resolution(struct i2c_client *client,
246{ 246{
247 int ret; 247 int ret;
248 int error; 248 int error;
249 u8 val[3]; 249 u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
250 250
251 ret = i2c_smbus_read_block_data(client, ETP_SMBUS_RESOLUTION_CMD, val); 251 ret = i2c_smbus_read_block_data(client, ETP_SMBUS_RESOLUTION_CMD, val);
252 if (ret != 3) { 252 if (ret != 3) {
@@ -267,7 +267,7 @@ static int elan_smbus_get_num_traces(struct i2c_client *client,
267{ 267{
268 int ret; 268 int ret;
269 int error; 269 int error;
270 u8 val[3]; 270 u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
271 271
272 ret = i2c_smbus_read_block_data(client, ETP_SMBUS_XY_TRACENUM_CMD, val); 272 ret = i2c_smbus_read_block_data(client, ETP_SMBUS_XY_TRACENUM_CMD, val);
273 if (ret != 3) { 273 if (ret != 3) {
@@ -294,7 +294,7 @@ static int elan_smbus_iap_get_mode(struct i2c_client *client,
294{ 294{
295 int error; 295 int error;
296 u16 constant; 296 u16 constant;
297 u8 val[3]; 297 u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
298 298
299 error = i2c_smbus_read_block_data(client, ETP_SMBUS_IAP_CTRL_CMD, val); 299 error = i2c_smbus_read_block_data(client, ETP_SMBUS_IAP_CTRL_CMD, val);
300 if (error < 0) { 300 if (error < 0) {
@@ -345,7 +345,7 @@ static int elan_smbus_prepare_fw_update(struct i2c_client *client)
345 int len; 345 int len;
346 int error; 346 int error;
347 enum tp_mode mode; 347 enum tp_mode mode;
348 u8 val[3]; 348 u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
349 u8 cmd[4] = {0x0F, 0x78, 0x00, 0x06}; 349 u8 cmd[4] = {0x0F, 0x78, 0x00, 0x06};
350 u16 password; 350 u16 password;
351 351
@@ -419,7 +419,7 @@ static int elan_smbus_write_fw_block(struct i2c_client *client,
419 struct device *dev = &client->dev; 419 struct device *dev = &client->dev;
420 int error; 420 int error;
421 u16 result; 421 u16 result;
422 u8 val[3]; 422 u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
423 423
424 /* 424 /*
425 * Due to the limitation of smbus protocol limiting 425 * Due to the limitation of smbus protocol limiting
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 60f2c463d1cc..a9591d278145 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -172,6 +172,12 @@ static const char * const smbus_pnp_ids[] = {
172 "LEN0048", /* X1 Carbon 3 */ 172 "LEN0048", /* X1 Carbon 3 */
173 "LEN0046", /* X250 */ 173 "LEN0046", /* X250 */
174 "LEN004a", /* W541 */ 174 "LEN004a", /* W541 */
175 "LEN0071", /* T480 */
176 "LEN0072", /* X1 Carbon Gen 5 (2017) - Elan/ALPS trackpoint */
177 "LEN0073", /* X1 Carbon G5 (Elantech) */
178 "LEN0092", /* X1 Carbon 6 */
179 "LEN0096", /* X280 */
180 "LEN0097", /* X280 -> ALPS trackpoint */
175 "LEN200f", /* T450s */ 181 "LEN200f", /* T450s */
176 NULL 182 NULL
177}; 183};
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 99b857e5a7a9..b9ca782fe82d 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1447,8 +1447,8 @@ static void __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)
1447 if (ns->lba_shift == 0) 1447 if (ns->lba_shift == 0)
1448 ns->lba_shift = 9; 1448 ns->lba_shift = 9;
1449 ns->noiob = le16_to_cpu(id->noiob); 1449 ns->noiob = le16_to_cpu(id->noiob);
1450 ns->ext = ns->ms && (id->flbas & NVME_NS_FLBAS_META_EXT);
1451 ns->ms = le16_to_cpu(id->lbaf[id->flbas & NVME_NS_FLBAS_LBA_MASK].ms); 1450 ns->ms = le16_to_cpu(id->lbaf[id->flbas & NVME_NS_FLBAS_LBA_MASK].ms);
1451 ns->ext = ns->ms && (id->flbas & NVME_NS_FLBAS_META_EXT);
1452 /* the PI implementation requires metadata equal t10 pi tuple size */ 1452 /* the PI implementation requires metadata equal t10 pi tuple size */
1453 if (ns->ms == sizeof(struct t10_pi_tuple)) 1453 if (ns->ms == sizeof(struct t10_pi_tuple))
1454 ns->pi_type = id->dps & NVME_NS_DPS_PI_MASK; 1454 ns->pi_type = id->dps & NVME_NS_DPS_PI_MASK;
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index a32c5c00e0e7..ffffb9909ae1 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -163,6 +163,16 @@ MODULE_LICENSE("GPL");
163 163
164static const char * const ashs_ids[] = { "ATK4001", "ATK4002", NULL }; 164static const char * const ashs_ids[] = { "ATK4001", "ATK4002", NULL };
165 165
166static bool ashs_present(void)
167{
168 int i = 0;
169 while (ashs_ids[i]) {
170 if (acpi_dev_found(ashs_ids[i++]))
171 return true;
172 }
173 return false;
174}
175
166struct bios_args { 176struct bios_args {
167 u32 arg0; 177 u32 arg0;
168 u32 arg1; 178 u32 arg1;
@@ -1025,6 +1035,9 @@ static int asus_new_rfkill(struct asus_wmi *asus,
1025 1035
1026static void asus_wmi_rfkill_exit(struct asus_wmi *asus) 1036static void asus_wmi_rfkill_exit(struct asus_wmi *asus)
1027{ 1037{
1038 if (asus->driver->wlan_ctrl_by_user && ashs_present())
1039 return;
1040
1028 asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P5"); 1041 asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P5");
1029 asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P6"); 1042 asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P6");
1030 asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P7"); 1043 asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P7");
@@ -2121,16 +2134,6 @@ static int asus_wmi_fan_init(struct asus_wmi *asus)
2121 return 0; 2134 return 0;
2122} 2135}
2123 2136
2124static bool ashs_present(void)
2125{
2126 int i = 0;
2127 while (ashs_ids[i]) {
2128 if (acpi_dev_found(ashs_ids[i++]))
2129 return true;
2130 }
2131 return false;
2132}
2133
2134/* 2137/*
2135 * WMI Driver 2138 * WMI Driver
2136 */ 2139 */
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 04143c08bd6e..02c03e418c27 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -3034,7 +3034,8 @@ static blk_status_t do_dasd_request(struct blk_mq_hw_ctx *hctx,
3034 cqr->callback_data = req; 3034 cqr->callback_data = req;
3035 cqr->status = DASD_CQR_FILLED; 3035 cqr->status = DASD_CQR_FILLED;
3036 cqr->dq = dq; 3036 cqr->dq = dq;
3037 req->completion_data = cqr; 3037 *((struct dasd_ccw_req **) blk_mq_rq_to_pdu(req)) = cqr;
3038
3038 blk_mq_start_request(req); 3039 blk_mq_start_request(req);
3039 spin_lock(&block->queue_lock); 3040 spin_lock(&block->queue_lock);
3040 list_add_tail(&cqr->blocklist, &block->ccw_queue); 3041 list_add_tail(&cqr->blocklist, &block->ccw_queue);
@@ -3058,12 +3059,13 @@ out:
3058 */ 3059 */
3059enum blk_eh_timer_return dasd_times_out(struct request *req, bool reserved) 3060enum blk_eh_timer_return dasd_times_out(struct request *req, bool reserved)
3060{ 3061{
3061 struct dasd_ccw_req *cqr = req->completion_data;
3062 struct dasd_block *block = req->q->queuedata; 3062 struct dasd_block *block = req->q->queuedata;
3063 struct dasd_device *device; 3063 struct dasd_device *device;
3064 struct dasd_ccw_req *cqr;
3064 unsigned long flags; 3065 unsigned long flags;
3065 int rc = 0; 3066 int rc = 0;
3066 3067
3068 cqr = *((struct dasd_ccw_req **) blk_mq_rq_to_pdu(req));
3067 if (!cqr) 3069 if (!cqr)
3068 return BLK_EH_NOT_HANDLED; 3070 return BLK_EH_NOT_HANDLED;
3069 3071
@@ -3169,6 +3171,7 @@ static int dasd_alloc_queue(struct dasd_block *block)
3169 int rc; 3171 int rc;
3170 3172
3171 block->tag_set.ops = &dasd_mq_ops; 3173 block->tag_set.ops = &dasd_mq_ops;
3174 block->tag_set.cmd_size = sizeof(struct dasd_ccw_req *);
3172 block->tag_set.nr_hw_queues = DASD_NR_HW_QUEUES; 3175 block->tag_set.nr_hw_queues = DASD_NR_HW_QUEUES;
3173 block->tag_set.queue_depth = DASD_MAX_LCU_DEV * DASD_REQ_PER_DEV; 3176 block->tag_set.queue_depth = DASD_MAX_LCU_DEV * DASD_REQ_PER_DEV;
3174 block->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; 3177 block->tag_set.flags = BLK_MQ_F_SHOULD_MERGE;
diff --git a/fs/afs/security.c b/fs/afs/security.c
index 1992b0ffa543..81dfedb7879f 100644
--- a/fs/afs/security.c
+++ b/fs/afs/security.c
@@ -372,18 +372,14 @@ int afs_permission(struct inode *inode, int mask)
372 mask, access, S_ISDIR(inode->i_mode) ? "dir" : "file"); 372 mask, access, S_ISDIR(inode->i_mode) ? "dir" : "file");
373 373
374 if (S_ISDIR(inode->i_mode)) { 374 if (S_ISDIR(inode->i_mode)) {
375 if (mask & MAY_EXEC) { 375 if (mask & (MAY_EXEC | MAY_READ | MAY_CHDIR)) {
376 if (!(access & AFS_ACE_LOOKUP)) 376 if (!(access & AFS_ACE_LOOKUP))
377 goto permission_denied; 377 goto permission_denied;
378 } else if (mask & MAY_READ) { 378 }
379 if (!(access & AFS_ACE_LOOKUP)) 379 if (mask & MAY_WRITE) {
380 goto permission_denied;
381 } else if (mask & MAY_WRITE) {
382 if (!(access & (AFS_ACE_DELETE | /* rmdir, unlink, rename from */ 380 if (!(access & (AFS_ACE_DELETE | /* rmdir, unlink, rename from */
383 AFS_ACE_INSERT))) /* create, mkdir, symlink, rename to */ 381 AFS_ACE_INSERT))) /* create, mkdir, symlink, rename to */
384 goto permission_denied; 382 goto permission_denied;
385 } else {
386 BUG();
387 } 383 }
388 } else { 384 } else {
389 if (!(access & AFS_ACE_LOOKUP)) 385 if (!(access & AFS_ACE_LOOKUP))
diff --git a/fs/afs/vlclient.c b/fs/afs/vlclient.c
index 1ed7e2fd2f35..c3b740813fc7 100644
--- a/fs/afs/vlclient.c
+++ b/fs/afs/vlclient.c
@@ -23,7 +23,7 @@ static int afs_deliver_vl_get_entry_by_name_u(struct afs_call *call)
23 struct afs_uvldbentry__xdr *uvldb; 23 struct afs_uvldbentry__xdr *uvldb;
24 struct afs_vldb_entry *entry; 24 struct afs_vldb_entry *entry;
25 bool new_only = false; 25 bool new_only = false;
26 u32 tmp, nr_servers; 26 u32 tmp, nr_servers, vlflags;
27 int i, ret; 27 int i, ret;
28 28
29 _enter(""); 29 _enter("");
@@ -55,6 +55,7 @@ static int afs_deliver_vl_get_entry_by_name_u(struct afs_call *call)
55 new_only = true; 55 new_only = true;
56 } 56 }
57 57
58 vlflags = ntohl(uvldb->flags);
58 for (i = 0; i < nr_servers; i++) { 59 for (i = 0; i < nr_servers; i++) {
59 struct afs_uuid__xdr *xdr; 60 struct afs_uuid__xdr *xdr;
60 struct afs_uuid *uuid; 61 struct afs_uuid *uuid;
@@ -64,12 +65,13 @@ static int afs_deliver_vl_get_entry_by_name_u(struct afs_call *call)
64 if (tmp & AFS_VLSF_DONTUSE || 65 if (tmp & AFS_VLSF_DONTUSE ||
65 (new_only && !(tmp & AFS_VLSF_NEWREPSITE))) 66 (new_only && !(tmp & AFS_VLSF_NEWREPSITE)))
66 continue; 67 continue;
67 if (tmp & AFS_VLSF_RWVOL) 68 if (tmp & AFS_VLSF_RWVOL) {
68 entry->fs_mask[i] |= AFS_VOL_VTM_RW; 69 entry->fs_mask[i] |= AFS_VOL_VTM_RW;
70 if (vlflags & AFS_VLF_BACKEXISTS)
71 entry->fs_mask[i] |= AFS_VOL_VTM_BAK;
72 }
69 if (tmp & AFS_VLSF_ROVOL) 73 if (tmp & AFS_VLSF_ROVOL)
70 entry->fs_mask[i] |= AFS_VOL_VTM_RO; 74 entry->fs_mask[i] |= AFS_VOL_VTM_RO;
71 if (tmp & AFS_VLSF_BACKVOL)
72 entry->fs_mask[i] |= AFS_VOL_VTM_BAK;
73 if (!entry->fs_mask[i]) 75 if (!entry->fs_mask[i])
74 continue; 76 continue;
75 77
@@ -89,15 +91,14 @@ static int afs_deliver_vl_get_entry_by_name_u(struct afs_call *call)
89 for (i = 0; i < AFS_MAXTYPES; i++) 91 for (i = 0; i < AFS_MAXTYPES; i++)
90 entry->vid[i] = ntohl(uvldb->volumeId[i]); 92 entry->vid[i] = ntohl(uvldb->volumeId[i]);
91 93
92 tmp = ntohl(uvldb->flags); 94 if (vlflags & AFS_VLF_RWEXISTS)
93 if (tmp & AFS_VLF_RWEXISTS)
94 __set_bit(AFS_VLDB_HAS_RW, &entry->flags); 95 __set_bit(AFS_VLDB_HAS_RW, &entry->flags);
95 if (tmp & AFS_VLF_ROEXISTS) 96 if (vlflags & AFS_VLF_ROEXISTS)
96 __set_bit(AFS_VLDB_HAS_RO, &entry->flags); 97 __set_bit(AFS_VLDB_HAS_RO, &entry->flags);
97 if (tmp & AFS_VLF_BACKEXISTS) 98 if (vlflags & AFS_VLF_BACKEXISTS)
98 __set_bit(AFS_VLDB_HAS_BAK, &entry->flags); 99 __set_bit(AFS_VLDB_HAS_BAK, &entry->flags);
99 100
100 if (!(tmp & (AFS_VLF_RWEXISTS | AFS_VLF_ROEXISTS | AFS_VLF_BACKEXISTS))) { 101 if (!(vlflags & (AFS_VLF_RWEXISTS | AFS_VLF_ROEXISTS | AFS_VLF_BACKEXISTS))) {
101 entry->error = -ENOMEDIUM; 102 entry->error = -ENOMEDIUM;
102 __set_bit(AFS_VLDB_QUERY_ERROR, &entry->flags); 103 __set_bit(AFS_VLDB_QUERY_ERROR, &entry->flags);
103 } 104 }
diff --git a/fs/inode.c b/fs/inode.c
index 13ceb98c3bd3..3b55391072f3 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -178,6 +178,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
178 mapping->a_ops = &empty_aops; 178 mapping->a_ops = &empty_aops;
179 mapping->host = inode; 179 mapping->host = inode;
180 mapping->flags = 0; 180 mapping->flags = 0;
181 mapping->wb_err = 0;
181 atomic_set(&mapping->i_mmap_writable, 0); 182 atomic_set(&mapping->i_mmap_writable, 0);
182 mapping_set_gfp_mask(mapping, GFP_HIGHUSER_MOVABLE); 183 mapping_set_gfp_mask(mapping, GFP_HIGHUSER_MOVABLE);
183 mapping->private_data = NULL; 184 mapping->private_data = NULL;
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 414d7210b2ec..bcd93031d042 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -893,7 +893,7 @@ int __trace_bputs(unsigned long ip, const char *str)
893EXPORT_SYMBOL_GPL(__trace_bputs); 893EXPORT_SYMBOL_GPL(__trace_bputs);
894 894
895#ifdef CONFIG_TRACER_SNAPSHOT 895#ifdef CONFIG_TRACER_SNAPSHOT
896static void tracing_snapshot_instance(struct trace_array *tr) 896void tracing_snapshot_instance(struct trace_array *tr)
897{ 897{
898 struct tracer *tracer = tr->current_trace; 898 struct tracer *tracer = tr->current_trace;
899 unsigned long flags; 899 unsigned long flags;
@@ -949,7 +949,7 @@ static int resize_buffer_duplicate_size(struct trace_buffer *trace_buf,
949 struct trace_buffer *size_buf, int cpu_id); 949 struct trace_buffer *size_buf, int cpu_id);
950static void set_buffer_entries(struct trace_buffer *buf, unsigned long val); 950static void set_buffer_entries(struct trace_buffer *buf, unsigned long val);
951 951
952static int alloc_snapshot(struct trace_array *tr) 952int tracing_alloc_snapshot_instance(struct trace_array *tr)
953{ 953{
954 int ret; 954 int ret;
955 955
@@ -995,7 +995,7 @@ int tracing_alloc_snapshot(void)
995 struct trace_array *tr = &global_trace; 995 struct trace_array *tr = &global_trace;
996 int ret; 996 int ret;
997 997
998 ret = alloc_snapshot(tr); 998 ret = tracing_alloc_snapshot_instance(tr);
999 WARN_ON(ret < 0); 999 WARN_ON(ret < 0);
1000 1000
1001 return ret; 1001 return ret;
@@ -5408,7 +5408,7 @@ static int tracing_set_tracer(struct trace_array *tr, const char *buf)
5408 5408
5409#ifdef CONFIG_TRACER_MAX_TRACE 5409#ifdef CONFIG_TRACER_MAX_TRACE
5410 if (t->use_max_tr && !had_max_tr) { 5410 if (t->use_max_tr && !had_max_tr) {
5411 ret = alloc_snapshot(tr); 5411 ret = tracing_alloc_snapshot_instance(tr);
5412 if (ret < 0) 5412 if (ret < 0)
5413 goto out; 5413 goto out;
5414 } 5414 }
@@ -6451,7 +6451,7 @@ tracing_snapshot_write(struct file *filp, const char __user *ubuf, size_t cnt,
6451 } 6451 }
6452#endif 6452#endif
6453 if (!tr->allocated_snapshot) { 6453 if (!tr->allocated_snapshot) {
6454 ret = alloc_snapshot(tr); 6454 ret = tracing_alloc_snapshot_instance(tr);
6455 if (ret < 0) 6455 if (ret < 0)
6456 break; 6456 break;
6457 } 6457 }
@@ -7179,7 +7179,7 @@ ftrace_trace_snapshot_callback(struct trace_array *tr, struct ftrace_hash *hash,
7179 return ret; 7179 return ret;
7180 7180
7181 out_reg: 7181 out_reg:
7182 ret = alloc_snapshot(tr); 7182 ret = tracing_alloc_snapshot_instance(tr);
7183 if (ret < 0) 7183 if (ret < 0)
7184 goto out; 7184 goto out;
7185 7185
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 6fb46a06c9dc..507954b4e058 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -1817,6 +1817,17 @@ static inline void __init trace_event_init(void) { }
1817static inline void trace_event_eval_update(struct trace_eval_map **map, int len) { } 1817static inline void trace_event_eval_update(struct trace_eval_map **map, int len) { }
1818#endif 1818#endif
1819 1819
1820#ifdef CONFIG_TRACER_SNAPSHOT
1821void tracing_snapshot_instance(struct trace_array *tr);
1822int tracing_alloc_snapshot_instance(struct trace_array *tr);
1823#else
1824static inline void tracing_snapshot_instance(struct trace_array *tr) { }
1825static inline int tracing_alloc_snapshot_instance(struct trace_array *tr)
1826{
1827 return 0;
1828}
1829#endif
1830
1820extern struct trace_iterator *tracepoint_print_iter; 1831extern struct trace_iterator *tracepoint_print_iter;
1821 1832
1822#endif /* _LINUX_KERNEL_TRACE_H */ 1833#endif /* _LINUX_KERNEL_TRACE_H */
diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
index d251cabcf69a..8b5bdcf64871 100644
--- a/kernel/trace/trace_events_trigger.c
+++ b/kernel/trace/trace_events_trigger.c
@@ -483,9 +483,10 @@ clear_event_triggers(struct trace_array *tr)
483 struct trace_event_file *file; 483 struct trace_event_file *file;
484 484
485 list_for_each_entry(file, &tr->events, list) { 485 list_for_each_entry(file, &tr->events, list) {
486 struct event_trigger_data *data; 486 struct event_trigger_data *data, *n;
487 list_for_each_entry_rcu(data, &file->triggers, list) { 487 list_for_each_entry_safe(data, n, &file->triggers, list) {
488 trace_event_trigger_enable_disable(file, 0); 488 trace_event_trigger_enable_disable(file, 0);
489 list_del_rcu(&data->list);
489 if (data->ops->free) 490 if (data->ops->free)
490 data->ops->free(data->ops, data); 491 data->ops->free(data->ops, data);
491 } 492 }
@@ -642,6 +643,7 @@ event_trigger_callback(struct event_command *cmd_ops,
642 trigger_data->count = -1; 643 trigger_data->count = -1;
643 trigger_data->ops = trigger_ops; 644 trigger_data->ops = trigger_ops;
644 trigger_data->cmd_ops = cmd_ops; 645 trigger_data->cmd_ops = cmd_ops;
646 trigger_data->private_data = file;
645 INIT_LIST_HEAD(&trigger_data->list); 647 INIT_LIST_HEAD(&trigger_data->list);
646 INIT_LIST_HEAD(&trigger_data->named_list); 648 INIT_LIST_HEAD(&trigger_data->named_list);
647 649
@@ -1053,7 +1055,12 @@ static void
1053snapshot_trigger(struct event_trigger_data *data, void *rec, 1055snapshot_trigger(struct event_trigger_data *data, void *rec,
1054 struct ring_buffer_event *event) 1056 struct ring_buffer_event *event)
1055{ 1057{
1056 tracing_snapshot(); 1058 struct trace_event_file *file = data->private_data;
1059
1060 if (file)
1061 tracing_snapshot_instance(file->tr);
1062 else
1063 tracing_snapshot();
1057} 1064}
1058 1065
1059static void 1066static void
@@ -1076,7 +1083,7 @@ register_snapshot_trigger(char *glob, struct event_trigger_ops *ops,
1076{ 1083{
1077 int ret = register_trigger(glob, ops, data, file); 1084 int ret = register_trigger(glob, ops, data, file);
1078 1085
1079 if (ret > 0 && tracing_alloc_snapshot() != 0) { 1086 if (ret > 0 && tracing_alloc_snapshot_instance(file->tr) != 0) {
1080 unregister_trigger(glob, ops, data, file); 1087 unregister_trigger(glob, ops, data, file);
1081 ret = 0; 1088 ret = 0;
1082 } 1089 }
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index 8057e19dc15f..3ce225e3f142 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -1494,7 +1494,7 @@ static int security_context_to_sid_core(struct selinux_state *state,
1494 scontext_len, &context, def_sid); 1494 scontext_len, &context, def_sid);
1495 if (rc == -EINVAL && force) { 1495 if (rc == -EINVAL && force) {
1496 context.str = str; 1496 context.str = str;
1497 context.len = scontext_len; 1497 context.len = strlen(str) + 1;
1498 str = NULL; 1498 str = NULL;
1499 } else if (rc) 1499 } else if (rc)
1500 goto out_unlock; 1500 goto out_unlock;
diff --git a/tools/power/x86/turbostat/Makefile b/tools/power/x86/turbostat/Makefile
index a9bc914a8fe8..2ab25aa38263 100644
--- a/tools/power/x86/turbostat/Makefile
+++ b/tools/power/x86/turbostat/Makefile
@@ -25,4 +25,4 @@ install : turbostat
25 install -d $(DESTDIR)$(PREFIX)/bin 25 install -d $(DESTDIR)$(PREFIX)/bin
26 install $(BUILD_OUTPUT)/turbostat $(DESTDIR)$(PREFIX)/bin/turbostat 26 install $(BUILD_OUTPUT)/turbostat $(DESTDIR)$(PREFIX)/bin/turbostat
27 install -d $(DESTDIR)$(PREFIX)/share/man/man8 27 install -d $(DESTDIR)$(PREFIX)/share/man/man8
28 install turbostat.8 $(DESTDIR)$(PREFIX)/share/man/man8 28 install -m 644 turbostat.8 $(DESTDIR)$(PREFIX)/share/man/man8
diff --git a/tools/power/x86/turbostat/turbostat.8 b/tools/power/x86/turbostat/turbostat.8
index ccf2a69365cc..ca9ef7017624 100644
--- a/tools/power/x86/turbostat/turbostat.8
+++ b/tools/power/x86/turbostat/turbostat.8
@@ -54,9 +54,12 @@ name as necessary to disambiguate it from others is necessary. Note that option
54.PP 54.PP
55\fB--cpu cpu-set\fP limit output to system summary plus the specified cpu-set. If cpu-set is the string "core", then the system summary plus the first CPU in each core are printed -- eg. subsequent HT siblings are not printed. Or if cpu-set is the string "package", then the system summary plus the first CPU in each package is printed. Otherwise, the system summary plus the specified set of CPUs are printed. The cpu-set is ordered from low to high, comma delimited with ".." and "-" permitted to denote a range. eg. 1,2,8,14..17,21-44 55\fB--cpu cpu-set\fP limit output to system summary plus the specified cpu-set. If cpu-set is the string "core", then the system summary plus the first CPU in each core are printed -- eg. subsequent HT siblings are not printed. Or if cpu-set is the string "package", then the system summary plus the first CPU in each package is printed. Otherwise, the system summary plus the specified set of CPUs are printed. The cpu-set is ordered from low to high, comma delimited with ".." and "-" permitted to denote a range. eg. 1,2,8,14..17,21-44
56.PP 56.PP
57\fB--hide column\fP do not show the specified columns. May be invoked multiple times, or with a comma-separated list of column names. Use "--hide sysfs" to hide the sysfs statistics columns as a group. 57\fB--hide column\fP do not show the specified built-in columns. May be invoked multiple times, or with a comma-separated list of column names. Use "--hide sysfs" to hide the sysfs statistics columns as a group.
58.PP 58.PP
59\fB--show column\fP show only the specified columns. May be invoked multiple times, or with a comma-separated list of column names. Use "--show sysfs" to show the sysfs statistics columns as a group. 59\fB--enable column\fP show the specified built-in columns, which are otherwise disabled, by default. Currently the only built-in counters disabled by default are "usec" and "Time_Of_Day_Seconds".
60The column name "all" can be used to enable all disabled-by-default built-in counters.
61.PP
62\fB--show column\fP show only the specified built-in columns. May be invoked multiple times, or with a comma-separated list of column names. Use "--show sysfs" to show the sysfs statistics columns as a group.
60.PP 63.PP
61\fB--Dump\fP displays the raw counter values. 64\fB--Dump\fP displays the raw counter values.
62.PP 65.PP
@@ -64,6 +67,8 @@ name as necessary to disambiguate it from others is necessary. Note that option
64.PP 67.PP
65\fB--interval seconds\fP overrides the default 5.0 second measurement interval. 68\fB--interval seconds\fP overrides the default 5.0 second measurement interval.
66.PP 69.PP
70\fB--num_iterations num\fP number of the measurement iterations.
71.PP
67\fB--out output_file\fP turbostat output is written to the specified output_file. 72\fB--out output_file\fP turbostat output is written to the specified output_file.
68The file is truncated if it already exists, and it is created if it does not exist. 73The file is truncated if it already exists, and it is created if it does not exist.
69.PP 74.PP
@@ -86,6 +91,8 @@ displays the statistics gathered since it was forked.
86The system configuration dump (if --quiet is not used) is followed by statistics. The first row of the statistics labels the content of each column (below). The second row of statistics is the system summary line. The system summary line has a '-' in the columns for the Package, Core, and CPU. The contents of the system summary line depends on the type of column. Columns that count items (eg. IRQ) show the sum across all CPUs in the system. Columns that show a percentage show the average across all CPUs in the system. Columns that dump raw MSR values simply show 0 in the summary. After the system summary row, each row describes a specific Package/Core/CPU. Note that if the --cpu parameter is used to limit which specific CPUs are displayed, turbostat will still collect statistics for all CPUs in the system and will still show the system summary for all CPUs in the system. 91The system configuration dump (if --quiet is not used) is followed by statistics. The first row of the statistics labels the content of each column (below). The second row of statistics is the system summary line. The system summary line has a '-' in the columns for the Package, Core, and CPU. The contents of the system summary line depends on the type of column. Columns that count items (eg. IRQ) show the sum across all CPUs in the system. Columns that show a percentage show the average across all CPUs in the system. Columns that dump raw MSR values simply show 0 in the summary. After the system summary row, each row describes a specific Package/Core/CPU. Note that if the --cpu parameter is used to limit which specific CPUs are displayed, turbostat will still collect statistics for all CPUs in the system and will still show the system summary for all CPUs in the system.
87.SH COLUMN DESCRIPTIONS 92.SH COLUMN DESCRIPTIONS
88.nf 93.nf
94\fBusec\fP For each CPU, the number of microseconds elapsed during counter collection, including thread migration -- if any. This counter is disabled by default, and is enabled with "--enable usec", or --debug. On the summary row, usec refers to the total elapsed time to collect the counters on all cpus.
95\fBTime_Of_Day_Seconds\fP For each CPU, the gettimeofday(2) value (seconds.subsec since Epoch) when the counters ending the measurement interval were collected. This column is disabled by default, and can be enabled with "--enable Time_Of_Day_Seconds" or "--debug". On the summary row, Time_Of_Day_Seconds refers to the timestamp following collection of counters on the last CPU.
89\fBCore\fP processor core number. Note that multiple CPUs per core indicate support for Intel(R) Hyper-Threading Technology (HT). 96\fBCore\fP processor core number. Note that multiple CPUs per core indicate support for Intel(R) Hyper-Threading Technology (HT).
90\fBCPU\fP Linux CPU (logical processor) number. Yes, it is okay that on many systems the CPUs are not listed in numerical order -- for efficiency reasons, turbostat runs in topology order, so HT siblings appear together. 97\fBCPU\fP Linux CPU (logical processor) number. Yes, it is okay that on many systems the CPUs are not listed in numerical order -- for efficiency reasons, turbostat runs in topology order, so HT siblings appear together.
91\fBPackage\fP processor package number -- not present on systems with a single processor package. 98\fBPackage\fP processor package number -- not present on systems with a single processor package.
@@ -262,6 +269,21 @@ CPU PRF_CTRL
262 269
263.fi 270.fi
264 271
272.SH INPUT
273
274For interval-mode, turbostat will immediately end the current interval
275when it sees a newline on standard input.
276turbostat will then start the next interval.
277Control-C will be send a SIGINT to turbostat,
278which will immediately abort the program with no further processing.
279.SH SIGNALS
280
281SIGINT will interrupt interval-mode.
282The end-of-interval data will be collected and displayed before turbostat exits.
283
284SIGUSR1 will end current interval,
285end-of-interval data will be collected and displayed before turbostat
286starts a new interval.
265.SH NOTES 287.SH NOTES
266 288
267.B "turbostat " 289.B "turbostat "
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index bd9c6b31a504..d6cff3070ebd 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -29,6 +29,7 @@
29#include <sys/types.h> 29#include <sys/types.h>
30#include <sys/wait.h> 30#include <sys/wait.h>
31#include <sys/stat.h> 31#include <sys/stat.h>
32#include <sys/select.h>
32#include <sys/resource.h> 33#include <sys/resource.h>
33#include <fcntl.h> 34#include <fcntl.h>
34#include <signal.h> 35#include <signal.h>
@@ -47,9 +48,13 @@
47char *proc_stat = "/proc/stat"; 48char *proc_stat = "/proc/stat";
48FILE *outf; 49FILE *outf;
49int *fd_percpu; 50int *fd_percpu;
51struct timeval interval_tv = {5, 0};
50struct timespec interval_ts = {5, 0}; 52struct timespec interval_ts = {5, 0};
53struct timespec one_msec = {0, 1000000};
54unsigned int num_iterations;
51unsigned int debug; 55unsigned int debug;
52unsigned int quiet; 56unsigned int quiet;
57unsigned int shown;
53unsigned int sums_need_wide_columns; 58unsigned int sums_need_wide_columns;
54unsigned int rapl_joules; 59unsigned int rapl_joules;
55unsigned int summary_only; 60unsigned int summary_only;
@@ -58,6 +63,7 @@ unsigned int dump_only;
58unsigned int do_snb_cstates; 63unsigned int do_snb_cstates;
59unsigned int do_knl_cstates; 64unsigned int do_knl_cstates;
60unsigned int do_slm_cstates; 65unsigned int do_slm_cstates;
66unsigned int do_cnl_cstates;
61unsigned int use_c1_residency_msr; 67unsigned int use_c1_residency_msr;
62unsigned int has_aperf; 68unsigned int has_aperf;
63unsigned int has_epb; 69unsigned int has_epb;
@@ -80,6 +86,8 @@ unsigned int do_rapl;
80unsigned int do_dts; 86unsigned int do_dts;
81unsigned int do_ptm; 87unsigned int do_ptm;
82unsigned long long gfx_cur_rc6_ms; 88unsigned long long gfx_cur_rc6_ms;
89unsigned long long cpuidle_cur_cpu_lpi_us;
90unsigned long long cpuidle_cur_sys_lpi_us;
83unsigned int gfx_cur_mhz; 91unsigned int gfx_cur_mhz;
84unsigned int tcc_activation_temp; 92unsigned int tcc_activation_temp;
85unsigned int tcc_activation_temp_override; 93unsigned int tcc_activation_temp_override;
@@ -87,6 +95,7 @@ double rapl_power_units, rapl_time_units;
87double rapl_dram_energy_units, rapl_energy_units; 95double rapl_dram_energy_units, rapl_energy_units;
88double rapl_joule_counter_range; 96double rapl_joule_counter_range;
89unsigned int do_core_perf_limit_reasons; 97unsigned int do_core_perf_limit_reasons;
98unsigned int has_automatic_cstate_conversion;
90unsigned int do_gfx_perf_limit_reasons; 99unsigned int do_gfx_perf_limit_reasons;
91unsigned int do_ring_perf_limit_reasons; 100unsigned int do_ring_perf_limit_reasons;
92unsigned int crystal_hz; 101unsigned int crystal_hz;
@@ -147,7 +156,9 @@ char *progname;
147#define CPU_SUBSET_MAXCPUS 1024 /* need to use before probe... */ 156#define CPU_SUBSET_MAXCPUS 1024 /* need to use before probe... */
148cpu_set_t *cpu_present_set, *cpu_affinity_set, *cpu_subset; 157cpu_set_t *cpu_present_set, *cpu_affinity_set, *cpu_subset;
149size_t cpu_present_setsize, cpu_affinity_setsize, cpu_subset_size; 158size_t cpu_present_setsize, cpu_affinity_setsize, cpu_subset_size;
150#define MAX_ADDED_COUNTERS 16 159#define MAX_ADDED_COUNTERS 8
160#define MAX_ADDED_THREAD_COUNTERS 24
161#define BITMASK_SIZE 32
151 162
152struct thread_data { 163struct thread_data {
153 struct timeval tv_begin; 164 struct timeval tv_begin;
@@ -162,7 +173,7 @@ struct thread_data {
162 unsigned int flags; 173 unsigned int flags;
163#define CPU_IS_FIRST_THREAD_IN_CORE 0x2 174#define CPU_IS_FIRST_THREAD_IN_CORE 0x2
164#define CPU_IS_FIRST_CORE_IN_PACKAGE 0x4 175#define CPU_IS_FIRST_CORE_IN_PACKAGE 0x4
165 unsigned long long counter[MAX_ADDED_COUNTERS]; 176 unsigned long long counter[MAX_ADDED_THREAD_COUNTERS];
166} *thread_even, *thread_odd; 177} *thread_even, *thread_odd;
167 178
168struct core_data { 179struct core_data {
@@ -183,6 +194,8 @@ struct pkg_data {
183 unsigned long long pc8; 194 unsigned long long pc8;
184 unsigned long long pc9; 195 unsigned long long pc9;
185 unsigned long long pc10; 196 unsigned long long pc10;
197 unsigned long long cpu_lpi;
198 unsigned long long sys_lpi;
186 unsigned long long pkg_wtd_core_c0; 199 unsigned long long pkg_wtd_core_c0;
187 unsigned long long pkg_any_core_c0; 200 unsigned long long pkg_any_core_c0;
188 unsigned long long pkg_any_gfxe_c0; 201 unsigned long long pkg_any_gfxe_c0;
@@ -203,12 +216,21 @@ struct pkg_data {
203#define ODD_COUNTERS thread_odd, core_odd, package_odd 216#define ODD_COUNTERS thread_odd, core_odd, package_odd
204#define EVEN_COUNTERS thread_even, core_even, package_even 217#define EVEN_COUNTERS thread_even, core_even, package_even
205 218
206#define GET_THREAD(thread_base, thread_no, core_no, pkg_no) \ 219#define GET_THREAD(thread_base, thread_no, core_no, node_no, pkg_no) \
207 (thread_base + (pkg_no) * topo.num_cores_per_pkg * \ 220 ((thread_base) + \
208 topo.num_threads_per_core + \ 221 ((pkg_no) * \
209 (core_no) * topo.num_threads_per_core + (thread_no)) 222 topo.nodes_per_pkg * topo.cores_per_node * topo.threads_per_core) + \
210#define GET_CORE(core_base, core_no, pkg_no) \ 223 ((node_no) * topo.cores_per_node * topo.threads_per_core) + \
211 (core_base + (pkg_no) * topo.num_cores_per_pkg + (core_no)) 224 ((core_no) * topo.threads_per_core) + \
225 (thread_no))
226
227#define GET_CORE(core_base, core_no, node_no, pkg_no) \
228 ((core_base) + \
229 ((pkg_no) * topo.nodes_per_pkg * topo.cores_per_node) + \
230 ((node_no) * topo.cores_per_node) + \
231 (core_no))
232
233
212#define GET_PKG(pkg_base, pkg_no) (pkg_base + pkg_no) 234#define GET_PKG(pkg_base, pkg_no) (pkg_base + pkg_no)
213 235
214enum counter_scope {SCOPE_CPU, SCOPE_CORE, SCOPE_PACKAGE}; 236enum counter_scope {SCOPE_CPU, SCOPE_CORE, SCOPE_PACKAGE};
@@ -244,14 +266,25 @@ struct system_summary {
244 struct pkg_data packages; 266 struct pkg_data packages;
245} average; 267} average;
246 268
269struct cpu_topology {
270 int physical_package_id;
271 int logical_cpu_id;
272 int physical_node_id;
273 int logical_node_id; /* 0-based count within the package */
274 int physical_core_id;
275 int thread_id;
276 cpu_set_t *put_ids; /* Processing Unit/Thread IDs */
277} *cpus;
247 278
248struct topo_params { 279struct topo_params {
249 int num_packages; 280 int num_packages;
250 int num_cpus; 281 int num_cpus;
251 int num_cores; 282 int num_cores;
252 int max_cpu_num; 283 int max_cpu_num;
253 int num_cores_per_pkg; 284 int max_node_num;
254 int num_threads_per_core; 285 int nodes_per_pkg;
286 int cores_per_node;
287 int threads_per_core;
255} topo; 288} topo;
256 289
257struct timeval tv_even, tv_odd, tv_delta; 290struct timeval tv_even, tv_odd, tv_delta;
@@ -273,27 +306,33 @@ int cpu_is_not_present(int cpu)
273int for_all_cpus(int (func)(struct thread_data *, struct core_data *, struct pkg_data *), 306int for_all_cpus(int (func)(struct thread_data *, struct core_data *, struct pkg_data *),
274 struct thread_data *thread_base, struct core_data *core_base, struct pkg_data *pkg_base) 307 struct thread_data *thread_base, struct core_data *core_base, struct pkg_data *pkg_base)
275{ 308{
276 int retval, pkg_no, core_no, thread_no; 309 int retval, pkg_no, core_no, thread_no, node_no;
277 310
278 for (pkg_no = 0; pkg_no < topo.num_packages; ++pkg_no) { 311 for (pkg_no = 0; pkg_no < topo.num_packages; ++pkg_no) {
279 for (core_no = 0; core_no < topo.num_cores_per_pkg; ++core_no) { 312 for (core_no = 0; core_no < topo.cores_per_node; ++core_no) {
280 for (thread_no = 0; thread_no < 313 for (node_no = 0; node_no < topo.nodes_per_pkg;
281 topo.num_threads_per_core; ++thread_no) { 314 node_no++) {
282 struct thread_data *t; 315 for (thread_no = 0; thread_no <
283 struct core_data *c; 316 topo.threads_per_core; ++thread_no) {
284 struct pkg_data *p; 317 struct thread_data *t;
285 318 struct core_data *c;
286 t = GET_THREAD(thread_base, thread_no, core_no, pkg_no); 319 struct pkg_data *p;
287 320
288 if (cpu_is_not_present(t->cpu_id)) 321 t = GET_THREAD(thread_base, thread_no,
289 continue; 322 core_no, node_no,
290 323 pkg_no);
291 c = GET_CORE(core_base, core_no, pkg_no); 324
292 p = GET_PKG(pkg_base, pkg_no); 325 if (cpu_is_not_present(t->cpu_id))
293 326 continue;
294 retval = func(t, c, p); 327
295 if (retval) 328 c = GET_CORE(core_base, core_no,
296 return retval; 329 node_no, pkg_no);
330 p = GET_PKG(pkg_base, pkg_no);
331
332 retval = func(t, c, p);
333 if (retval)
334 return retval;
335 }
297 } 336 }
298 } 337 }
299 } 338 }
@@ -346,6 +385,8 @@ int get_msr(int cpu, off_t offset, unsigned long long *msr)
346 * Thus, strings that are proper sub-sets must follow their more specific peers. 385 * Thus, strings that are proper sub-sets must follow their more specific peers.
347 */ 386 */
348struct msr_counter bic[] = { 387struct msr_counter bic[] = {
388 { 0x0, "usec" },
389 { 0x0, "Time_Of_Day_Seconds" },
349 { 0x0, "Package" }, 390 { 0x0, "Package" },
350 { 0x0, "Avg_MHz" }, 391 { 0x0, "Avg_MHz" },
351 { 0x0, "Bzy_MHz" }, 392 { 0x0, "Bzy_MHz" },
@@ -369,7 +410,9 @@ struct msr_counter bic[] = {
369 { 0x0, "Pkg%pc7" }, 410 { 0x0, "Pkg%pc7" },
370 { 0x0, "Pkg%pc8" }, 411 { 0x0, "Pkg%pc8" },
371 { 0x0, "Pkg%pc9" }, 412 { 0x0, "Pkg%pc9" },
372 { 0x0, "Pkg%pc10" }, 413 { 0x0, "Pk%pc10" },
414 { 0x0, "CPU%LPI" },
415 { 0x0, "SYS%LPI" },
373 { 0x0, "PkgWatt" }, 416 { 0x0, "PkgWatt" },
374 { 0x0, "CorWatt" }, 417 { 0x0, "CorWatt" },
375 { 0x0, "GFXWatt" }, 418 { 0x0, "GFXWatt" },
@@ -389,62 +432,72 @@ struct msr_counter bic[] = {
389 { 0x0, "Any%C0" }, 432 { 0x0, "Any%C0" },
390 { 0x0, "GFX%C0" }, 433 { 0x0, "GFX%C0" },
391 { 0x0, "CPUGFX%" }, 434 { 0x0, "CPUGFX%" },
435 { 0x0, "Node%" },
392}; 436};
393 437
394 438
395 439
396#define MAX_BIC (sizeof(bic) / sizeof(struct msr_counter)) 440#define MAX_BIC (sizeof(bic) / sizeof(struct msr_counter))
397#define BIC_Package (1ULL << 0) 441#define BIC_USEC (1ULL << 0)
398#define BIC_Avg_MHz (1ULL << 1) 442#define BIC_TOD (1ULL << 1)
399#define BIC_Bzy_MHz (1ULL << 2) 443#define BIC_Package (1ULL << 2)
400#define BIC_TSC_MHz (1ULL << 3) 444#define BIC_Avg_MHz (1ULL << 3)
401#define BIC_IRQ (1ULL << 4) 445#define BIC_Bzy_MHz (1ULL << 4)
402#define BIC_SMI (1ULL << 5) 446#define BIC_TSC_MHz (1ULL << 5)
403#define BIC_Busy (1ULL << 6) 447#define BIC_IRQ (1ULL << 6)
404#define BIC_CPU_c1 (1ULL << 7) 448#define BIC_SMI (1ULL << 7)
405#define BIC_CPU_c3 (1ULL << 8) 449#define BIC_Busy (1ULL << 8)
406#define BIC_CPU_c6 (1ULL << 9) 450#define BIC_CPU_c1 (1ULL << 9)
407#define BIC_CPU_c7 (1ULL << 10) 451#define BIC_CPU_c3 (1ULL << 10)
408#define BIC_ThreadC (1ULL << 11) 452#define BIC_CPU_c6 (1ULL << 11)
409#define BIC_CoreTmp (1ULL << 12) 453#define BIC_CPU_c7 (1ULL << 12)
410#define BIC_CoreCnt (1ULL << 13) 454#define BIC_ThreadC (1ULL << 13)
411#define BIC_PkgTmp (1ULL << 14) 455#define BIC_CoreTmp (1ULL << 14)
412#define BIC_GFX_rc6 (1ULL << 15) 456#define BIC_CoreCnt (1ULL << 15)
413#define BIC_GFXMHz (1ULL << 16) 457#define BIC_PkgTmp (1ULL << 16)
414#define BIC_Pkgpc2 (1ULL << 17) 458#define BIC_GFX_rc6 (1ULL << 17)
415#define BIC_Pkgpc3 (1ULL << 18) 459#define BIC_GFXMHz (1ULL << 18)
416#define BIC_Pkgpc6 (1ULL << 19) 460#define BIC_Pkgpc2 (1ULL << 19)
417#define BIC_Pkgpc7 (1ULL << 20) 461#define BIC_Pkgpc3 (1ULL << 20)
418#define BIC_Pkgpc8 (1ULL << 21) 462#define BIC_Pkgpc6 (1ULL << 21)
419#define BIC_Pkgpc9 (1ULL << 22) 463#define BIC_Pkgpc7 (1ULL << 22)
420#define BIC_Pkgpc10 (1ULL << 23) 464#define BIC_Pkgpc8 (1ULL << 23)
421#define BIC_PkgWatt (1ULL << 24) 465#define BIC_Pkgpc9 (1ULL << 24)
422#define BIC_CorWatt (1ULL << 25) 466#define BIC_Pkgpc10 (1ULL << 25)
423#define BIC_GFXWatt (1ULL << 26) 467#define BIC_CPU_LPI (1ULL << 26)
424#define BIC_PkgCnt (1ULL << 27) 468#define BIC_SYS_LPI (1ULL << 27)
425#define BIC_RAMWatt (1ULL << 28) 469#define BIC_PkgWatt (1ULL << 26)
426#define BIC_PKG__ (1ULL << 29) 470#define BIC_CorWatt (1ULL << 27)
427#define BIC_RAM__ (1ULL << 30) 471#define BIC_GFXWatt (1ULL << 28)
428#define BIC_Pkg_J (1ULL << 31) 472#define BIC_PkgCnt (1ULL << 29)
429#define BIC_Cor_J (1ULL << 32) 473#define BIC_RAMWatt (1ULL << 30)
430#define BIC_GFX_J (1ULL << 33) 474#define BIC_PKG__ (1ULL << 31)
431#define BIC_RAM_J (1ULL << 34) 475#define BIC_RAM__ (1ULL << 32)
432#define BIC_Core (1ULL << 35) 476#define BIC_Pkg_J (1ULL << 33)
433#define BIC_CPU (1ULL << 36) 477#define BIC_Cor_J (1ULL << 34)
434#define BIC_Mod_c6 (1ULL << 37) 478#define BIC_GFX_J (1ULL << 35)
435#define BIC_sysfs (1ULL << 38) 479#define BIC_RAM_J (1ULL << 36)
436#define BIC_Totl_c0 (1ULL << 39) 480#define BIC_Core (1ULL << 37)
437#define BIC_Any_c0 (1ULL << 40) 481#define BIC_CPU (1ULL << 38)
438#define BIC_GFX_c0 (1ULL << 41) 482#define BIC_Mod_c6 (1ULL << 39)
439#define BIC_CPUGFX (1ULL << 42) 483#define BIC_sysfs (1ULL << 40)
440 484#define BIC_Totl_c0 (1ULL << 41)
441unsigned long long bic_enabled = 0xFFFFFFFFFFFFFFFFULL; 485#define BIC_Any_c0 (1ULL << 42)
442unsigned long long bic_present = BIC_sysfs; 486#define BIC_GFX_c0 (1ULL << 43)
487#define BIC_CPUGFX (1ULL << 44)
488#define BIC_Node (1ULL << 45)
489
490#define BIC_DISABLED_BY_DEFAULT (BIC_USEC | BIC_TOD)
491
492unsigned long long bic_enabled = (0xFFFFFFFFFFFFFFFFULL & ~BIC_DISABLED_BY_DEFAULT);
493unsigned long long bic_present = BIC_USEC | BIC_TOD | BIC_sysfs;
443 494
444#define DO_BIC(COUNTER_NAME) (bic_enabled & bic_present & COUNTER_NAME) 495#define DO_BIC(COUNTER_NAME) (bic_enabled & bic_present & COUNTER_NAME)
496#define ENABLE_BIC(COUNTER_NAME) (bic_enabled |= COUNTER_NAME)
445#define BIC_PRESENT(COUNTER_BIT) (bic_present |= COUNTER_BIT) 497#define BIC_PRESENT(COUNTER_BIT) (bic_present |= COUNTER_BIT)
446#define BIC_NOT_PRESENT(COUNTER_BIT) (bic_present &= ~COUNTER_BIT) 498#define BIC_NOT_PRESENT(COUNTER_BIT) (bic_present &= ~COUNTER_BIT)
447 499
500
448#define MAX_DEFERRED 16 501#define MAX_DEFERRED 16
449char *deferred_skip_names[MAX_DEFERRED]; 502char *deferred_skip_names[MAX_DEFERRED];
450int deferred_skip_index; 503int deferred_skip_index;
@@ -469,9 +522,10 @@ void help(void)
469 "--cpu cpu-set limit output to summary plus cpu-set:\n" 522 "--cpu cpu-set limit output to summary plus cpu-set:\n"
470 " {core | package | j,k,l..m,n-p }\n" 523 " {core | package | j,k,l..m,n-p }\n"
471 "--quiet skip decoding system configuration header\n" 524 "--quiet skip decoding system configuration header\n"
472 "--interval sec Override default 5-second measurement interval\n" 525 "--interval sec.subsec Override default 5-second measurement interval\n"
473 "--help print this help message\n" 526 "--help print this help message\n"
474 "--list list column headers only\n" 527 "--list list column headers only\n"
528 "--num_iterations num number of the measurement iterations\n"
475 "--out file create or truncate \"file\" for all output\n" 529 "--out file create or truncate \"file\" for all output\n"
476 "--version print version information\n" 530 "--version print version information\n"
477 "\n" 531 "\n"
@@ -496,6 +550,9 @@ unsigned long long bic_lookup(char *name_list, enum show_hide_mode mode)
496 if (comma) 550 if (comma)
497 *comma = '\0'; 551 *comma = '\0';
498 552
553 if (!strcmp(name_list, "all"))
554 return ~0;
555
499 for (i = 0; i < MAX_BIC; ++i) { 556 for (i = 0; i < MAX_BIC; ++i) {
500 if (!strcmp(name_list, bic[i].name)) { 557 if (!strcmp(name_list, bic[i].name)) {
501 retval |= (1ULL << i); 558 retval |= (1ULL << i);
@@ -532,10 +589,14 @@ void print_header(char *delim)
532 struct msr_counter *mp; 589 struct msr_counter *mp;
533 int printed = 0; 590 int printed = 0;
534 591
535 if (debug) 592 if (DO_BIC(BIC_USEC))
536 outp += sprintf(outp, "usec %s", delim); 593 outp += sprintf(outp, "%susec", (printed++ ? delim : ""));
594 if (DO_BIC(BIC_TOD))
595 outp += sprintf(outp, "%sTime_Of_Day_Seconds", (printed++ ? delim : ""));
537 if (DO_BIC(BIC_Package)) 596 if (DO_BIC(BIC_Package))
538 outp += sprintf(outp, "%sPackage", (printed++ ? delim : "")); 597 outp += sprintf(outp, "%sPackage", (printed++ ? delim : ""));
598 if (DO_BIC(BIC_Node))
599 outp += sprintf(outp, "%sNode", (printed++ ? delim : ""));
539 if (DO_BIC(BIC_Core)) 600 if (DO_BIC(BIC_Core))
540 outp += sprintf(outp, "%sCore", (printed++ ? delim : "")); 601 outp += sprintf(outp, "%sCore", (printed++ ? delim : ""));
541 if (DO_BIC(BIC_CPU)) 602 if (DO_BIC(BIC_CPU))
@@ -576,7 +637,7 @@ void print_header(char *delim)
576 637
577 if (DO_BIC(BIC_CPU_c1)) 638 if (DO_BIC(BIC_CPU_c1))
578 outp += sprintf(outp, "%sCPU%%c1", (printed++ ? delim : "")); 639 outp += sprintf(outp, "%sCPU%%c1", (printed++ ? delim : ""));
579 if (DO_BIC(BIC_CPU_c3) && !do_slm_cstates && !do_knl_cstates) 640 if (DO_BIC(BIC_CPU_c3) && !do_slm_cstates && !do_knl_cstates && !do_cnl_cstates)
580 outp += sprintf(outp, "%sCPU%%c3", (printed++ ? delim : "")); 641 outp += sprintf(outp, "%sCPU%%c3", (printed++ ? delim : ""));
581 if (DO_BIC(BIC_CPU_c6)) 642 if (DO_BIC(BIC_CPU_c6))
582 outp += sprintf(outp, "%sCPU%%c6", (printed++ ? delim : "")); 643 outp += sprintf(outp, "%sCPU%%c6", (printed++ ? delim : ""));
@@ -635,6 +696,10 @@ void print_header(char *delim)
635 outp += sprintf(outp, "%sPkg%%pc9", (printed++ ? delim : "")); 696 outp += sprintf(outp, "%sPkg%%pc9", (printed++ ? delim : ""));
636 if (DO_BIC(BIC_Pkgpc10)) 697 if (DO_BIC(BIC_Pkgpc10))
637 outp += sprintf(outp, "%sPk%%pc10", (printed++ ? delim : "")); 698 outp += sprintf(outp, "%sPk%%pc10", (printed++ ? delim : ""));
699 if (DO_BIC(BIC_CPU_LPI))
700 outp += sprintf(outp, "%sCPU%%LPI", (printed++ ? delim : ""));
701 if (DO_BIC(BIC_SYS_LPI))
702 outp += sprintf(outp, "%sSYS%%LPI", (printed++ ? delim : ""));
638 703
639 if (do_rapl && !rapl_joules) { 704 if (do_rapl && !rapl_joules) {
640 if (DO_BIC(BIC_PkgWatt)) 705 if (DO_BIC(BIC_PkgWatt))
@@ -739,6 +804,9 @@ int dump_counters(struct thread_data *t, struct core_data *c,
739 outp += sprintf(outp, "pc8: %016llX\n", p->pc8); 804 outp += sprintf(outp, "pc8: %016llX\n", p->pc8);
740 outp += sprintf(outp, "pc9: %016llX\n", p->pc9); 805 outp += sprintf(outp, "pc9: %016llX\n", p->pc9);
741 outp += sprintf(outp, "pc10: %016llX\n", p->pc10); 806 outp += sprintf(outp, "pc10: %016llX\n", p->pc10);
807 outp += sprintf(outp, "pc10: %016llX\n", p->pc10);
808 outp += sprintf(outp, "cpu_lpi: %016llX\n", p->cpu_lpi);
809 outp += sprintf(outp, "sys_lpi: %016llX\n", p->sys_lpi);
742 outp += sprintf(outp, "Joules PKG: %0X\n", p->energy_pkg); 810 outp += sprintf(outp, "Joules PKG: %0X\n", p->energy_pkg);
743 outp += sprintf(outp, "Joules COR: %0X\n", p->energy_cores); 811 outp += sprintf(outp, "Joules COR: %0X\n", p->energy_cores);
744 outp += sprintf(outp, "Joules GFX: %0X\n", p->energy_gfx); 812 outp += sprintf(outp, "Joules GFX: %0X\n", p->energy_gfx);
@@ -786,7 +854,7 @@ int format_counters(struct thread_data *t, struct core_data *c,
786 (cpu_subset && !CPU_ISSET_S(t->cpu_id, cpu_subset_size, cpu_subset))) 854 (cpu_subset && !CPU_ISSET_S(t->cpu_id, cpu_subset_size, cpu_subset)))
787 return 0; 855 return 0;
788 856
789 if (debug) { 857 if (DO_BIC(BIC_USEC)) {
790 /* on each row, print how many usec each timestamp took to gather */ 858 /* on each row, print how many usec each timestamp took to gather */
791 struct timeval tv; 859 struct timeval tv;
792 860
@@ -794,6 +862,10 @@ int format_counters(struct thread_data *t, struct core_data *c,
794 outp += sprintf(outp, "%5ld\t", tv.tv_sec * 1000000 + tv.tv_usec); 862 outp += sprintf(outp, "%5ld\t", tv.tv_sec * 1000000 + tv.tv_usec);
795 } 863 }
796 864
865 /* Time_Of_Day_Seconds: on each row, print sec.usec last timestamp taken */
866 if (DO_BIC(BIC_TOD))
867 outp += sprintf(outp, "%10ld.%06ld\t", t->tv_end.tv_sec, t->tv_end.tv_usec);
868
797 interval_float = tv_delta.tv_sec + tv_delta.tv_usec/1000000.0; 869 interval_float = tv_delta.tv_sec + tv_delta.tv_usec/1000000.0;
798 870
799 tsc = t->tsc * tsc_tweak; 871 tsc = t->tsc * tsc_tweak;
@@ -802,6 +874,8 @@ int format_counters(struct thread_data *t, struct core_data *c,
802 if (t == &average.threads) { 874 if (t == &average.threads) {
803 if (DO_BIC(BIC_Package)) 875 if (DO_BIC(BIC_Package))
804 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); 876 outp += sprintf(outp, "%s-", (printed++ ? delim : ""));
877 if (DO_BIC(BIC_Node))
878 outp += sprintf(outp, "%s-", (printed++ ? delim : ""));
805 if (DO_BIC(BIC_Core)) 879 if (DO_BIC(BIC_Core))
806 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); 880 outp += sprintf(outp, "%s-", (printed++ ? delim : ""));
807 if (DO_BIC(BIC_CPU)) 881 if (DO_BIC(BIC_CPU))
@@ -813,6 +887,15 @@ int format_counters(struct thread_data *t, struct core_data *c,
813 else 887 else
814 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); 888 outp += sprintf(outp, "%s-", (printed++ ? delim : ""));
815 } 889 }
890 if (DO_BIC(BIC_Node)) {
891 if (t)
892 outp += sprintf(outp, "%s%d",
893 (printed++ ? delim : ""),
894 cpus[t->cpu_id].physical_node_id);
895 else
896 outp += sprintf(outp, "%s-",
897 (printed++ ? delim : ""));
898 }
816 if (DO_BIC(BIC_Core)) { 899 if (DO_BIC(BIC_Core)) {
817 if (c) 900 if (c)
818 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), c->core_id); 901 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), c->core_id);
@@ -882,7 +965,7 @@ int format_counters(struct thread_data *t, struct core_data *c,
882 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) 965 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE))
883 goto done; 966 goto done;
884 967
885 if (DO_BIC(BIC_CPU_c3) && !do_slm_cstates && !do_knl_cstates) 968 if (DO_BIC(BIC_CPU_c3) && !do_slm_cstates && !do_knl_cstates && !do_cnl_cstates)
886 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->c3/tsc); 969 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->c3/tsc);
887 if (DO_BIC(BIC_CPU_c6)) 970 if (DO_BIC(BIC_CPU_c6))
888 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->c6/tsc); 971 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * c->c6/tsc);
@@ -959,6 +1042,11 @@ int format_counters(struct thread_data *t, struct core_data *c,
959 if (DO_BIC(BIC_Pkgpc10)) 1042 if (DO_BIC(BIC_Pkgpc10))
960 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc10/tsc); 1043 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->pc10/tsc);
961 1044
1045 if (DO_BIC(BIC_CPU_LPI))
1046 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->cpu_lpi / 1000000.0 / interval_float);
1047 if (DO_BIC(BIC_SYS_LPI))
1048 outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), 100.0 * p->sys_lpi / 1000000.0 / interval_float);
1049
962 /* 1050 /*
963 * If measurement interval exceeds minimum RAPL Joule Counter range, 1051 * If measurement interval exceeds minimum RAPL Joule Counter range,
964 * indicate that results are suspect by printing "**" in fraction place. 1052 * indicate that results are suspect by printing "**" in fraction place.
@@ -1006,7 +1094,8 @@ int format_counters(struct thread_data *t, struct core_data *c,
1006 } 1094 }
1007 1095
1008done: 1096done:
1009 outp += sprintf(outp, "\n"); 1097 if (*(outp - 1) != '\n')
1098 outp += sprintf(outp, "\n");
1010 1099
1011 return 0; 1100 return 0;
1012} 1101}
@@ -1083,6 +1172,8 @@ delta_package(struct pkg_data *new, struct pkg_data *old)
1083 old->pc8 = new->pc8 - old->pc8; 1172 old->pc8 = new->pc8 - old->pc8;
1084 old->pc9 = new->pc9 - old->pc9; 1173 old->pc9 = new->pc9 - old->pc9;
1085 old->pc10 = new->pc10 - old->pc10; 1174 old->pc10 = new->pc10 - old->pc10;
1175 old->cpu_lpi = new->cpu_lpi - old->cpu_lpi;
1176 old->sys_lpi = new->sys_lpi - old->sys_lpi;
1086 old->pkg_temp_c = new->pkg_temp_c; 1177 old->pkg_temp_c = new->pkg_temp_c;
1087 1178
1088 /* flag an error when rc6 counter resets/wraps */ 1179 /* flag an error when rc6 counter resets/wraps */
@@ -1140,6 +1231,15 @@ delta_thread(struct thread_data *new, struct thread_data *old,
1140 int i; 1231 int i;
1141 struct msr_counter *mp; 1232 struct msr_counter *mp;
1142 1233
1234 /*
1235 * the timestamps from start of measurement interval are in "old"
1236 * the timestamp from end of measurement interval are in "new"
1237 * over-write old w/ new so we can print end of interval values
1238 */
1239
1240 old->tv_begin = new->tv_begin;
1241 old->tv_end = new->tv_end;
1242
1143 old->tsc = new->tsc - old->tsc; 1243 old->tsc = new->tsc - old->tsc;
1144 1244
1145 /* check for TSC < 1 Mcycles over interval */ 1245 /* check for TSC < 1 Mcycles over interval */
@@ -1228,6 +1328,11 @@ void clear_counters(struct thread_data *t, struct core_data *c, struct pkg_data
1228 int i; 1328 int i;
1229 struct msr_counter *mp; 1329 struct msr_counter *mp;
1230 1330
1331 t->tv_begin.tv_sec = 0;
1332 t->tv_begin.tv_usec = 0;
1333 t->tv_end.tv_sec = 0;
1334 t->tv_end.tv_usec = 0;
1335
1231 t->tsc = 0; 1336 t->tsc = 0;
1232 t->aperf = 0; 1337 t->aperf = 0;
1233 t->mperf = 0; 1338 t->mperf = 0;
@@ -1260,6 +1365,8 @@ void clear_counters(struct thread_data *t, struct core_data *c, struct pkg_data
1260 p->pc8 = 0; 1365 p->pc8 = 0;
1261 p->pc9 = 0; 1366 p->pc9 = 0;
1262 p->pc10 = 0; 1367 p->pc10 = 0;
1368 p->cpu_lpi = 0;
1369 p->sys_lpi = 0;
1263 1370
1264 p->energy_pkg = 0; 1371 p->energy_pkg = 0;
1265 p->energy_dram = 0; 1372 p->energy_dram = 0;
@@ -1286,6 +1393,13 @@ int sum_counters(struct thread_data *t, struct core_data *c,
1286 int i; 1393 int i;
1287 struct msr_counter *mp; 1394 struct msr_counter *mp;
1288 1395
1396 /* remember first tv_begin */
1397 if (average.threads.tv_begin.tv_sec == 0)
1398 average.threads.tv_begin = t->tv_begin;
1399
1400 /* remember last tv_end */
1401 average.threads.tv_end = t->tv_end;
1402
1289 average.threads.tsc += t->tsc; 1403 average.threads.tsc += t->tsc;
1290 average.threads.aperf += t->aperf; 1404 average.threads.aperf += t->aperf;
1291 average.threads.mperf += t->mperf; 1405 average.threads.mperf += t->mperf;
@@ -1341,6 +1455,9 @@ int sum_counters(struct thread_data *t, struct core_data *c,
1341 average.packages.pc9 += p->pc9; 1455 average.packages.pc9 += p->pc9;
1342 average.packages.pc10 += p->pc10; 1456 average.packages.pc10 += p->pc10;
1343 1457
1458 average.packages.cpu_lpi = p->cpu_lpi;
1459 average.packages.sys_lpi = p->sys_lpi;
1460
1344 average.packages.energy_pkg += p->energy_pkg; 1461 average.packages.energy_pkg += p->energy_pkg;
1345 average.packages.energy_dram += p->energy_dram; 1462 average.packages.energy_dram += p->energy_dram;
1346 average.packages.energy_cores += p->energy_cores; 1463 average.packages.energy_cores += p->energy_cores;
@@ -1487,7 +1604,7 @@ int get_mp(int cpu, struct msr_counter *mp, unsigned long long *counterp)
1487 if (get_msr(cpu, mp->msr_num, counterp)) 1604 if (get_msr(cpu, mp->msr_num, counterp))
1488 return -1; 1605 return -1;
1489 } else { 1606 } else {
1490 char path[128]; 1607 char path[128 + PATH_BYTES];
1491 1608
1492 if (mp->flags & SYSFS_PERCPU) { 1609 if (mp->flags & SYSFS_PERCPU) {
1493 sprintf(path, "/sys/devices/system/cpu/cpu%d/%s", 1610 sprintf(path, "/sys/devices/system/cpu/cpu%d/%s",
@@ -1603,7 +1720,7 @@ retry:
1603 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) 1720 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE))
1604 goto done; 1721 goto done;
1605 1722
1606 if (DO_BIC(BIC_CPU_c3) && !do_slm_cstates && !do_knl_cstates) { 1723 if (DO_BIC(BIC_CPU_c3) && !do_slm_cstates && !do_knl_cstates && !do_cnl_cstates) {
1607 if (get_msr(cpu, MSR_CORE_C3_RESIDENCY, &c->c3)) 1724 if (get_msr(cpu, MSR_CORE_C3_RESIDENCY, &c->c3))
1608 return -6; 1725 return -6;
1609 } 1726 }
@@ -1684,6 +1801,11 @@ retry:
1684 if (get_msr(cpu, MSR_PKG_C10_RESIDENCY, &p->pc10)) 1801 if (get_msr(cpu, MSR_PKG_C10_RESIDENCY, &p->pc10))
1685 return -13; 1802 return -13;
1686 1803
1804 if (DO_BIC(BIC_CPU_LPI))
1805 p->cpu_lpi = cpuidle_cur_cpu_lpi_us;
1806 if (DO_BIC(BIC_SYS_LPI))
1807 p->sys_lpi = cpuidle_cur_sys_lpi_us;
1808
1687 if (do_rapl & RAPL_PKG) { 1809 if (do_rapl & RAPL_PKG) {
1688 if (get_msr(cpu, MSR_PKG_ENERGY_STATUS, &msr)) 1810 if (get_msr(cpu, MSR_PKG_ENERGY_STATUS, &msr))
1689 return -13; 1811 return -13;
@@ -1769,7 +1891,7 @@ int slv_pkg_cstate_limits[16] = {PCL__0, PCL__1, PCLRSV, PCLRSV, PCL__4, PCLRSV,
1769int amt_pkg_cstate_limits[16] = {PCLUNL, PCL__1, PCL__2, PCLRSV, PCLRSV, PCLRSV, PCL__6, PCL__7, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV}; 1891int amt_pkg_cstate_limits[16] = {PCLUNL, PCL__1, PCL__2, PCLRSV, PCLRSV, PCLRSV, PCL__6, PCL__7, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV};
1770int phi_pkg_cstate_limits[16] = {PCL__0, PCL__2, PCL_6N, PCL_6R, PCLRSV, PCLRSV, PCLRSV, PCLUNL, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV}; 1892int phi_pkg_cstate_limits[16] = {PCL__0, PCL__2, PCL_6N, PCL_6R, PCLRSV, PCLRSV, PCLRSV, PCLUNL, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV};
1771int bxt_pkg_cstate_limits[16] = {PCL__0, PCL__2, PCLUNL, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV}; 1893int bxt_pkg_cstate_limits[16] = {PCL__0, PCL__2, PCLUNL, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV};
1772int skx_pkg_cstate_limits[16] = {PCL__0, PCL__2, PCL_6N, PCL_6R, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLUNL, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV}; 1894int skx_pkg_cstate_limits[16] = {PCL__0, PCL__2, PCL_6N, PCL_6R, PCLRSV, PCLRSV, PCLRSV, PCLUNL, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV};
1773 1895
1774 1896
1775static void 1897static void
@@ -2071,12 +2193,9 @@ dump_nhm_cst_cfg(void)
2071 2193
2072 get_msr(base_cpu, MSR_PKG_CST_CONFIG_CONTROL, &msr); 2194 get_msr(base_cpu, MSR_PKG_CST_CONFIG_CONTROL, &msr);
2073 2195
2074#define SNB_C1_AUTO_UNDEMOTE (1UL << 27)
2075#define SNB_C3_AUTO_UNDEMOTE (1UL << 28)
2076
2077 fprintf(outf, "cpu%d: MSR_PKG_CST_CONFIG_CONTROL: 0x%08llx", base_cpu, msr); 2196 fprintf(outf, "cpu%d: MSR_PKG_CST_CONFIG_CONTROL: 0x%08llx", base_cpu, msr);
2078 2197
2079 fprintf(outf, " (%s%s%s%s%slocked: pkg-cstate-limit=%d: %s)\n", 2198 fprintf(outf, " (%s%s%s%s%slocked, pkg-cstate-limit=%d (%s)",
2080 (msr & SNB_C3_AUTO_UNDEMOTE) ? "UNdemote-C3, " : "", 2199 (msr & SNB_C3_AUTO_UNDEMOTE) ? "UNdemote-C3, " : "",
2081 (msr & SNB_C1_AUTO_UNDEMOTE) ? "UNdemote-C1, " : "", 2200 (msr & SNB_C1_AUTO_UNDEMOTE) ? "UNdemote-C1, " : "",
2082 (msr & NHM_C3_AUTO_DEMOTE) ? "demote-C3, " : "", 2201 (msr & NHM_C3_AUTO_DEMOTE) ? "demote-C3, " : "",
@@ -2084,6 +2203,15 @@ dump_nhm_cst_cfg(void)
2084 (msr & (1 << 15)) ? "" : "UN", 2203 (msr & (1 << 15)) ? "" : "UN",
2085 (unsigned int)msr & 0xF, 2204 (unsigned int)msr & 0xF,
2086 pkg_cstate_limit_strings[pkg_cstate_limit]); 2205 pkg_cstate_limit_strings[pkg_cstate_limit]);
2206
2207#define AUTOMATIC_CSTATE_CONVERSION (1UL << 16)
2208 if (has_automatic_cstate_conversion) {
2209 fprintf(outf, ", automatic c-state conversion=%s",
2210 (msr & AUTOMATIC_CSTATE_CONVERSION) ? "on" : "off");
2211 }
2212
2213 fprintf(outf, ")\n");
2214
2087 return; 2215 return;
2088} 2216}
2089 2217
@@ -2184,6 +2312,8 @@ void free_fd_percpu(void)
2184 2312
2185void free_all_buffers(void) 2313void free_all_buffers(void)
2186{ 2314{
2315 int i;
2316
2187 CPU_FREE(cpu_present_set); 2317 CPU_FREE(cpu_present_set);
2188 cpu_present_set = NULL; 2318 cpu_present_set = NULL;
2189 cpu_present_setsize = 0; 2319 cpu_present_setsize = 0;
@@ -2216,6 +2346,12 @@ void free_all_buffers(void)
2216 2346
2217 free(irq_column_2_cpu); 2347 free(irq_column_2_cpu);
2218 free(irqs_per_cpu); 2348 free(irqs_per_cpu);
2349
2350 for (i = 0; i <= topo.max_cpu_num; ++i) {
2351 if (cpus[i].put_ids)
2352 CPU_FREE(cpus[i].put_ids);
2353 }
2354 free(cpus);
2219} 2355}
2220 2356
2221 2357
@@ -2240,44 +2376,6 @@ int parse_int_file(const char *fmt, ...)
2240} 2376}
2241 2377
2242/* 2378/*
2243 * get_cpu_position_in_core(cpu)
2244 * return the position of the CPU among its HT siblings in the core
2245 * return -1 if the sibling is not in list
2246 */
2247int get_cpu_position_in_core(int cpu)
2248{
2249 char path[64];
2250 FILE *filep;
2251 int this_cpu;
2252 char character;
2253 int i;
2254
2255 sprintf(path,
2256 "/sys/devices/system/cpu/cpu%d/topology/thread_siblings_list",
2257 cpu);
2258 filep = fopen(path, "r");
2259 if (filep == NULL) {
2260 perror(path);
2261 exit(1);
2262 }
2263
2264 for (i = 0; i < topo.num_threads_per_core; i++) {
2265 fscanf(filep, "%d", &this_cpu);
2266 if (this_cpu == cpu) {
2267 fclose(filep);
2268 return i;
2269 }
2270
2271 /* Account for no separator after last thread*/
2272 if (i != (topo.num_threads_per_core - 1))
2273 fscanf(filep, "%c", &character);
2274 }
2275
2276 fclose(filep);
2277 return -1;
2278}
2279
2280/*
2281 * cpu_is_first_core_in_package(cpu) 2379 * cpu_is_first_core_in_package(cpu)
2282 * return 1 if given CPU is 1st core in package 2380 * return 1 if given CPU is 1st core in package
2283 */ 2381 */
@@ -2296,35 +2394,115 @@ int get_core_id(int cpu)
2296 return parse_int_file("/sys/devices/system/cpu/cpu%d/topology/core_id", cpu); 2394 return parse_int_file("/sys/devices/system/cpu/cpu%d/topology/core_id", cpu);
2297} 2395}
2298 2396
2299int get_num_ht_siblings(int cpu) 2397void set_node_data(void)
2300{ 2398{
2301 char path[80]; 2399 char path[80];
2302 FILE *filep; 2400 FILE *filep;
2303 int sib1; 2401 int pkg, node, cpu;
2304 int matches = 0;
2305 char character;
2306 char str[100];
2307 char *ch;
2308 2402
2309 sprintf(path, "/sys/devices/system/cpu/cpu%d/topology/thread_siblings_list", cpu); 2403 struct pkg_node_info {
2310 filep = fopen_or_die(path, "r"); 2404 int count;
2405 int min;
2406 } *pni;
2311 2407
2312 /* 2408 pni = calloc(topo.num_packages, sizeof(struct pkg_node_info));
2313 * file format: 2409 if (!pni)
2314 * A ',' separated or '-' separated set of numbers 2410 err(1, "calloc pkg_node_count");
2315 * (eg 1-2 or 1,3,4,5) 2411
2316 */ 2412 for (pkg = 0; pkg < topo.num_packages; pkg++)
2317 fscanf(filep, "%d%c\n", &sib1, &character); 2413 pni[pkg].min = topo.num_cpus;
2318 fseek(filep, 0, SEEK_SET); 2414
2319 fgets(str, 100, filep); 2415 for (node = 0; node <= topo.max_node_num; node++) {
2320 ch = strchr(str, character); 2416 /* find the "first" cpu in the node */
2321 while (ch != NULL) { 2417 sprintf(path, "/sys/bus/node/devices/node%d/cpulist", node);
2322 matches++; 2418 filep = fopen(path, "r");
2323 ch = strchr(ch+1, character); 2419 if (!filep)
2420 continue;
2421 fscanf(filep, "%d", &cpu);
2422 fclose(filep);
2423
2424 pkg = cpus[cpu].physical_package_id;
2425 pni[pkg].count++;
2426
2427 if (node < pni[pkg].min)
2428 pni[pkg].min = node;
2324 } 2429 }
2325 2430
2431 for (pkg = 0; pkg < topo.num_packages; pkg++)
2432 if (pni[pkg].count > topo.nodes_per_pkg)
2433 topo.nodes_per_pkg = pni[0].count;
2434
2435 for (cpu = 0; cpu < topo.num_cpus; cpu++) {
2436 pkg = cpus[cpu].physical_package_id;
2437 node = cpus[cpu].physical_node_id;
2438 cpus[cpu].logical_node_id = node - pni[pkg].min;
2439 }
2440 free(pni);
2441
2442}
2443
2444int get_physical_node_id(struct cpu_topology *thiscpu)
2445{
2446 char path[80];
2447 FILE *filep;
2448 int i;
2449 int cpu = thiscpu->logical_cpu_id;
2450
2451 for (i = 0; i <= topo.max_cpu_num; i++) {
2452 sprintf(path, "/sys/devices/system/cpu/cpu%d/node%i/cpulist",
2453 cpu, i);
2454 filep = fopen(path, "r");
2455 if (!filep)
2456 continue;
2457 fclose(filep);
2458 return i;
2459 }
2460 return -1;
2461}
2462
2463int get_thread_siblings(struct cpu_topology *thiscpu)
2464{
2465 char path[80], character;
2466 FILE *filep;
2467 unsigned long map;
2468 int so, shift, sib_core;
2469 int cpu = thiscpu->logical_cpu_id;
2470 int offset = topo.max_cpu_num + 1;
2471 size_t size;
2472 int thread_id = 0;
2473
2474 thiscpu->put_ids = CPU_ALLOC((topo.max_cpu_num + 1));
2475 if (thiscpu->thread_id < 0)
2476 thiscpu->thread_id = thread_id++;
2477 if (!thiscpu->put_ids)
2478 return -1;
2479
2480 size = CPU_ALLOC_SIZE((topo.max_cpu_num + 1));
2481 CPU_ZERO_S(size, thiscpu->put_ids);
2482
2483 sprintf(path,
2484 "/sys/devices/system/cpu/cpu%d/topology/thread_siblings", cpu);
2485 filep = fopen_or_die(path, "r");
2486 do {
2487 offset -= BITMASK_SIZE;
2488 fscanf(filep, "%lx%c", &map, &character);
2489 for (shift = 0; shift < BITMASK_SIZE; shift++) {
2490 if ((map >> shift) & 0x1) {
2491 so = shift + offset;
2492 sib_core = get_core_id(so);
2493 if (sib_core == thiscpu->physical_core_id) {
2494 CPU_SET_S(so, size, thiscpu->put_ids);
2495 if ((so != cpu) &&
2496 (cpus[so].thread_id < 0))
2497 cpus[so].thread_id =
2498 thread_id++;
2499 }
2500 }
2501 }
2502 } while (!strncmp(&character, ",", 1));
2326 fclose(filep); 2503 fclose(filep);
2327 return matches+1; 2504
2505 return CPU_COUNT_S(size, thiscpu->put_ids);
2328} 2506}
2329 2507
2330/* 2508/*
@@ -2339,32 +2517,42 @@ int for_all_cpus_2(int (func)(struct thread_data *, struct core_data *,
2339 struct thread_data *thread_base2, struct core_data *core_base2, 2517 struct thread_data *thread_base2, struct core_data *core_base2,
2340 struct pkg_data *pkg_base2) 2518 struct pkg_data *pkg_base2)
2341{ 2519{
2342 int retval, pkg_no, core_no, thread_no; 2520 int retval, pkg_no, node_no, core_no, thread_no;
2343 2521
2344 for (pkg_no = 0; pkg_no < topo.num_packages; ++pkg_no) { 2522 for (pkg_no = 0; pkg_no < topo.num_packages; ++pkg_no) {
2345 for (core_no = 0; core_no < topo.num_cores_per_pkg; ++core_no) { 2523 for (node_no = 0; node_no < topo.nodes_per_pkg; ++node_no) {
2346 for (thread_no = 0; thread_no < 2524 for (core_no = 0; core_no < topo.cores_per_node;
2347 topo.num_threads_per_core; ++thread_no) { 2525 ++core_no) {
2348 struct thread_data *t, *t2; 2526 for (thread_no = 0; thread_no <
2349 struct core_data *c, *c2; 2527 topo.threads_per_core; ++thread_no) {
2350 struct pkg_data *p, *p2; 2528 struct thread_data *t, *t2;
2351 2529 struct core_data *c, *c2;
2352 t = GET_THREAD(thread_base, thread_no, core_no, pkg_no); 2530 struct pkg_data *p, *p2;
2353 2531
2354 if (cpu_is_not_present(t->cpu_id)) 2532 t = GET_THREAD(thread_base, thread_no,
2355 continue; 2533 core_no, node_no,
2356 2534 pkg_no);
2357 t2 = GET_THREAD(thread_base2, thread_no, core_no, pkg_no); 2535
2358 2536 if (cpu_is_not_present(t->cpu_id))
2359 c = GET_CORE(core_base, core_no, pkg_no); 2537 continue;
2360 c2 = GET_CORE(core_base2, core_no, pkg_no); 2538
2361 2539 t2 = GET_THREAD(thread_base2, thread_no,
2362 p = GET_PKG(pkg_base, pkg_no); 2540 core_no, node_no,
2363 p2 = GET_PKG(pkg_base2, pkg_no); 2541 pkg_no);
2364 2542
2365 retval = func(t, c, p, t2, c2, p2); 2543 c = GET_CORE(core_base, core_no,
2366 if (retval) 2544 node_no, pkg_no);
2367 return retval; 2545 c2 = GET_CORE(core_base2, core_no,
2546 node_no,
2547 pkg_no);
2548
2549 p = GET_PKG(pkg_base, pkg_no);
2550 p2 = GET_PKG(pkg_base2, pkg_no);
2551
2552 retval = func(t, c, p, t2, c2, p2);
2553 if (retval)
2554 return retval;
2555 }
2368 } 2556 }
2369 } 2557 }
2370 } 2558 }
@@ -2409,6 +2597,20 @@ void re_initialize(void)
2409 printf("turbostat: re-initialized with num_cpus %d\n", topo.num_cpus); 2597 printf("turbostat: re-initialized with num_cpus %d\n", topo.num_cpus);
2410} 2598}
2411 2599
2600void set_max_cpu_num(void)
2601{
2602 FILE *filep;
2603 unsigned long dummy;
2604
2605 topo.max_cpu_num = 0;
2606 filep = fopen_or_die(
2607 "/sys/devices/system/cpu/cpu0/topology/thread_siblings",
2608 "r");
2609 while (fscanf(filep, "%lx,", &dummy) == 1)
2610 topo.max_cpu_num += BITMASK_SIZE;
2611 fclose(filep);
2612 topo.max_cpu_num--; /* 0 based */
2613}
2412 2614
2413/* 2615/*
2414 * count_cpus() 2616 * count_cpus()
@@ -2416,10 +2618,7 @@ void re_initialize(void)
2416 */ 2618 */
2417int count_cpus(int cpu) 2619int count_cpus(int cpu)
2418{ 2620{
2419 if (topo.max_cpu_num < cpu) 2621 topo.num_cpus++;
2420 topo.max_cpu_num = cpu;
2421
2422 topo.num_cpus += 1;
2423 return 0; 2622 return 0;
2424} 2623}
2425int mark_cpu_present(int cpu) 2624int mark_cpu_present(int cpu)
@@ -2428,6 +2627,12 @@ int mark_cpu_present(int cpu)
2428 return 0; 2627 return 0;
2429} 2628}
2430 2629
2630int init_thread_id(int cpu)
2631{
2632 cpus[cpu].thread_id = -1;
2633 return 0;
2634}
2635
2431/* 2636/*
2432 * snapshot_proc_interrupts() 2637 * snapshot_proc_interrupts()
2433 * 2638 *
@@ -2542,6 +2747,52 @@ int snapshot_gfx_mhz(void)
2542} 2747}
2543 2748
2544/* 2749/*
2750 * snapshot_cpu_lpi()
2751 *
2752 * record snapshot of
2753 * /sys/devices/system/cpu/cpuidle/low_power_idle_cpu_residency_us
2754 *
2755 * return 1 if config change requires a restart, else return 0
2756 */
2757int snapshot_cpu_lpi_us(void)
2758{
2759 FILE *fp;
2760 int retval;
2761
2762 fp = fopen_or_die("/sys/devices/system/cpu/cpuidle/low_power_idle_cpu_residency_us", "r");
2763
2764 retval = fscanf(fp, "%lld", &cpuidle_cur_cpu_lpi_us);
2765 if (retval != 1)
2766 err(1, "CPU LPI");
2767
2768 fclose(fp);
2769
2770 return 0;
2771}
2772/*
2773 * snapshot_sys_lpi()
2774 *
2775 * record snapshot of
2776 * /sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us
2777 *
2778 * return 1 if config change requires a restart, else return 0
2779 */
2780int snapshot_sys_lpi_us(void)
2781{
2782 FILE *fp;
2783 int retval;
2784
2785 fp = fopen_or_die("/sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us", "r");
2786
2787 retval = fscanf(fp, "%lld", &cpuidle_cur_sys_lpi_us);
2788 if (retval != 1)
2789 err(1, "SYS LPI");
2790
2791 fclose(fp);
2792
2793 return 0;
2794}
2795/*
2545 * snapshot /proc and /sys files 2796 * snapshot /proc and /sys files
2546 * 2797 *
2547 * return 1 if configuration restart needed, else return 0 2798 * return 1 if configuration restart needed, else return 0
@@ -2558,13 +2809,83 @@ int snapshot_proc_sysfs_files(void)
2558 if (DO_BIC(BIC_GFXMHz)) 2809 if (DO_BIC(BIC_GFXMHz))
2559 snapshot_gfx_mhz(); 2810 snapshot_gfx_mhz();
2560 2811
2812 if (DO_BIC(BIC_CPU_LPI))
2813 snapshot_cpu_lpi_us();
2814
2815 if (DO_BIC(BIC_SYS_LPI))
2816 snapshot_sys_lpi_us();
2817
2561 return 0; 2818 return 0;
2562} 2819}
2563 2820
2821int exit_requested;
2822
2823static void signal_handler (int signal)
2824{
2825 switch (signal) {
2826 case SIGINT:
2827 exit_requested = 1;
2828 if (debug)
2829 fprintf(stderr, " SIGINT\n");
2830 break;
2831 case SIGUSR1:
2832 if (debug > 1)
2833 fprintf(stderr, "SIGUSR1\n");
2834 break;
2835 }
2836 /* make sure this manually-invoked interval is at least 1ms long */
2837 nanosleep(&one_msec, NULL);
2838}
2839
2840void setup_signal_handler(void)
2841{
2842 struct sigaction sa;
2843
2844 memset(&sa, 0, sizeof(sa));
2845
2846 sa.sa_handler = &signal_handler;
2847
2848 if (sigaction(SIGINT, &sa, NULL) < 0)
2849 err(1, "sigaction SIGINT");
2850 if (sigaction(SIGUSR1, &sa, NULL) < 0)
2851 err(1, "sigaction SIGUSR1");
2852}
2853
2854void do_sleep(void)
2855{
2856 struct timeval select_timeout;
2857 fd_set readfds;
2858 int retval;
2859
2860 FD_ZERO(&readfds);
2861 FD_SET(0, &readfds);
2862
2863 if (!isatty(fileno(stdin))) {
2864 nanosleep(&interval_ts, NULL);
2865 return;
2866 }
2867
2868 select_timeout = interval_tv;
2869 retval = select(1, &readfds, NULL, NULL, &select_timeout);
2870
2871 if (retval == 1) {
2872 switch (getc(stdin)) {
2873 case 'q':
2874 exit_requested = 1;
2875 break;
2876 }
2877 /* make sure this manually-invoked interval is at least 1ms long */
2878 nanosleep(&one_msec, NULL);
2879 }
2880}
2881
2564void turbostat_loop() 2882void turbostat_loop()
2565{ 2883{
2566 int retval; 2884 int retval;
2567 int restarted = 0; 2885 int restarted = 0;
2886 int done_iters = 0;
2887
2888 setup_signal_handler();
2568 2889
2569restart: 2890restart:
2570 restarted++; 2891 restarted++;
@@ -2581,6 +2902,7 @@ restart:
2581 goto restart; 2902 goto restart;
2582 } 2903 }
2583 restarted = 0; 2904 restarted = 0;
2905 done_iters = 0;
2584 gettimeofday(&tv_even, (struct timezone *)NULL); 2906 gettimeofday(&tv_even, (struct timezone *)NULL);
2585 2907
2586 while (1) { 2908 while (1) {
@@ -2588,7 +2910,7 @@ restart:
2588 re_initialize(); 2910 re_initialize();
2589 goto restart; 2911 goto restart;
2590 } 2912 }
2591 nanosleep(&interval_ts, NULL); 2913 do_sleep();
2592 if (snapshot_proc_sysfs_files()) 2914 if (snapshot_proc_sysfs_files())
2593 goto restart; 2915 goto restart;
2594 retval = for_all_cpus(get_counters, ODD_COUNTERS); 2916 retval = for_all_cpus(get_counters, ODD_COUNTERS);
@@ -2607,7 +2929,11 @@ restart:
2607 compute_average(EVEN_COUNTERS); 2929 compute_average(EVEN_COUNTERS);
2608 format_all_counters(EVEN_COUNTERS); 2930 format_all_counters(EVEN_COUNTERS);
2609 flush_output_stdout(); 2931 flush_output_stdout();
2610 nanosleep(&interval_ts, NULL); 2932 if (exit_requested)
2933 break;
2934 if (num_iterations && ++done_iters >= num_iterations)
2935 break;
2936 do_sleep();
2611 if (snapshot_proc_sysfs_files()) 2937 if (snapshot_proc_sysfs_files())
2612 goto restart; 2938 goto restart;
2613 retval = for_all_cpus(get_counters, EVEN_COUNTERS); 2939 retval = for_all_cpus(get_counters, EVEN_COUNTERS);
@@ -2626,6 +2952,10 @@ restart:
2626 compute_average(ODD_COUNTERS); 2952 compute_average(ODD_COUNTERS);
2627 format_all_counters(ODD_COUNTERS); 2953 format_all_counters(ODD_COUNTERS);
2628 flush_output_stdout(); 2954 flush_output_stdout();
2955 if (exit_requested)
2956 break;
2957 if (num_iterations && ++done_iters >= num_iterations)
2958 break;
2629 } 2959 }
2630} 2960}
2631 2961
@@ -2740,6 +3070,7 @@ int probe_nhm_msrs(unsigned int family, unsigned int model)
2740 case INTEL_FAM6_SKYLAKE_DESKTOP: /* SKL */ 3070 case INTEL_FAM6_SKYLAKE_DESKTOP: /* SKL */
2741 case INTEL_FAM6_KABYLAKE_MOBILE: /* KBL */ 3071 case INTEL_FAM6_KABYLAKE_MOBILE: /* KBL */
2742 case INTEL_FAM6_KABYLAKE_DESKTOP: /* KBL */ 3072 case INTEL_FAM6_KABYLAKE_DESKTOP: /* KBL */
3073 case INTEL_FAM6_CANNONLAKE_MOBILE: /* CNL */
2743 pkg_cstate_limits = hsw_pkg_cstate_limits; 3074 pkg_cstate_limits = hsw_pkg_cstate_limits;
2744 has_misc_feature_control = 1; 3075 has_misc_feature_control = 1;
2745 break; 3076 break;
@@ -2945,6 +3276,7 @@ int has_config_tdp(unsigned int family, unsigned int model)
2945 case INTEL_FAM6_SKYLAKE_DESKTOP: /* SKL */ 3276 case INTEL_FAM6_SKYLAKE_DESKTOP: /* SKL */
2946 case INTEL_FAM6_KABYLAKE_MOBILE: /* KBL */ 3277 case INTEL_FAM6_KABYLAKE_MOBILE: /* KBL */
2947 case INTEL_FAM6_KABYLAKE_DESKTOP: /* KBL */ 3278 case INTEL_FAM6_KABYLAKE_DESKTOP: /* KBL */
3279 case INTEL_FAM6_CANNONLAKE_MOBILE: /* CNL */
2948 case INTEL_FAM6_SKYLAKE_X: /* SKX */ 3280 case INTEL_FAM6_SKYLAKE_X: /* SKX */
2949 3281
2950 case INTEL_FAM6_XEON_PHI_KNL: /* Knights Landing */ 3282 case INTEL_FAM6_XEON_PHI_KNL: /* Knights Landing */
@@ -3399,6 +3731,7 @@ void rapl_probe(unsigned int family, unsigned int model)
3399 case INTEL_FAM6_SKYLAKE_DESKTOP: /* SKL */ 3731 case INTEL_FAM6_SKYLAKE_DESKTOP: /* SKL */
3400 case INTEL_FAM6_KABYLAKE_MOBILE: /* KBL */ 3732 case INTEL_FAM6_KABYLAKE_MOBILE: /* KBL */
3401 case INTEL_FAM6_KABYLAKE_DESKTOP: /* KBL */ 3733 case INTEL_FAM6_KABYLAKE_DESKTOP: /* KBL */
3734 case INTEL_FAM6_CANNONLAKE_MOBILE: /* CNL */
3402 do_rapl = RAPL_PKG | RAPL_CORES | RAPL_CORE_POLICY | RAPL_DRAM | RAPL_DRAM_PERF_STATUS | RAPL_PKG_PERF_STATUS | RAPL_GFX | RAPL_PKG_POWER_INFO; 3735 do_rapl = RAPL_PKG | RAPL_CORES | RAPL_CORE_POLICY | RAPL_DRAM | RAPL_DRAM_PERF_STATUS | RAPL_PKG_PERF_STATUS | RAPL_GFX | RAPL_PKG_POWER_INFO;
3403 BIC_PRESENT(BIC_PKG__); 3736 BIC_PRESENT(BIC_PKG__);
3404 BIC_PRESENT(BIC_RAM__); 3737 BIC_PRESENT(BIC_RAM__);
@@ -3523,6 +3856,12 @@ void perf_limit_reasons_probe(unsigned int family, unsigned int model)
3523 } 3856 }
3524} 3857}
3525 3858
3859void automatic_cstate_conversion_probe(unsigned int family, unsigned int model)
3860{
3861 if (is_skx(family, model) || is_bdx(family, model))
3862 has_automatic_cstate_conversion = 1;
3863}
3864
3526int print_thermal(struct thread_data *t, struct core_data *c, struct pkg_data *p) 3865int print_thermal(struct thread_data *t, struct core_data *c, struct pkg_data *p)
3527{ 3866{
3528 unsigned long long msr; 3867 unsigned long long msr;
@@ -3728,6 +4067,7 @@ int has_snb_msrs(unsigned int family, unsigned int model)
3728 case INTEL_FAM6_SKYLAKE_DESKTOP: /* SKL */ 4067 case INTEL_FAM6_SKYLAKE_DESKTOP: /* SKL */
3729 case INTEL_FAM6_KABYLAKE_MOBILE: /* KBL */ 4068 case INTEL_FAM6_KABYLAKE_MOBILE: /* KBL */
3730 case INTEL_FAM6_KABYLAKE_DESKTOP: /* KBL */ 4069 case INTEL_FAM6_KABYLAKE_DESKTOP: /* KBL */
4070 case INTEL_FAM6_CANNONLAKE_MOBILE: /* CNL */
3731 case INTEL_FAM6_SKYLAKE_X: /* SKX */ 4071 case INTEL_FAM6_SKYLAKE_X: /* SKX */
3732 case INTEL_FAM6_ATOM_GOLDMONT: /* BXT */ 4072 case INTEL_FAM6_ATOM_GOLDMONT: /* BXT */
3733 case INTEL_FAM6_ATOM_GEMINI_LAKE: 4073 case INTEL_FAM6_ATOM_GEMINI_LAKE:
@@ -3761,6 +4101,7 @@ int has_hsw_msrs(unsigned int family, unsigned int model)
3761 case INTEL_FAM6_SKYLAKE_DESKTOP: /* SKL */ 4101 case INTEL_FAM6_SKYLAKE_DESKTOP: /* SKL */
3762 case INTEL_FAM6_KABYLAKE_MOBILE: /* KBL */ 4102 case INTEL_FAM6_KABYLAKE_MOBILE: /* KBL */
3763 case INTEL_FAM6_KABYLAKE_DESKTOP: /* KBL */ 4103 case INTEL_FAM6_KABYLAKE_DESKTOP: /* KBL */
4104 case INTEL_FAM6_CANNONLAKE_MOBILE: /* CNL */
3764 case INTEL_FAM6_ATOM_GOLDMONT: /* BXT */ 4105 case INTEL_FAM6_ATOM_GOLDMONT: /* BXT */
3765 case INTEL_FAM6_ATOM_GEMINI_LAKE: 4106 case INTEL_FAM6_ATOM_GEMINI_LAKE:
3766 return 1; 4107 return 1;
@@ -3786,6 +4127,7 @@ int has_skl_msrs(unsigned int family, unsigned int model)
3786 case INTEL_FAM6_SKYLAKE_DESKTOP: /* SKL */ 4127 case INTEL_FAM6_SKYLAKE_DESKTOP: /* SKL */
3787 case INTEL_FAM6_KABYLAKE_MOBILE: /* KBL */ 4128 case INTEL_FAM6_KABYLAKE_MOBILE: /* KBL */
3788 case INTEL_FAM6_KABYLAKE_DESKTOP: /* KBL */ 4129 case INTEL_FAM6_KABYLAKE_DESKTOP: /* KBL */
4130 case INTEL_FAM6_CANNONLAKE_MOBILE: /* CNL */
3789 return 1; 4131 return 1;
3790 } 4132 }
3791 return 0; 4133 return 0;
@@ -3815,6 +4157,19 @@ int is_knl(unsigned int family, unsigned int model)
3815 return 0; 4157 return 0;
3816} 4158}
3817 4159
4160int is_cnl(unsigned int family, unsigned int model)
4161{
4162 if (!genuine_intel)
4163 return 0;
4164
4165 switch (model) {
4166 case INTEL_FAM6_CANNONLAKE_MOBILE: /* CNL */
4167 return 1;
4168 }
4169
4170 return 0;
4171}
4172
3818unsigned int get_aperf_mperf_multiplier(unsigned int family, unsigned int model) 4173unsigned int get_aperf_mperf_multiplier(unsigned int family, unsigned int model)
3819{ 4174{
3820 if (is_knl(family, model)) 4175 if (is_knl(family, model))
@@ -3947,7 +4302,7 @@ void decode_misc_enable_msr(void)
3947 base_cpu, msr, 4302 base_cpu, msr,
3948 msr & MSR_IA32_MISC_ENABLE_TM1 ? "" : "No-", 4303 msr & MSR_IA32_MISC_ENABLE_TM1 ? "" : "No-",
3949 msr & MSR_IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP ? "" : "No-", 4304 msr & MSR_IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP ? "" : "No-",
3950 msr & MSR_IA32_MISC_ENABLE_MWAIT ? "No-" : "", 4305 msr & MSR_IA32_MISC_ENABLE_MWAIT ? "" : "No-",
3951 msr & MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE ? "No-" : "", 4306 msr & MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE ? "No-" : "",
3952 msr & MSR_IA32_MISC_ENABLE_TURBO_DISABLE ? "No-" : ""); 4307 msr & MSR_IA32_MISC_ENABLE_TURBO_DISABLE ? "No-" : "");
3953} 4308}
@@ -4152,7 +4507,6 @@ void process_cpuid()
4152 case INTEL_FAM6_KABYLAKE_DESKTOP: /* KBL */ 4507 case INTEL_FAM6_KABYLAKE_DESKTOP: /* KBL */
4153 crystal_hz = 24000000; /* 24.0 MHz */ 4508 crystal_hz = 24000000; /* 24.0 MHz */
4154 break; 4509 break;
4155 case INTEL_FAM6_SKYLAKE_X: /* SKX */
4156 case INTEL_FAM6_ATOM_DENVERTON: /* DNV */ 4510 case INTEL_FAM6_ATOM_DENVERTON: /* DNV */
4157 crystal_hz = 25000000; /* 25.0 MHz */ 4511 crystal_hz = 25000000; /* 25.0 MHz */
4158 break; 4512 break;
@@ -4253,6 +4607,7 @@ void process_cpuid()
4253 } 4607 }
4254 do_slm_cstates = is_slm(family, model); 4608 do_slm_cstates = is_slm(family, model);
4255 do_knl_cstates = is_knl(family, model); 4609 do_knl_cstates = is_knl(family, model);
4610 do_cnl_cstates = is_cnl(family, model);
4256 4611
4257 if (!quiet) 4612 if (!quiet)
4258 decode_misc_pwr_mgmt_msr(); 4613 decode_misc_pwr_mgmt_msr();
@@ -4262,6 +4617,7 @@ void process_cpuid()
4262 4617
4263 rapl_probe(family, model); 4618 rapl_probe(family, model);
4264 perf_limit_reasons_probe(family, model); 4619 perf_limit_reasons_probe(family, model);
4620 automatic_cstate_conversion_probe(family, model);
4265 4621
4266 if (!quiet) 4622 if (!quiet)
4267 dump_cstate_pstate_config_info(family, model); 4623 dump_cstate_pstate_config_info(family, model);
@@ -4280,6 +4636,16 @@ void process_cpuid()
4280 if (!access("/sys/class/graphics/fb0/device/drm/card0/gt_cur_freq_mhz", R_OK)) 4636 if (!access("/sys/class/graphics/fb0/device/drm/card0/gt_cur_freq_mhz", R_OK))
4281 BIC_PRESENT(BIC_GFXMHz); 4637 BIC_PRESENT(BIC_GFXMHz);
4282 4638
4639 if (!access("/sys/devices/system/cpu/cpuidle/low_power_idle_cpu_residency_us", R_OK))
4640 BIC_PRESENT(BIC_CPU_LPI);
4641 else
4642 BIC_NOT_PRESENT(BIC_CPU_LPI);
4643
4644 if (!access("/sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us", R_OK))
4645 BIC_PRESENT(BIC_SYS_LPI);
4646 else
4647 BIC_NOT_PRESENT(BIC_SYS_LPI);
4648
4283 if (!quiet) 4649 if (!quiet)
4284 decode_misc_feature_control(); 4650 decode_misc_feature_control();
4285 4651
@@ -4310,14 +4676,10 @@ void topology_probe()
4310 int max_core_id = 0; 4676 int max_core_id = 0;
4311 int max_package_id = 0; 4677 int max_package_id = 0;
4312 int max_siblings = 0; 4678 int max_siblings = 0;
4313 struct cpu_topology {
4314 int core_id;
4315 int physical_package_id;
4316 } *cpus;
4317 4679
4318 /* Initialize num_cpus, max_cpu_num */ 4680 /* Initialize num_cpus, max_cpu_num */
4681 set_max_cpu_num();
4319 topo.num_cpus = 0; 4682 topo.num_cpus = 0;
4320 topo.max_cpu_num = 0;
4321 for_all_proc_cpus(count_cpus); 4683 for_all_proc_cpus(count_cpus);
4322 if (!summary_only && topo.num_cpus > 1) 4684 if (!summary_only && topo.num_cpus > 1)
4323 BIC_PRESENT(BIC_CPU); 4685 BIC_PRESENT(BIC_CPU);
@@ -4357,6 +4719,7 @@ void topology_probe()
4357 cpu_affinity_setsize = CPU_ALLOC_SIZE((topo.max_cpu_num + 1)); 4719 cpu_affinity_setsize = CPU_ALLOC_SIZE((topo.max_cpu_num + 1));
4358 CPU_ZERO_S(cpu_affinity_setsize, cpu_affinity_set); 4720 CPU_ZERO_S(cpu_affinity_setsize, cpu_affinity_set);
4359 4721
4722 for_all_proc_cpus(init_thread_id);
4360 4723
4361 /* 4724 /*
4362 * For online cpus 4725 * For online cpus
@@ -4370,26 +4733,45 @@ void topology_probe()
4370 fprintf(outf, "cpu%d NOT PRESENT\n", i); 4733 fprintf(outf, "cpu%d NOT PRESENT\n", i);
4371 continue; 4734 continue;
4372 } 4735 }
4373 cpus[i].core_id = get_core_id(i);
4374 if (cpus[i].core_id > max_core_id)
4375 max_core_id = cpus[i].core_id;
4376 4736
4737 cpus[i].logical_cpu_id = i;
4738
4739 /* get package information */
4377 cpus[i].physical_package_id = get_physical_package_id(i); 4740 cpus[i].physical_package_id = get_physical_package_id(i);
4378 if (cpus[i].physical_package_id > max_package_id) 4741 if (cpus[i].physical_package_id > max_package_id)
4379 max_package_id = cpus[i].physical_package_id; 4742 max_package_id = cpus[i].physical_package_id;
4380 4743
4381 siblings = get_num_ht_siblings(i); 4744 /* get numa node information */
4745 cpus[i].physical_node_id = get_physical_node_id(&cpus[i]);
4746 if (cpus[i].physical_node_id > topo.max_node_num)
4747 topo.max_node_num = cpus[i].physical_node_id;
4748
4749 /* get core information */
4750 cpus[i].physical_core_id = get_core_id(i);
4751 if (cpus[i].physical_core_id > max_core_id)
4752 max_core_id = cpus[i].physical_core_id;
4753
4754 /* get thread information */
4755 siblings = get_thread_siblings(&cpus[i]);
4382 if (siblings > max_siblings) 4756 if (siblings > max_siblings)
4383 max_siblings = siblings; 4757 max_siblings = siblings;
4758 if (cpus[i].thread_id != -1)
4759 topo.num_cores++;
4760
4384 if (debug > 1) 4761 if (debug > 1)
4385 fprintf(outf, "cpu %d pkg %d core %d\n", 4762 fprintf(outf,
4386 i, cpus[i].physical_package_id, cpus[i].core_id); 4763 "cpu %d pkg %d node %d core %d thread %d\n",
4764 i, cpus[i].physical_package_id,
4765 cpus[i].physical_node_id,
4766 cpus[i].physical_core_id,
4767 cpus[i].thread_id);
4387 } 4768 }
4388 topo.num_cores_per_pkg = max_core_id + 1; 4769
4770 topo.cores_per_node = max_core_id + 1;
4389 if (debug > 1) 4771 if (debug > 1)
4390 fprintf(outf, "max_core_id %d, sizing for %d cores per package\n", 4772 fprintf(outf, "max_core_id %d, sizing for %d cores per package\n",
4391 max_core_id, topo.num_cores_per_pkg); 4773 max_core_id, topo.cores_per_node);
4392 if (!summary_only && topo.num_cores_per_pkg > 1) 4774 if (!summary_only && topo.cores_per_node > 1)
4393 BIC_PRESENT(BIC_Core); 4775 BIC_PRESENT(BIC_Core);
4394 4776
4395 topo.num_packages = max_package_id + 1; 4777 topo.num_packages = max_package_id + 1;
@@ -4399,33 +4781,38 @@ void topology_probe()
4399 if (!summary_only && topo.num_packages > 1) 4781 if (!summary_only && topo.num_packages > 1)
4400 BIC_PRESENT(BIC_Package); 4782 BIC_PRESENT(BIC_Package);
4401 4783
4402 topo.num_threads_per_core = max_siblings; 4784 set_node_data();
4403 if (debug > 1) 4785 if (debug > 1)
4404 fprintf(outf, "max_siblings %d\n", max_siblings); 4786 fprintf(outf, "nodes_per_pkg %d\n", topo.nodes_per_pkg);
4787 if (!summary_only && topo.nodes_per_pkg > 1)
4788 BIC_PRESENT(BIC_Node);
4405 4789
4406 free(cpus); 4790 topo.threads_per_core = max_siblings;
4791 if (debug > 1)
4792 fprintf(outf, "max_siblings %d\n", max_siblings);
4407} 4793}
4408 4794
4409void 4795void
4410allocate_counters(struct thread_data **t, struct core_data **c, struct pkg_data **p) 4796allocate_counters(struct thread_data **t, struct core_data **c,
4797 struct pkg_data **p)
4411{ 4798{
4412 int i; 4799 int i;
4800 int num_cores = topo.cores_per_node * topo.nodes_per_pkg *
4801 topo.num_packages;
4802 int num_threads = topo.threads_per_core * num_cores;
4413 4803
4414 *t = calloc(topo.num_threads_per_core * topo.num_cores_per_pkg * 4804 *t = calloc(num_threads, sizeof(struct thread_data));
4415 topo.num_packages, sizeof(struct thread_data));
4416 if (*t == NULL) 4805 if (*t == NULL)
4417 goto error; 4806 goto error;
4418 4807
4419 for (i = 0; i < topo.num_threads_per_core * 4808 for (i = 0; i < num_threads; i++)
4420 topo.num_cores_per_pkg * topo.num_packages; i++)
4421 (*t)[i].cpu_id = -1; 4809 (*t)[i].cpu_id = -1;
4422 4810
4423 *c = calloc(topo.num_cores_per_pkg * topo.num_packages, 4811 *c = calloc(num_cores, sizeof(struct core_data));
4424 sizeof(struct core_data));
4425 if (*c == NULL) 4812 if (*c == NULL)
4426 goto error; 4813 goto error;
4427 4814
4428 for (i = 0; i < topo.num_cores_per_pkg * topo.num_packages; i++) 4815 for (i = 0; i < num_cores; i++)
4429 (*c)[i].core_id = -1; 4816 (*c)[i].core_id = -1;
4430 4817
4431 *p = calloc(topo.num_packages, sizeof(struct pkg_data)); 4818 *p = calloc(topo.num_packages, sizeof(struct pkg_data));
@@ -4442,47 +4829,39 @@ error:
4442/* 4829/*
4443 * init_counter() 4830 * init_counter()
4444 * 4831 *
4445 * set cpu_id, core_num, pkg_num
4446 * set FIRST_THREAD_IN_CORE and FIRST_CORE_IN_PACKAGE 4832 * set FIRST_THREAD_IN_CORE and FIRST_CORE_IN_PACKAGE
4447 *
4448 * increment topo.num_cores when 1st core in pkg seen
4449 */ 4833 */
4450void init_counter(struct thread_data *thread_base, struct core_data *core_base, 4834void init_counter(struct thread_data *thread_base, struct core_data *core_base,
4451 struct pkg_data *pkg_base, int thread_num, int core_num, 4835 struct pkg_data *pkg_base, int cpu_id)
4452 int pkg_num, int cpu_id)
4453{ 4836{
4837 int pkg_id = cpus[cpu_id].physical_package_id;
4838 int node_id = cpus[cpu_id].logical_node_id;
4839 int core_id = cpus[cpu_id].physical_core_id;
4840 int thread_id = cpus[cpu_id].thread_id;
4454 struct thread_data *t; 4841 struct thread_data *t;
4455 struct core_data *c; 4842 struct core_data *c;
4456 struct pkg_data *p; 4843 struct pkg_data *p;
4457 4844
4458 t = GET_THREAD(thread_base, thread_num, core_num, pkg_num); 4845 t = GET_THREAD(thread_base, thread_id, core_id, node_id, pkg_id);
4459 c = GET_CORE(core_base, core_num, pkg_num); 4846 c = GET_CORE(core_base, core_id, node_id, pkg_id);
4460 p = GET_PKG(pkg_base, pkg_num); 4847 p = GET_PKG(pkg_base, pkg_id);
4461 4848
4462 t->cpu_id = cpu_id; 4849 t->cpu_id = cpu_id;
4463 if (thread_num == 0) { 4850 if (thread_id == 0) {
4464 t->flags |= CPU_IS_FIRST_THREAD_IN_CORE; 4851 t->flags |= CPU_IS_FIRST_THREAD_IN_CORE;
4465 if (cpu_is_first_core_in_package(cpu_id)) 4852 if (cpu_is_first_core_in_package(cpu_id))
4466 t->flags |= CPU_IS_FIRST_CORE_IN_PACKAGE; 4853 t->flags |= CPU_IS_FIRST_CORE_IN_PACKAGE;
4467 } 4854 }
4468 4855
4469 c->core_id = core_num; 4856 c->core_id = core_id;
4470 p->package_id = pkg_num; 4857 p->package_id = pkg_id;
4471} 4858}
4472 4859
4473 4860
4474int initialize_counters(int cpu_id) 4861int initialize_counters(int cpu_id)
4475{ 4862{
4476 int my_thread_id, my_core_id, my_package_id; 4863 init_counter(EVEN_COUNTERS, cpu_id);
4477 4864 init_counter(ODD_COUNTERS, cpu_id);
4478 my_package_id = get_physical_package_id(cpu_id);
4479 my_core_id = get_core_id(cpu_id);
4480 my_thread_id = get_cpu_position_in_core(cpu_id);
4481 if (!my_thread_id)
4482 topo.num_cores++;
4483
4484 init_counter(EVEN_COUNTERS, my_thread_id, my_core_id, my_package_id, cpu_id);
4485 init_counter(ODD_COUNTERS, my_thread_id, my_core_id, my_package_id, cpu_id);
4486 return 0; 4865 return 0;
4487} 4866}
4488 4867
@@ -4630,7 +5009,7 @@ int get_and_dump_counters(void)
4630} 5009}
4631 5010
4632void print_version() { 5011void print_version() {
4633 fprintf(outf, "turbostat version 17.06.23" 5012 fprintf(outf, "turbostat version 18.06.01"
4634 " - Len Brown <lenb@kernel.org>\n"); 5013 " - Len Brown <lenb@kernel.org>\n");
4635} 5014}
4636 5015
@@ -4661,7 +5040,7 @@ int add_counter(unsigned int msr_num, char *path, char *name,
4661 msrp->next = sys.tp; 5040 msrp->next = sys.tp;
4662 sys.tp = msrp; 5041 sys.tp = msrp;
4663 sys.added_thread_counters++; 5042 sys.added_thread_counters++;
4664 if (sys.added_thread_counters > MAX_ADDED_COUNTERS) { 5043 if (sys.added_thread_counters > MAX_ADDED_THREAD_COUNTERS) {
4665 fprintf(stderr, "exceeded max %d added thread counters\n", 5044 fprintf(stderr, "exceeded max %d added thread counters\n",
4666 MAX_ADDED_COUNTERS); 5045 MAX_ADDED_COUNTERS);
4667 exit(-1); 5046 exit(-1);
@@ -4820,7 +5199,7 @@ void probe_sysfs(void)
4820 if (!DO_BIC(BIC_sysfs)) 5199 if (!DO_BIC(BIC_sysfs))
4821 return; 5200 return;
4822 5201
4823 for (state = 10; state > 0; --state) { 5202 for (state = 10; state >= 0; --state) {
4824 5203
4825 sprintf(path, "/sys/devices/system/cpu/cpu%d/cpuidle/state%d/name", 5204 sprintf(path, "/sys/devices/system/cpu/cpu%d/cpuidle/state%d/name",
4826 base_cpu, state); 5205 base_cpu, state);
@@ -4847,7 +5226,7 @@ void probe_sysfs(void)
4847 FORMAT_PERCENT, SYSFS_PERCPU); 5226 FORMAT_PERCENT, SYSFS_PERCPU);
4848 } 5227 }
4849 5228
4850 for (state = 10; state > 0; --state) { 5229 for (state = 10; state >= 0; --state) {
4851 5230
4852 sprintf(path, "/sys/devices/system/cpu/cpu%d/cpuidle/state%d/name", 5231 sprintf(path, "/sys/devices/system/cpu/cpu%d/cpuidle/state%d/name",
4853 base_cpu, state); 5232 base_cpu, state);
@@ -4960,34 +5339,6 @@ error:
4960 exit(-1); 5339 exit(-1);
4961} 5340}
4962 5341
4963int shown;
4964/*
4965 * parse_show_hide() - process cmdline to set default counter action
4966 */
4967void parse_show_hide(char *optarg, enum show_hide_mode new_mode)
4968{
4969 /*
4970 * --show: show only those specified
4971 * The 1st invocation will clear and replace the enabled mask
4972 * subsequent invocations can add to it.
4973 */
4974 if (new_mode == SHOW_LIST) {
4975 if (shown == 0)
4976 bic_enabled = bic_lookup(optarg, new_mode);
4977 else
4978 bic_enabled |= bic_lookup(optarg, new_mode);
4979 shown = 1;
4980
4981 return;
4982 }
4983
4984 /*
4985 * --hide: do not show those specified
4986 * multiple invocations simply clear more bits in enabled mask
4987 */
4988 bic_enabled &= ~bic_lookup(optarg, new_mode);
4989
4990}
4991 5342
4992void cmdline(int argc, char **argv) 5343void cmdline(int argc, char **argv)
4993{ 5344{
@@ -4998,7 +5349,9 @@ void cmdline(int argc, char **argv)
4998 {"cpu", required_argument, 0, 'c'}, 5349 {"cpu", required_argument, 0, 'c'},
4999 {"Dump", no_argument, 0, 'D'}, 5350 {"Dump", no_argument, 0, 'D'},
5000 {"debug", no_argument, 0, 'd'}, /* internal, not documented */ 5351 {"debug", no_argument, 0, 'd'}, /* internal, not documented */
5352 {"enable", required_argument, 0, 'e'},
5001 {"interval", required_argument, 0, 'i'}, 5353 {"interval", required_argument, 0, 'i'},
5354 {"num_iterations", required_argument, 0, 'n'},
5002 {"help", no_argument, 0, 'h'}, 5355 {"help", no_argument, 0, 'h'},
5003 {"hide", required_argument, 0, 'H'}, // meh, -h taken by --help 5356 {"hide", required_argument, 0, 'H'}, // meh, -h taken by --help
5004 {"Joules", no_argument, 0, 'J'}, 5357 {"Joules", no_argument, 0, 'J'},
@@ -5014,7 +5367,7 @@ void cmdline(int argc, char **argv)
5014 5367
5015 progname = argv[0]; 5368 progname = argv[0];
5016 5369
5017 while ((opt = getopt_long_only(argc, argv, "+C:c:Ddhi:JM:m:o:qST:v", 5370 while ((opt = getopt_long_only(argc, argv, "+C:c:Dde:hi:Jn:o:qST:v",
5018 long_options, &option_index)) != -1) { 5371 long_options, &option_index)) != -1) {
5019 switch (opt) { 5372 switch (opt) {
5020 case 'a': 5373 case 'a':
@@ -5026,11 +5379,20 @@ void cmdline(int argc, char **argv)
5026 case 'D': 5379 case 'D':
5027 dump_only++; 5380 dump_only++;
5028 break; 5381 break;
5382 case 'e':
5383 /* --enable specified counter */
5384 bic_enabled |= bic_lookup(optarg, SHOW_LIST);
5385 break;
5029 case 'd': 5386 case 'd':
5030 debug++; 5387 debug++;
5388 ENABLE_BIC(BIC_DISABLED_BY_DEFAULT);
5031 break; 5389 break;
5032 case 'H': 5390 case 'H':
5033 parse_show_hide(optarg, HIDE_LIST); 5391 /*
5392 * --hide: do not show those specified
5393 * multiple invocations simply clear more bits in enabled mask
5394 */
5395 bic_enabled &= ~bic_lookup(optarg, HIDE_LIST);
5034 break; 5396 break;
5035 case 'h': 5397 case 'h':
5036 default: 5398 default:
@@ -5046,7 +5408,8 @@ void cmdline(int argc, char **argv)
5046 exit(2); 5408 exit(2);
5047 } 5409 }
5048 5410
5049 interval_ts.tv_sec = interval; 5411 interval_tv.tv_sec = interval_ts.tv_sec = interval;
5412 interval_tv.tv_usec = (interval - interval_tv.tv_sec) * 1000000;
5050 interval_ts.tv_nsec = (interval - interval_ts.tv_sec) * 1000000000; 5413 interval_ts.tv_nsec = (interval - interval_ts.tv_sec) * 1000000000;
5051 } 5414 }
5052 break; 5415 break;
@@ -5054,6 +5417,7 @@ void cmdline(int argc, char **argv)
5054 rapl_joules++; 5417 rapl_joules++;
5055 break; 5418 break;
5056 case 'l': 5419 case 'l':
5420 ENABLE_BIC(BIC_DISABLED_BY_DEFAULT);
5057 list_header_only++; 5421 list_header_only++;
5058 quiet++; 5422 quiet++;
5059 break; 5423 break;
@@ -5063,8 +5427,26 @@ void cmdline(int argc, char **argv)
5063 case 'q': 5427 case 'q':
5064 quiet = 1; 5428 quiet = 1;
5065 break; 5429 break;
5430 case 'n':
5431 num_iterations = strtod(optarg, NULL);
5432
5433 if (num_iterations <= 0) {
5434 fprintf(outf, "iterations %d should be positive number\n",
5435 num_iterations);
5436 exit(2);
5437 }
5438 break;
5066 case 's': 5439 case 's':
5067 parse_show_hide(optarg, SHOW_LIST); 5440 /*
5441 * --show: show only those specified
5442 * The 1st invocation will clear and replace the enabled mask
5443 * subsequent invocations can add to it.
5444 */
5445 if (shown == 0)
5446 bic_enabled = bic_lookup(optarg, SHOW_LIST);
5447 else
5448 bic_enabled |= bic_lookup(optarg, SHOW_LIST);
5449 shown = 1;
5068 break; 5450 break;
5069 case 'S': 5451 case 'S':
5070 summary_only++; 5452 summary_only++;
diff --git a/tools/power/x86/x86_energy_perf_policy/Makefile b/tools/power/x86/x86_energy_perf_policy/Makefile
index 2447b1bbaacf..f4534fb8b951 100644
--- a/tools/power/x86/x86_energy_perf_policy/Makefile
+++ b/tools/power/x86/x86_energy_perf_policy/Makefile
@@ -24,5 +24,5 @@ install : x86_energy_perf_policy
24 install -d $(DESTDIR)$(PREFIX)/bin 24 install -d $(DESTDIR)$(PREFIX)/bin
25 install $(BUILD_OUTPUT)/x86_energy_perf_policy $(DESTDIR)$(PREFIX)/bin/x86_energy_perf_policy 25 install $(BUILD_OUTPUT)/x86_energy_perf_policy $(DESTDIR)$(PREFIX)/bin/x86_energy_perf_policy
26 install -d $(DESTDIR)$(PREFIX)/share/man/man8 26 install -d $(DESTDIR)$(PREFIX)/share/man/man8
27 install x86_energy_perf_policy.8 $(DESTDIR)$(PREFIX)/share/man/man8 27 install -m 644 x86_energy_perf_policy.8 $(DESTDIR)$(PREFIX)/share/man/man8
28 28