Skip to content

Commit 3cace81

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-urgent-for-mingo-20160815' 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 occasional decoding errors when tracing system-wide with Intel PT (Adrian Hunter) - Fix ip compression in Intel PT for some specific packet types not present on current hardware (Adrian Hunter) - Fix annotation of objects with debuginfo files (Anton Blanchard) - Fix build on Fedora Rawhide (25) wrt using the right header to get the major() & minor() definitions in the jitdump code, now it is deprecated getting those using sys/types.h, one has to use sys/sysmacros.h (Arnaldo Carvalho de Melo) - Sync arm64/s390 kvm related header files (Arnaldo Carvalho de Melo) - Check for dup and fdopen failures in 'perf probe' (Colin Ian King, Arnaldo Carvalho de Melo) - Fix showing callchains in pipe mode, i.e. perf record -g -o - workload | perf script now shows callchains (He Kuang) - Show proper message when the scripts directory points to some invalid location in 'perf script --list' (He Kuang) - Fix 'perf mem -t store' to record 'cpu/mem-stores/P' events again (Jiri Olsa) - Fix ppc64le build failure when libelf is not present (Ravi Bangoria) Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2 parents 3684b03 + 3d918fb commit 3cace81

File tree

12 files changed

+136
-40
lines changed

12 files changed

+136
-40
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ struct kvm_regs {
8787
/* Supported VGICv3 address types */
8888
#define KVM_VGIC_V3_ADDR_TYPE_DIST 2
8989
#define KVM_VGIC_V3_ADDR_TYPE_REDIST 3
90+
#define KVM_VGIC_ITS_ADDR_TYPE 4
9091

9192
#define KVM_VGIC_V3_DIST_SIZE SZ_64K
9293
#define KVM_VGIC_V3_REDIST_SIZE (2 * SZ_64K)
94+
#define KVM_VGIC_V3_ITS_SIZE (2 * SZ_64K)
9395

9496
#define KVM_ARM_VCPU_POWER_OFF 0 /* CPU is started in OFF state */
9597
#define KVM_ARM_VCPU_EL1_32BIT 1 /* CPU running a 32bit VM */

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,47 @@ struct kvm_s390_vm_cpu_machine {
9393
__u64 fac_list[256];
9494
};
9595

96+
#define KVM_S390_VM_CPU_PROCESSOR_FEAT 2
97+
#define KVM_S390_VM_CPU_MACHINE_FEAT 3
98+
99+
#define KVM_S390_VM_CPU_FEAT_NR_BITS 1024
100+
#define KVM_S390_VM_CPU_FEAT_ESOP 0
101+
#define KVM_S390_VM_CPU_FEAT_SIEF2 1
102+
#define KVM_S390_VM_CPU_FEAT_64BSCAO 2
103+
#define KVM_S390_VM_CPU_FEAT_SIIF 3
104+
#define KVM_S390_VM_CPU_FEAT_GPERE 4
105+
#define KVM_S390_VM_CPU_FEAT_GSLS 5
106+
#define KVM_S390_VM_CPU_FEAT_IB 6
107+
#define KVM_S390_VM_CPU_FEAT_CEI 7
108+
#define KVM_S390_VM_CPU_FEAT_IBS 8
109+
#define KVM_S390_VM_CPU_FEAT_SKEY 9
110+
#define KVM_S390_VM_CPU_FEAT_CMMA 10
111+
#define KVM_S390_VM_CPU_FEAT_PFMFI 11
112+
#define KVM_S390_VM_CPU_FEAT_SIGPIF 12
113+
struct kvm_s390_vm_cpu_feat {
114+
__u64 feat[16];
115+
};
116+
117+
#define KVM_S390_VM_CPU_PROCESSOR_SUBFUNC 4
118+
#define KVM_S390_VM_CPU_MACHINE_SUBFUNC 5
119+
/* for "test bit" instructions MSB 0 bit ordering, for "query" raw blocks */
120+
struct kvm_s390_vm_cpu_subfunc {
121+
__u8 plo[32]; /* always */
122+
__u8 ptff[16]; /* with TOD-clock steering */
123+
__u8 kmac[16]; /* with MSA */
124+
__u8 kmc[16]; /* with MSA */
125+
__u8 km[16]; /* with MSA */
126+
__u8 kimd[16]; /* with MSA */
127+
__u8 klmd[16]; /* with MSA */
128+
__u8 pckmo[16]; /* with MSA3 */
129+
__u8 kmctr[16]; /* with MSA4 */
130+
__u8 kmf[16]; /* with MSA4 */
131+
__u8 kmo[16]; /* with MSA4 */
132+
__u8 pcc[16]; /* with MSA4 */
133+
__u8 ppno[16]; /* with MSA5 */
134+
__u8 reserved[1824];
135+
};
136+
96137
/* kvm attributes for crypto */
97138
#define KVM_S390_VM_CRYPTO_ENABLE_AES_KW 0
98139
#define KVM_S390_VM_CRYPTO_ENABLE_DEA_KW 1

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
exit_code_ipa0(0xB2, 0x4c, "TAR"), \
141141
exit_code_ipa0(0xB2, 0x50, "CSP"), \
142142
exit_code_ipa0(0xB2, 0x54, "MVPG"), \
143+
exit_code_ipa0(0xB2, 0x56, "STHYI"), \
143144
exit_code_ipa0(0xB2, 0x58, "BSG"), \
144145
exit_code_ipa0(0xB2, 0x5a, "BSA"), \
145146
exit_code_ipa0(0xB2, 0x5f, "CHSC"), \

tools/perf/arch/powerpc/util/sym-handling.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ void arch__fix_tev_from_maps(struct perf_probe_event *pev,
9797
}
9898
}
9999

100+
#ifdef HAVE_LIBELF_SUPPORT
100101
void arch__post_process_probe_trace_events(struct perf_probe_event *pev,
101102
int ntevs)
102103
{
@@ -118,5 +119,6 @@ void arch__post_process_probe_trace_events(struct perf_probe_event *pev,
118119
}
119120
}
120121
}
122+
#endif /* HAVE_LIBELF_SUPPORT */
121123

122124
#endif

tools/perf/arch/x86/util/intel-pt.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
501501
struct intel_pt_recording *ptr =
502502
container_of(itr, struct intel_pt_recording, itr);
503503
struct perf_pmu *intel_pt_pmu = ptr->intel_pt_pmu;
504-
bool have_timing_info;
504+
bool have_timing_info, need_immediate = false;
505505
struct perf_evsel *evsel, *intel_pt_evsel = NULL;
506506
const struct cpu_map *cpus = evlist->cpus;
507507
bool privileged = geteuid() == 0 || perf_event_paranoid() < 0;
@@ -655,6 +655,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
655655
ptr->have_sched_switch = 3;
656656
} else {
657657
opts->record_switch_events = true;
658+
need_immediate = true;
658659
if (cpu_wide)
659660
ptr->have_sched_switch = 3;
660661
else
@@ -700,6 +701,9 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
700701
tracking_evsel->attr.freq = 0;
701702
tracking_evsel->attr.sample_period = 1;
702703

704+
if (need_immediate)
705+
tracking_evsel->immediate = true;
706+
703707
/* In per-cpu case, always need the time of mmap events etc */
704708
if (!cpu_map__empty(cpus)) {
705709
perf_evsel__set_sample_bit(tracking_evsel, TIME);

tools/perf/builtin-mem.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
8888
if (mem->operation & MEM_OPERATION_LOAD)
8989
perf_mem_events[PERF_MEM_EVENTS__LOAD].record = true;
9090

91+
if (mem->operation & MEM_OPERATION_STORE)
92+
perf_mem_events[PERF_MEM_EVENTS__STORE].record = true;
93+
9194
if (perf_mem_events[PERF_MEM_EVENTS__LOAD].record)
9295
rec_argv[i++] = "-W";
9396

tools/perf/builtin-script.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,14 +371,16 @@ static int perf_session__check_output_opt(struct perf_session *session)
371371

372372
if (!no_callchain) {
373373
bool use_callchain = false;
374+
bool not_pipe = false;
374375

375376
evlist__for_each_entry(session->evlist, evsel) {
377+
not_pipe = true;
376378
if (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN) {
377379
use_callchain = true;
378380
break;
379381
}
380382
}
381-
if (!use_callchain)
383+
if (not_pipe && !use_callchain)
382384
symbol_conf.use_callchain = false;
383385
}
384386

@@ -1690,8 +1692,13 @@ static int list_available_scripts(const struct option *opt __maybe_unused,
16901692
snprintf(scripts_path, MAXPATHLEN, "%s/scripts", get_argv_exec_path());
16911693

16921694
scripts_dir = opendir(scripts_path);
1693-
if (!scripts_dir)
1694-
return -1;
1695+
if (!scripts_dir) {
1696+
fprintf(stdout,
1697+
"open(%s) failed.\n"
1698+
"Check \"PERF_EXEC_PATH\" env to set scripts dir.\n",
1699+
scripts_path);
1700+
exit(-1);
1701+
}
16951702

16961703
for_each_lang(scripts_path, scripts_dir, lang_dirent) {
16971704
snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,

tools/perf/util/intel-pt-decoder/intel-pt-decoder.c

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ struct intel_pt_decoder {
123123
bool have_calc_cyc_to_tsc;
124124
int exec_mode;
125125
unsigned int insn_bytes;
126-
uint64_t sign_bit;
127-
uint64_t sign_bits;
128126
uint64_t period;
129127
enum intel_pt_period_type period_type;
130128
uint64_t tot_insn_cnt;
@@ -191,9 +189,6 @@ struct intel_pt_decoder *intel_pt_decoder_new(struct intel_pt_params *params)
191189
decoder->data = params->data;
192190
decoder->return_compression = params->return_compression;
193191

194-
decoder->sign_bit = (uint64_t)1 << 47;
195-
decoder->sign_bits = ~(((uint64_t)1 << 48) - 1);
196-
197192
decoder->period = params->period;
198193
decoder->period_type = params->period_type;
199194

@@ -362,38 +357,43 @@ int intel_pt__strerror(int code, char *buf, size_t buflen)
362357
return 0;
363358
}
364359

365-
static uint64_t intel_pt_calc_ip(struct intel_pt_decoder *decoder,
366-
const struct intel_pt_pkt *packet,
360+
static uint64_t intel_pt_calc_ip(const struct intel_pt_pkt *packet,
367361
uint64_t last_ip)
368362
{
369363
uint64_t ip;
370364

371365
switch (packet->count) {
372-
case 2:
366+
case 1:
373367
ip = (last_ip & (uint64_t)0xffffffffffff0000ULL) |
374368
packet->payload;
375369
break;
376-
case 4:
370+
case 2:
377371
ip = (last_ip & (uint64_t)0xffffffff00000000ULL) |
378372
packet->payload;
379373
break;
374+
case 3:
375+
ip = packet->payload;
376+
/* Sign-extend 6-byte ip */
377+
if (ip & (uint64_t)0x800000000000ULL)
378+
ip |= (uint64_t)0xffff000000000000ULL;
379+
break;
380+
case 4:
381+
ip = (last_ip & (uint64_t)0xffff000000000000ULL) |
382+
packet->payload;
383+
break;
380384
case 6:
381385
ip = packet->payload;
382386
break;
383387
default:
384388
return 0;
385389
}
386390

387-
if (ip & decoder->sign_bit)
388-
return ip | decoder->sign_bits;
389-
390391
return ip;
391392
}
392393

393394
static inline void intel_pt_set_last_ip(struct intel_pt_decoder *decoder)
394395
{
395-
decoder->last_ip = intel_pt_calc_ip(decoder, &decoder->packet,
396-
decoder->last_ip);
396+
decoder->last_ip = intel_pt_calc_ip(&decoder->packet, decoder->last_ip);
397397
}
398398

399399
static inline void intel_pt_set_ip(struct intel_pt_decoder *decoder)
@@ -1657,6 +1657,12 @@ static int intel_pt_walk_trace(struct intel_pt_decoder *decoder)
16571657
}
16581658
}
16591659

1660+
static inline bool intel_pt_have_ip(struct intel_pt_decoder *decoder)
1661+
{
1662+
return decoder->last_ip || decoder->packet.count == 0 ||
1663+
decoder->packet.count == 3 || decoder->packet.count == 6;
1664+
}
1665+
16601666
/* Walk PSB+ packets to get in sync. */
16611667
static int intel_pt_walk_psb(struct intel_pt_decoder *decoder)
16621668
{
@@ -1677,8 +1683,7 @@ static int intel_pt_walk_psb(struct intel_pt_decoder *decoder)
16771683

16781684
case INTEL_PT_FUP:
16791685
decoder->pge = true;
1680-
if (decoder->last_ip || decoder->packet.count == 6 ||
1681-
decoder->packet.count == 0) {
1686+
if (intel_pt_have_ip(decoder)) {
16821687
uint64_t current_ip = decoder->ip;
16831688

16841689
intel_pt_set_ip(decoder);
@@ -1767,18 +1772,15 @@ static int intel_pt_walk_to_ip(struct intel_pt_decoder *decoder)
17671772
case INTEL_PT_TIP_PGE:
17681773
case INTEL_PT_TIP:
17691774
decoder->pge = decoder->packet.type != INTEL_PT_TIP_PGD;
1770-
if (decoder->last_ip || decoder->packet.count == 6 ||
1771-
decoder->packet.count == 0)
1775+
if (intel_pt_have_ip(decoder))
17721776
intel_pt_set_ip(decoder);
17731777
if (decoder->ip)
17741778
return 0;
17751779
break;
17761780

17771781
case INTEL_PT_FUP:
17781782
if (decoder->overflow) {
1779-
if (decoder->last_ip ||
1780-
decoder->packet.count == 6 ||
1781-
decoder->packet.count == 0)
1783+
if (intel_pt_have_ip(decoder))
17821784
intel_pt_set_ip(decoder);
17831785
if (decoder->ip)
17841786
return 0;

tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -292,36 +292,46 @@ static int intel_pt_get_ip(enum intel_pt_pkt_type type, unsigned int byte,
292292
const unsigned char *buf, size_t len,
293293
struct intel_pt_pkt *packet)
294294
{
295-
switch (byte >> 5) {
295+
int ip_len;
296+
297+
packet->count = byte >> 5;
298+
299+
switch (packet->count) {
296300
case 0:
297-
packet->count = 0;
301+
ip_len = 0;
298302
break;
299303
case 1:
300304
if (len < 3)
301305
return INTEL_PT_NEED_MORE_BYTES;
302-
packet->count = 2;
306+
ip_len = 2;
303307
packet->payload = le16_to_cpu(*(uint16_t *)(buf + 1));
304308
break;
305309
case 2:
306310
if (len < 5)
307311
return INTEL_PT_NEED_MORE_BYTES;
308-
packet->count = 4;
312+
ip_len = 4;
309313
packet->payload = le32_to_cpu(*(uint32_t *)(buf + 1));
310314
break;
311315
case 3:
312-
case 6:
316+
case 4:
313317
if (len < 7)
314318
return INTEL_PT_NEED_MORE_BYTES;
315-
packet->count = 6;
319+
ip_len = 6;
316320
memcpy_le64(&packet->payload, buf + 1, 6);
317321
break;
322+
case 6:
323+
if (len < 9)
324+
return INTEL_PT_NEED_MORE_BYTES;
325+
ip_len = 8;
326+
packet->payload = le64_to_cpu(*(uint64_t *)(buf + 1));
327+
break;
318328
default:
319329
return INTEL_PT_BAD_PACKET;
320330
}
321331

322332
packet->type = type;
323333

324-
return packet->count + 1;
334+
return ip_len + 1;
325335
}
326336

327337
static int intel_pt_get_mode(const unsigned char *buf, size_t len,

tools/perf/util/jitdump.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <sys/sysmacros.h>
12
#include <sys/types.h>
23
#include <stdio.h>
34
#include <stdlib.h>

0 commit comments

Comments
 (0)