Skip to content

Commit 59410f5

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-urgent-for-mingo-4.16-20180205' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf/urgent fixes from Arnaldo Carvalho de Melo: - Fix 'period' and 'freq' handling for 'perf record', also related: add Add PERF_SAMPLE_PERIOD into PEBS_FREERUNNING_FLAGS in the x86 perf kernel driver (Jiri Olsa) - Fix 'perf trace -i perf.data' callgraph handling (Ravi Bangoria) - Synchronize tooling headers for asound, s390 and powerpc KVM, sched and x86 features (Arnaldo Carvalho de Melo) Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2 parents 72906f3 + 2fe2230 commit 59410f5

File tree

14 files changed

+91
-13
lines changed

14 files changed

+91
-13
lines changed

arch/x86/events/perf_event.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ struct amd_nb {
9393
PERF_SAMPLE_ID | PERF_SAMPLE_CPU | PERF_SAMPLE_STREAM_ID | \
9494
PERF_SAMPLE_DATA_SRC | PERF_SAMPLE_IDENTIFIER | \
9595
PERF_SAMPLE_TRANSACTION | PERF_SAMPLE_PHYS_ADDR | \
96-
PERF_SAMPLE_REGS_INTR | PERF_SAMPLE_REGS_USER)
96+
PERF_SAMPLE_REGS_INTR | PERF_SAMPLE_REGS_USER | \
97+
PERF_SAMPLE_PERIOD)
9798

9899
#define PEBS_REGS \
99100
(PERF_REG_X86_AX | \

tools/arch/powerpc/include/uapi/asm/kvm.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,31 @@ struct kvm_ppc_rmmu_info {
443443
__u32 ap_encodings[8];
444444
};
445445

446+
/* For KVM_PPC_GET_CPU_CHAR */
447+
struct kvm_ppc_cpu_char {
448+
__u64 character; /* characteristics of the CPU */
449+
__u64 behaviour; /* recommended software behaviour */
450+
__u64 character_mask; /* valid bits in character */
451+
__u64 behaviour_mask; /* valid bits in behaviour */
452+
};
453+
454+
/*
455+
* Values for character and character_mask.
456+
* These are identical to the values used by H_GET_CPU_CHARACTERISTICS.
457+
*/
458+
#define KVM_PPC_CPU_CHAR_SPEC_BAR_ORI31 (1ULL << 63)
459+
#define KVM_PPC_CPU_CHAR_BCCTRL_SERIALISED (1ULL << 62)
460+
#define KVM_PPC_CPU_CHAR_L1D_FLUSH_ORI30 (1ULL << 61)
461+
#define KVM_PPC_CPU_CHAR_L1D_FLUSH_TRIG2 (1ULL << 60)
462+
#define KVM_PPC_CPU_CHAR_L1D_THREAD_PRIV (1ULL << 59)
463+
#define KVM_PPC_CPU_CHAR_BR_HINT_HONOURED (1ULL << 58)
464+
#define KVM_PPC_CPU_CHAR_MTTRIG_THR_RECONF (1ULL << 57)
465+
#define KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS (1ULL << 56)
466+
467+
#define KVM_PPC_CPU_BEHAV_FAVOUR_SECURITY (1ULL << 63)
468+
#define KVM_PPC_CPU_BEHAV_L1D_FLUSH_PR (1ULL << 62)
469+
#define KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR (1ULL << 61)
470+
446471
/* Per-vcpu XICS interrupt controller state */
447472
#define KVM_REG_PPC_ICP_STATE (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x8c)
448473

tools/arch/s390/include/uapi/asm/kvm.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ struct kvm_guest_debug_arch {
224224
#define KVM_SYNC_RICCB (1UL << 7)
225225
#define KVM_SYNC_FPRS (1UL << 8)
226226
#define KVM_SYNC_GSCB (1UL << 9)
227+
#define KVM_SYNC_BPBC (1UL << 10)
227228
/* length and alignment of the sdnx as a power of two */
228229
#define SDNXC 8
229230
#define SDNXL (1UL << SDNXC)
@@ -247,7 +248,9 @@ struct kvm_sync_regs {
247248
};
248249
__u8 reserved[512]; /* for future vector expansion */
249250
__u32 fpc; /* valid on KVM_SYNC_VRS or KVM_SYNC_FPRS */
250-
__u8 padding1[52]; /* riccb needs to be 64byte aligned */
251+
__u8 bpbc : 1; /* bp mode */
252+
__u8 reserved2 : 7;
253+
__u8 padding1[51]; /* riccb needs to be 64byte aligned */
251254
__u8 riccb[64]; /* runtime instrumentation controls block */
252255
__u8 padding2[192]; /* sdnx needs to be 256byte aligned */
253256
union {

tools/arch/x86/include/asm/cpufeatures.h

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/*
1414
* Defines x86 CPU feature bits
1515
*/
16-
#define NCAPINTS 18 /* N 32-bit words worth of info */
16+
#define NCAPINTS 19 /* N 32-bit words worth of info */
1717
#define NBUGINTS 1 /* N 32-bit bug flags */
1818

1919
/*
@@ -203,12 +203,15 @@
203203
#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9) /* AMD ProcFeedbackInterface */
204204
#define X86_FEATURE_SME ( 7*32+10) /* AMD Secure Memory Encryption */
205205
#define X86_FEATURE_PTI ( 7*32+11) /* Kernel Page Table Isolation enabled */
206+
#define X86_FEATURE_RETPOLINE ( 7*32+12) /* "" Generic Retpoline mitigation for Spectre variant 2 */
207+
#define X86_FEATURE_RETPOLINE_AMD ( 7*32+13) /* "" AMD Retpoline mitigation for Spectre variant 2 */
206208
#define X86_FEATURE_INTEL_PPIN ( 7*32+14) /* Intel Processor Inventory Number */
207-
#define X86_FEATURE_INTEL_PT ( 7*32+15) /* Intel Processor Trace */
208-
#define X86_FEATURE_AVX512_4VNNIW ( 7*32+16) /* AVX-512 Neural Network Instructions */
209-
#define X86_FEATURE_AVX512_4FMAPS ( 7*32+17) /* AVX-512 Multiply Accumulation Single precision */
209+
#define X86_FEATURE_CDP_L2 ( 7*32+15) /* Code and Data Prioritization L2 */
210210

211211
#define X86_FEATURE_MBA ( 7*32+18) /* Memory Bandwidth Allocation */
212+
#define X86_FEATURE_RSB_CTXSW ( 7*32+19) /* "" Fill RSB on context switches */
213+
214+
#define X86_FEATURE_USE_IBPB ( 7*32+21) /* "" Indirect Branch Prediction Barrier enabled */
212215

213216
/* Virtualization flags: Linux defined, word 8 */
214217
#define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */
@@ -243,6 +246,7 @@
243246
#define X86_FEATURE_AVX512IFMA ( 9*32+21) /* AVX-512 Integer Fused Multiply-Add instructions */
244247
#define X86_FEATURE_CLFLUSHOPT ( 9*32+23) /* CLFLUSHOPT instruction */
245248
#define X86_FEATURE_CLWB ( 9*32+24) /* CLWB instruction */
249+
#define X86_FEATURE_INTEL_PT ( 9*32+25) /* Intel Processor Trace */
246250
#define X86_FEATURE_AVX512PF ( 9*32+26) /* AVX-512 Prefetch */
247251
#define X86_FEATURE_AVX512ER ( 9*32+27) /* AVX-512 Exponential and Reciprocal */
248252
#define X86_FEATURE_AVX512CD ( 9*32+28) /* AVX-512 Conflict Detection */
@@ -268,6 +272,9 @@
268272
#define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */
269273
#define X86_FEATURE_IRPERF (13*32+ 1) /* Instructions Retired Count */
270274
#define X86_FEATURE_XSAVEERPTR (13*32+ 2) /* Always save/restore FP error pointers */
275+
#define X86_FEATURE_IBPB (13*32+12) /* Indirect Branch Prediction Barrier */
276+
#define X86_FEATURE_IBRS (13*32+14) /* Indirect Branch Restricted Speculation */
277+
#define X86_FEATURE_STIBP (13*32+15) /* Single Thread Indirect Branch Predictors */
271278

272279
/* Thermal and Power Management Leaf, CPUID level 0x00000006 (EAX), word 14 */
273280
#define X86_FEATURE_DTHERM (14*32+ 0) /* Digital Thermal Sensor */
@@ -316,6 +323,13 @@
316323
#define X86_FEATURE_SUCCOR (17*32+ 1) /* Uncorrectable error containment and recovery */
317324
#define X86_FEATURE_SMCA (17*32+ 3) /* Scalable MCA */
318325

326+
/* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */
327+
#define X86_FEATURE_AVX512_4VNNIW (18*32+ 2) /* AVX-512 Neural Network Instructions */
328+
#define X86_FEATURE_AVX512_4FMAPS (18*32+ 3) /* AVX-512 Multiply Accumulation Single precision */
329+
#define X86_FEATURE_SPEC_CTRL (18*32+26) /* "" Speculation Control (IBRS + IBPB) */
330+
#define X86_FEATURE_INTEL_STIBP (18*32+27) /* "" Single Thread Indirect Branch Predictors */
331+
#define X86_FEATURE_ARCH_CAPABILITIES (18*32+29) /* IA32_ARCH_CAPABILITIES MSR (Intel) */
332+
319333
/*
320334
* BUG word(s)
321335
*/
@@ -342,5 +356,7 @@
342356
#define X86_BUG_MONITOR X86_BUG(12) /* IPI required to wake up remote CPU */
343357
#define X86_BUG_AMD_E400 X86_BUG(13) /* CPU is among the affected by Erratum 400 */
344358
#define X86_BUG_CPU_MELTDOWN X86_BUG(14) /* CPU is affected by meltdown attack and needs kernel page table isolation */
359+
#define X86_BUG_SPECTRE_V1 X86_BUG(15) /* CPU is affected by Spectre variant 1 attack with conditional branches */
360+
#define X86_BUG_SPECTRE_V2 X86_BUG(16) /* CPU is affected by Spectre variant 2 attack with indirect branches */
345361

346362
#endif /* _ASM_X86_CPUFEATURES_H */

tools/arch/x86/include/asm/disabled-features.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
#define DISABLED_MASK15 0
7878
#define DISABLED_MASK16 (DISABLE_PKU|DISABLE_OSPKE|DISABLE_LA57|DISABLE_UMIP)
7979
#define DISABLED_MASK17 0
80-
#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 18)
80+
#define DISABLED_MASK18 0
81+
#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19)
8182

8283
#endif /* _ASM_X86_DISABLED_FEATURES_H */

tools/arch/x86/include/asm/required-features.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
#define REQUIRED_MASK15 0
107107
#define REQUIRED_MASK16 (NEED_LA57)
108108
#define REQUIRED_MASK17 0
109-
#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 18)
109+
#define REQUIRED_MASK18 0
110+
#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19)
110111

111112
#endif /* _ASM_X86_REQUIRED_FEATURES_H */

tools/include/uapi/linux/kvm.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,8 @@ struct kvm_ppc_resize_hpt {
932932
#define KVM_CAP_HYPERV_SYNIC2 148
933933
#define KVM_CAP_HYPERV_VP_INDEX 149
934934
#define KVM_CAP_S390_AIS_MIGRATION 150
935+
#define KVM_CAP_PPC_GET_CPU_CHAR 151
936+
#define KVM_CAP_S390_BPB 152
935937

936938
#ifdef KVM_CAP_IRQ_ROUTING
937939

@@ -1261,6 +1263,8 @@ struct kvm_s390_ucas_mapping {
12611263
#define KVM_PPC_CONFIGURE_V3_MMU _IOW(KVMIO, 0xaf, struct kvm_ppc_mmuv3_cfg)
12621264
/* Available with KVM_CAP_PPC_RADIX_MMU */
12631265
#define KVM_PPC_GET_RMMU_INFO _IOW(KVMIO, 0xb0, struct kvm_ppc_rmmu_info)
1266+
/* Available with KVM_CAP_PPC_GET_CPU_CHAR */
1267+
#define KVM_PPC_GET_CPU_CHAR _IOR(KVMIO, 0xb1, struct kvm_ppc_cpu_char)
12641268

12651269
/* ioctl for vm fd */
12661270
#define KVM_CREATE_DEVICE _IOWR(KVMIO, 0xe0, struct kvm_create_device)

tools/include/uapi/linux/sched.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,10 @@
4949
*/
5050
#define SCHED_FLAG_RESET_ON_FORK 0x01
5151
#define SCHED_FLAG_RECLAIM 0x02
52+
#define SCHED_FLAG_DL_OVERRUN 0x04
53+
54+
#define SCHED_FLAG_ALL (SCHED_FLAG_RESET_ON_FORK | \
55+
SCHED_FLAG_RECLAIM | \
56+
SCHED_FLAG_DL_OVERRUN)
5257

5358
#endif /* _UAPI_LINUX_SCHED_H */

tools/include/uapi/sound/asound.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ typedef int __bitwise snd_pcm_format_t;
214214
#define SNDRV_PCM_FORMAT_IMA_ADPCM ((__force snd_pcm_format_t) 22)
215215
#define SNDRV_PCM_FORMAT_MPEG ((__force snd_pcm_format_t) 23)
216216
#define SNDRV_PCM_FORMAT_GSM ((__force snd_pcm_format_t) 24)
217+
#define SNDRV_PCM_FORMAT_S20_LE ((__force snd_pcm_format_t) 25) /* in four bytes, LSB justified */
218+
#define SNDRV_PCM_FORMAT_S20_BE ((__force snd_pcm_format_t) 26) /* in four bytes, LSB justified */
219+
#define SNDRV_PCM_FORMAT_U20_LE ((__force snd_pcm_format_t) 27) /* in four bytes, LSB justified */
220+
#define SNDRV_PCM_FORMAT_U20_BE ((__force snd_pcm_format_t) 28) /* in four bytes, LSB justified */
221+
/* gap in the numbering for a future standard linear format */
217222
#define SNDRV_PCM_FORMAT_SPECIAL ((__force snd_pcm_format_t) 31)
218223
#define SNDRV_PCM_FORMAT_S24_3LE ((__force snd_pcm_format_t) 32) /* in three bytes */
219224
#define SNDRV_PCM_FORMAT_S24_3BE ((__force snd_pcm_format_t) 33) /* in three bytes */
@@ -248,6 +253,8 @@ typedef int __bitwise snd_pcm_format_t;
248253
#define SNDRV_PCM_FORMAT_FLOAT SNDRV_PCM_FORMAT_FLOAT_LE
249254
#define SNDRV_PCM_FORMAT_FLOAT64 SNDRV_PCM_FORMAT_FLOAT64_LE
250255
#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE
256+
#define SNDRV_PCM_FORMAT_S20 SNDRV_PCM_FORMAT_S20_LE
257+
#define SNDRV_PCM_FORMAT_U20 SNDRV_PCM_FORMAT_U20_LE
251258
#endif
252259
#ifdef SNDRV_BIG_ENDIAN
253260
#define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_BE
@@ -259,6 +266,8 @@ typedef int __bitwise snd_pcm_format_t;
259266
#define SNDRV_PCM_FORMAT_FLOAT SNDRV_PCM_FORMAT_FLOAT_BE
260267
#define SNDRV_PCM_FORMAT_FLOAT64 SNDRV_PCM_FORMAT_FLOAT64_BE
261268
#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE
269+
#define SNDRV_PCM_FORMAT_S20 SNDRV_PCM_FORMAT_S20_BE
270+
#define SNDRV_PCM_FORMAT_U20 SNDRV_PCM_FORMAT_U20_BE
262271
#endif
263272

264273
typedef int __bitwise snd_pcm_subformat_t;

tools/perf/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ config.mak.autogen
3131
.config-detected
3232
util/intel-pt-decoder/inat-tables.c
3333
arch/*/include/generated/
34+
trace/beauty/generated/
3435
pmu-events/pmu-events.c
3536
pmu-events/jevents

tools/perf/builtin-record.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,8 @@ static struct option __record_options[] = {
15661566
OPT_BOOLEAN_SET('T', "timestamp", &record.opts.sample_time,
15671567
&record.opts.sample_time_set,
15681568
"Record the sample timestamps"),
1569-
OPT_BOOLEAN('P', "period", &record.opts.period, "Record the sample period"),
1569+
OPT_BOOLEAN_SET('P', "period", &record.opts.period, &record.opts.period_set,
1570+
"Record the sample period"),
15701571
OPT_BOOLEAN('n', "no-samples", &record.opts.no_samples,
15711572
"don't sample"),
15721573
OPT_BOOLEAN_SET('N', "no-buildid-cache", &record.no_buildid_cache,

tools/perf/builtin-trace.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1661,9 +1661,12 @@ static int trace__resolve_callchain(struct trace *trace, struct perf_evsel *evse
16611661
struct callchain_cursor *cursor)
16621662
{
16631663
struct addr_location al;
1664+
int max_stack = evsel->attr.sample_max_stack ?
1665+
evsel->attr.sample_max_stack :
1666+
trace->max_stack;
16641667

16651668
if (machine__resolve(trace->host, &al, sample) < 0 ||
1666-
thread__resolve_callchain(al.thread, cursor, evsel, sample, NULL, NULL, evsel->attr.sample_max_stack))
1669+
thread__resolve_callchain(al.thread, cursor, evsel, sample, NULL, NULL, max_stack))
16671670
return -1;
16681671

16691672
return 0;

tools/perf/perf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ struct record_opts {
5050
bool sample_time_set;
5151
bool sample_cpu;
5252
bool period;
53+
bool period_set;
5354
bool running_time;
5455
bool full_auxtrace;
5556
bool auxtrace_snapshot_mode;

tools/perf/util/evsel.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,12 +745,14 @@ static void apply_config_terms(struct perf_evsel *evsel,
745745
if (!(term->weak && opts->user_interval != ULLONG_MAX)) {
746746
attr->sample_period = term->val.period;
747747
attr->freq = 0;
748+
perf_evsel__reset_sample_bit(evsel, PERIOD);
748749
}
749750
break;
750751
case PERF_EVSEL__CONFIG_TERM_FREQ:
751752
if (!(term->weak && opts->user_freq != UINT_MAX)) {
752753
attr->sample_freq = term->val.freq;
753754
attr->freq = 1;
755+
perf_evsel__set_sample_bit(evsel, PERIOD);
754756
}
755757
break;
756758
case PERF_EVSEL__CONFIG_TERM_TIME:
@@ -969,9 +971,6 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
969971
if (target__has_cpu(&opts->target) || opts->sample_cpu)
970972
perf_evsel__set_sample_bit(evsel, CPU);
971973

972-
if (opts->period)
973-
perf_evsel__set_sample_bit(evsel, PERIOD);
974-
975974
/*
976975
* When the user explicitly disabled time don't force it here.
977976
*/
@@ -1073,6 +1072,14 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
10731072
apply_config_terms(evsel, opts, track);
10741073

10751074
evsel->ignore_missing_thread = opts->ignore_missing_thread;
1075+
1076+
/* The --period option takes the precedence. */
1077+
if (opts->period_set) {
1078+
if (opts->period)
1079+
perf_evsel__set_sample_bit(evsel, PERIOD);
1080+
else
1081+
perf_evsel__reset_sample_bit(evsel, PERIOD);
1082+
}
10761083
}
10771084

10781085
static int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)

0 commit comments

Comments
 (0)