[PATCH v1 10/48] perf arch x86: Silence -Wshorten-64-to-32 warnings

Ian Rogers
2025-04-01T18:24:58Z

tools/perf/arch/x86/tests/bp-modify.c | 2 +-
tools/perf/arch/x86/util/intel-bts.c | 4 +-
tools/perf/arch/x86/util/intel-pt.c | 10 ++---
tools/perf/arch/x86/util/iostat.c | 2 +-
tools/perf/arch/x86/util/kvm-stat.c | 6 +--
tools/perf/arch/x86/util/perf_regs.c | 3 +-
tools/perf/arch/x86/util/topdown.c | 2 +-
tools/perf/util/intel-bts.c | 4 +-
.../util/intel-pt-decoder/intel-pt-decoder.c | 30 +++++++--------
.../intel-pt-decoder/intel-pt-insn-decoder.c | 2 +-
.../perf/util/intel-pt-decoder/intel-pt-log.c | 2 +-
.../intel-pt-decoder/intel-pt-pkt-decoder.c | 2 +-
tools/perf/util/intel-pt.c | 38 +++++++++----------
tools/perf/util/intel-tpebs.c | 6 +--
14 files changed, 57 insertions(+), 56 deletions(-)

diff --git a/tools/perf/arch/x86/tests/bp-modify.c b/tools/perf/arch/x86/tests/bp-modify.c
index 0924ccd9e36d..0bbc81fe9b1d 100644
--- a/tools/perf/arch/x86/tests/bp-modify.c
+++ b/tools/perf/arch/x86/tests/bp-modify.c
@@ -37,7 +37,7 @@ static int spawn_child(void)
* waits in signal for parent to trace it,
* then it calls bp_1 and quits.
*/
- int err = ptrace(PTRACE_TRACEME, 0, NULL, NULL);
+ int err = (int)ptrace(PTRACE_TRACEME, 0, NULL, NULL);

if (err) {
pr_debug("failed to PTRACE_TRACEME\n");
diff --git a/tools/perf/arch/x86/util/intel-bts.c b/tools/perf/arch/x86/util/intel-bts.c
index 85c8186300c8..1692ee735109 100644
--- a/tools/perf/arch/x86/util/intel-bts.c
+++ b/tools/perf/arch/x86/util/intel-bts.c
@@ -169,7 +169,7 @@ static int intel_bts_recording_options(struct auxtrace_record *itr,
size_t sz = opts->auxtrace_snapshot_size;

sz = round_up(sz, page_size) / page_size;
- opts->auxtrace_mmap_pages = roundup_pow_of_two(sz);
+ opts->auxtrace_mmap_pages = (unsigned int)roundup_pow_of_two(sz);
}
if (opts->auxtrace_snapshot_size >
opts->auxtrace_mmap_pages * (size_t)page_size) {
@@ -347,7 +347,7 @@ static int intel_bts_snapshot_finish(struct auxtrace_record *itr)

static bool intel_bts_first_wrap(u64 *data, size_t buf_size)
{
- int i, a, b;
+ size_t i, a, b;

b = buf_size >> 3;
a = b - 512;
diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
index 8f235d8b67b6..842dba02f082 100644
--- a/tools/perf/arch/x86/util/intel-pt.c
+++ b/tools/perf/arch/x86/util/intel-pt.c
@@ -418,7 +418,7 @@ static int intel_pt_track_switches(struct evlist *evlist)

evsel = evlist__add_sched_switch(evlist, true);
if (IS_ERR(evsel)) {
- err = PTR_ERR(evsel);
+ err = (int)PTR_ERR(evsel);
pr_debug2("%s: failed to create %s, error = %d\n",
__func__, sched_switch, err);
return err;
@@ -692,7 +692,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
size_t sz = opts->auxtrace_snapshot_size;

sz = round_up(sz, page_size) / page_size;
- opts->auxtrace_mmap_pages = roundup_pow_of_two(sz);
+ opts->auxtrace_mmap_pages = (unsigned int)roundup_pow_of_two(sz);
}
if (opts->auxtrace_snapshot_size >
opts->auxtrace_mmap_pages * (size_t)page_size) {
@@ -726,7 +726,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
if (!opts->auxtrace_mmap_pages) {
size_t sz = round_up(max_sz, page_size) / page_size;

- opts->auxtrace_mmap_pages = roundup_pow_of_two(sz);
+ opts->auxtrace_mmap_pages = (unsigned int)roundup_pow_of_two(sz);
}
if (max_sz > opts->auxtrace_mmap_pages * (size_t)page_size) {
pr_err("Sample size %zu must not be greater than AUX area tracing mmap size %zu\n",
@@ -772,7 +772,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,

if (!opts->auxtrace_snapshot_mode && !opts->auxtrace_sample_mode) {
size_t aw = opts->auxtrace_mmap_pages * (size_t)page_size / 4;
- u32 aux_watermark = aw > UINT_MAX ? UINT_MAX : aw;
+ u32 aux_watermark = aw > UINT_MAX ? UINT_MAX : (u32)aw;

intel_pt_evsel->core.attr.aux_watermark = aux_watermark;
}
@@ -1093,7 +1093,7 @@ static bool intel_pt_wrapped(struct intel_pt_recording *ptr, int idx,

static bool intel_pt_first_wrap(u64 *data, size_t buf_size)
{
- int i, a, b;
+ size_t i, a, b;

b = buf_size >> 3;
a = b - 512;
diff --git a/tools/perf/arch/x86/util/iostat.c b/tools/perf/arch/x86/util/iostat.c
index 7442a2cd87ed..ed508698dc22 100644
--- a/tools/perf/arch/x86/util/iostat.c
+++ b/tools/perf/arch/x86/util/iostat.c
@@ -305,7 +305,7 @@ static int iostat_event_group(struct evlist *evl,
uncore_iio_%x/event=0x83,umask=0x01,ch_mask=0xF,fc_mask=0x07/,\
uncore_iio_%x/event=0xc0,umask=0x04,ch_mask=0xF,fc_mask=0x07/,\
uncore_iio_%x/event=0xc0,umask=0x01,ch_mask=0xF,fc_mask=0x07/}";
- const int len_template = strlen(iostat_cmd_template) + 1;
+ const size_t len_template = strlen(iostat_cmd_template) + 1;
struct evsel *evsel = NULL;
int metrics_count = iostat_metrics_count();
char *iostat_cmd = calloc(len_template, 1);
diff --git a/tools/perf/arch/x86/util/kvm-stat.c b/tools/perf/arch/x86/util/kvm-stat.c
index 424716518b75..6e97198b055a 100644
--- a/tools/perf/arch/x86/util/kvm-stat.c
+++ b/tools/perf/arch/x86/util/kvm-stat.c
@@ -31,7 +31,7 @@ static void mmio_event_get_key(struct evsel *evsel, struct perf_sample *sample,
struct event_key *key)
{
key->key = evsel__intval(evsel, sample, "gpa");
- key->info = evsel__intval(evsel, sample, "type");
+ key->info = (int)evsel__intval(evsel, sample, "type");
}

#define KVM_TRACE_MMIO_READ_UNSATISFIED 0
@@ -94,7 +94,7 @@ static void ioport_event_get_key(struct evsel *evsel,
struct event_key *key)
{
key->key = evsel__intval(evsel, sample, "port");
- key->info = evsel__intval(evsel, sample, "rw");
+ key->info = (int)evsel__intval(evsel, sample, "rw");
}

static bool ioport_event_begin(struct evsel *evsel,
@@ -138,7 +138,7 @@ static void msr_event_get_key(struct evsel *evsel,
struct event_key *key)
{
key->key = evsel__intval(evsel, sample, "ecx");
- key->info = evsel__intval(evsel, sample, "write");
+ key->info = (int)evsel__intval(evsel, sample, "write");
}

static bool msr_event_begin(struct evsel *evsel,
diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c
index 12fd93f04802..ed0c564dad7e 100644
--- a/tools/perf/arch/x86/util/perf_regs.c
+++ b/tools/perf/arch/x86/util/perf_regs.c
@@ -195,7 +195,8 @@ static void sdt_rename_register(char *sdt_reg, int sdt_len, char *uprobe_reg)
int arch_sdt_arg_parse_op(char *old_op, char **new_op)
{
char new_reg[SDT_REG_NAME_SIZE] = {0};
- int new_len = 0, ret;
+ int ret;
+ size_t new_len = 0;
/*
* rm[0]: +/-NUM(REG)
* rm[1]: +/-
diff --git a/tools/perf/arch/x86/util/topdown.c b/tools/perf/arch/x86/util/topdown.c
index d1c654839049..c93c35c46145 100644
--- a/tools/perf/arch/x86/util/topdown.c
+++ b/tools/perf/arch/x86/util/topdown.c
@@ -43,7 +43,7 @@ bool arch_is_topdown_slots(const struct evsel *evsel)

bool arch_is_topdown_metrics(const struct evsel *evsel)
{
- int config = evsel->core.attr.config;
+ __u64 config = evsel->core.attr.config;
const char *name_from_config;
struct perf_pmu *pmu;

diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c
index 3625c6224750..2598df776d4e 100644
--- a/tools/perf/util/intel-bts.c
+++ b/tools/perf/util/intel-bts.c
@@ -850,9 +850,9 @@ int intel_bts_process_auxtrace_info(union perf_event *event,
bts->session = session;
bts->machine = &session->machines.host; /* No kvm support */
bts->auxtrace_type = auxtrace_info->type;
- bts->pmu_type = auxtrace_info->priv[INTEL_BTS_PMU_TYPE];
+ bts->pmu_type = (u32)auxtrace_info->priv[INTEL_BTS_PMU_TYPE];
bts->tc.time_shift = auxtrace_info->priv[INTEL_BTS_TIME_SHIFT];
- bts->tc.time_mult = auxtrace_info->priv[INTEL_BTS_TIME_MULT];
+ bts->tc.time_mult = (u32)auxtrace_info->priv[INTEL_BTS_TIME_MULT];
bts->tc.time_zero = auxtrace_info->priv[INTEL_BTS_TIME_ZERO];
bts->cap_user_time_zero =
auxtrace_info->priv[INTEL_BTS_CAP_USER_TIME_ZERO];
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
index e733f6b1f7ac..abb891f778cb 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
@@ -841,7 +841,7 @@ static int intel_pt_calc_cyc_cb(struct intel_pt_pkt_info *pkt_info)
if (!data->have_tma)
return 0;

- mtc = pkt_info->packet.payload;
+ mtc = (uint32_t)pkt_info->packet.payload;
if (decoder->mtc_shift > 8 && data->fixup_last_mtc) {
data->fixup_last_mtc = false;
intel_pt_fixup_last_mtc(mtc, decoder->mtc_shift,
@@ -904,7 +904,7 @@ static int intel_pt_calc_cyc_cb(struct intel_pt_pkt_info *pkt_info)
if (!decoder->tsc_ctc_ratio_d)
return 0;

- ctc = pkt_info->packet.payload;
+ ctc = (uint32_t)pkt_info->packet.payload;
fc = pkt_info->packet.count;
ctc_rem = ctc & decoder->ctc_rem_mask;

@@ -930,7 +930,7 @@ static int intel_pt_calc_cyc_cb(struct intel_pt_pkt_info *pkt_info)
return 0;

case INTEL_PT_CBR:
- cbr = pkt_info->packet.payload;
+ cbr = (uint32_t)pkt_info->packet.payload;
if (data->cbr && data->cbr != cbr)
return 1;
data->cbr = cbr;
@@ -1268,7 +1268,7 @@ static void intel_pt_mode_exec_status(struct intel_pt_decoder *decoder)
{
bool iflag = decoder->packet.count & INTEL_PT_IFLAG;

- decoder->exec_mode = decoder->packet.payload;
+ decoder->exec_mode = (int)decoder->packet.payload;
decoder->iflag = iflag;
decoder->next_iflag = iflag;
decoder->state.from_iflag = iflag;
@@ -1279,7 +1279,7 @@ static void intel_pt_mode_exec(struct intel_pt_decoder *decoder)
{
bool iflag = decoder->packet.count & INTEL_PT_IFLAG;

- decoder->exec_mode = decoder->packet.payload;
+ decoder->exec_mode = (int)decoder->packet.payload;
decoder->next_iflag = iflag;
}

@@ -1331,7 +1331,7 @@ static bool intel_pt_fup_event(struct intel_pt_decoder *decoder, bool no_tip)
if (!ip && decoder->pge)
decoder->state.type |= INTEL_PT_BRANCH;
decoder->state.cfe_type = decoder->fup_cfe_pkt.count;
- decoder->state.cfe_vector = decoder->fup_cfe_pkt.payload;
+ decoder->state.cfe_vector = (int)decoder->fup_cfe_pkt.payload;
decoder->state.evd_cnt = decoder->evd_cnt;
decoder->state.evd = decoder->evd;
decoder->evd_cnt = 0;
@@ -1906,7 +1906,7 @@ static inline void intel_pt_mtc_cyc_cnt_upd(struct intel_pt_decoder *decoder)

static void intel_pt_calc_tma(struct intel_pt_decoder *decoder)
{
- uint32_t ctc = decoder->packet.payload;
+ uint32_t ctc = (uint32_t)decoder->packet.payload;
uint32_t fc = decoder->packet.count;
uint32_t ctc_rem = ctc & decoder->ctc_rem_mask;

@@ -1943,7 +1943,7 @@ static void intel_pt_calc_mtc_timestamp(struct intel_pt_decoder *decoder)
if (!decoder->have_tma)
return;

- mtc = decoder->packet.payload;
+ mtc = (uint32_t)decoder->packet.payload;

if (decoder->mtc_shift > 8 && decoder->fixup_last_mtc) {
decoder->fixup_last_mtc = false;
@@ -2044,7 +2044,7 @@ static void intel_pt_bbp(struct intel_pt_decoder *decoder)
memset(decoder->state.items.mask, 0, sizeof(decoder->state.items.mask));
decoder->state.items.is_32_bit = false;
}
- decoder->blk_type = decoder->packet.payload;
+ decoder->blk_type = (enum intel_pt_blk_type)decoder->packet.payload;
decoder->blk_type_pos = intel_pt_blk_type_pos(decoder->blk_type);
if (decoder->blk_type == INTEL_PT_GP_REGS)
decoder->state.items.is_32_bit = decoder->packet.count;
@@ -2488,12 +2488,12 @@ static uint64_t intel_pt_calc_expected_tsc(struct intel_pt_decoder *decoder,
static uint64_t intel_pt_expected_tsc(struct intel_pt_decoder *decoder,
struct intel_pt_vm_tsc_info *data)
{
- uint32_t ctc = data->tma_packet.payload;
+ uint32_t ctc = (uint32_t)data->tma_packet.payload;
uint32_t fc = data->tma_packet.count;

return intel_pt_calc_expected_tsc(decoder, ctc, fc,
decoder->ctc_timestamp,
- data->ctc_delta, data->last_ctc);
+ data->ctc_delta, (uint32_t)data->last_ctc);
}

static void intel_pt_translate_vm_tsc(struct intel_pt_decoder *decoder,
@@ -2889,7 +2889,7 @@ static int intel_pt_vm_time_correlation(struct intel_pt_decoder *decoder)
break;

case INTEL_PT_BBP:
- decoder->blk_type = decoder->packet.payload;
+ decoder->blk_type = (enum intel_pt_blk_type)decoder->packet.payload;
break;

case INTEL_PT_BIP:
@@ -3825,7 +3825,7 @@ static int intel_pt_part_psb(struct intel_pt_decoder *decoder)
if (i > decoder->len)
continue;
if (!memcmp(end - i, INTEL_PT_PSB_STR, i))
- return i;
+ return (int)i;
}
return 0;
}
@@ -3839,7 +3839,7 @@ static int intel_pt_rest_psb(struct intel_pt_decoder *decoder, int part_psb)
memcmp(decoder->buf, psb + part_psb, rest_psb))
return 0;

- return rest_psb;
+ return (int)rest_psb;
}

static int intel_pt_get_split_psb(struct intel_pt_decoder *decoder,
@@ -3898,7 +3898,7 @@ static int intel_pt_scan_for_psb(struct intel_pt_decoder *decoder)
continue;
}

- decoder->pkt_step = next - decoder->buf;
+ decoder->pkt_step = (int)(next - decoder->buf);
return intel_pt_get_next_packet(decoder);
}
}
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c
index 8fabddc1c0da..03e34afb69a3 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c
@@ -193,7 +193,7 @@ int intel_pt_get_insn(const unsigned char *buf, size_t len, int x86_64,
struct insn insn;
int ret;

- ret = insn_decode(&insn, buf, len,
+ ret = insn_decode(&insn, buf, (int)len,
x86_64 ? INSN_MODE_64 : INSN_MODE_32);
if (ret < 0 || insn.length > len)
return -1;
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-log.c b/tools/perf/util/intel-pt-decoder/intel-pt-log.c
index ef55d6232cf0..324692a45d42 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-log.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-log.c
@@ -232,7 +232,7 @@ void __intel_pt_log_insn(struct intel_pt_insn *intel_pt_insn, uint64_t ip)

if (len > INTEL_PT_INSN_BUF_SZ)
len = INTEL_PT_INSN_BUF_SZ;
- intel_pt_print_data(intel_pt_insn->buf, len, ip, 8);
+ intel_pt_print_data(intel_pt_insn->buf, (int)len, ip, 8);
if (intel_pt_insn_desc(intel_pt_insn, desc, INTEL_PT_INSN_DESC_MAX) > 0)
fprintf(f, "%s\n", desc);
else
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
index 94fb16cf9e0c..8f2d7aab9ca4 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
@@ -713,7 +713,7 @@ int intel_pt_pkt_desc(const struct intel_pt_pkt *packet, char *buf,
if (ret < 0)
return ret;
blen -= ret;
- return buf_len - blen;
+ return (int)(buf_len - blen);
}
case INTEL_PT_TIP_PGD:
case INTEL_PT_TIP_PGE:
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index 4e8a9b172fbc..037ccedf5d89 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -557,7 +557,7 @@ static int intel_pt_config_div(const char *var, const char *value, void *data)
if (!strcmp(var, "intel-pt.cache-divisor")) {
val = strtol(value, NULL, 0);
if (val > 0 && val <= INT_MAX)
- *d = val;
+ *d = (int)val;
}

return 0;
@@ -589,7 +589,7 @@ static unsigned int intel_pt_cache_size(struct dso *dso,
return 10;
if (size > (1 << 21))
return 21;
- return 32 - __builtin_clz(size);
+ return 32 - __builtin_clz((unsigned int)size);
}

static struct auxtrace_cache *intel_pt_cache(struct dso *dso,
@@ -635,7 +635,7 @@ static int intel_pt_cache_add(struct dso *dso, struct machine *machine,
e->rel = intel_pt_insn->rel;
memcpy(e->insn, intel_pt_insn->buf, INTEL_PT_INSN_BUF_SZ);

- err = auxtrace_cache__add(c, offset, &e->entry);
+ err = auxtrace_cache__add(c, (u32)offset, &e->entry);
if (err)
auxtrace_cache__free_entry(c, e);

@@ -650,7 +650,7 @@ intel_pt_cache_lookup(struct dso *dso, struct machine *machine, u64 offset)
if (!c)
return NULL;

- return auxtrace_cache__lookup(dso__auxtrace_cache(dso), offset);
+ return auxtrace_cache__lookup(dso__auxtrace_cache(dso), (u32)offset);
}

static void intel_pt_cache_invalidate(struct dso *dso, struct machine *machine,
@@ -661,7 +661,7 @@ static void intel_pt_cache_invalidate(struct dso *dso, struct machine *machine,
if (!c)
return;

- auxtrace_cache__remove(dso__auxtrace_cache(dso), offset);
+ auxtrace_cache__remove(dso__auxtrace_cache(dso), (u32)offset);
}

static inline bool intel_pt_guest_kernel_ip(uint64_t ip)
@@ -1101,7 +1101,7 @@ static unsigned int intel_pt_mtc_period(struct intel_pt *pt)

evlist__for_each_entry(pt->session->evlist, evsel) {
if (intel_pt_get_config(pt, &evsel->core.attr, &config))
- return (config & pt->mtc_freq_bits) >> shift;
+ return (unsigned int)((config & pt->mtc_freq_bits) >> shift);
}
return 0;
}
@@ -2424,7 +2424,7 @@ static int intel_pt_synth_pebs_sample(struct intel_pt_queue *ptq)
struct intel_pt_pebs_event *pe;
struct intel_pt *pt = ptq->pt;
int err = -EINVAL;
- int hw_id;
+ size_t hw_id;

if (!items->has_applicable_counters || !items->applicable_counters) {
if (!pt->single_pebs)
@@ -2435,9 +2435,10 @@ static int intel_pt_synth_pebs_sample(struct intel_pt_queue *ptq)
for_each_set_bit(hw_id, (unsigned long *)&items->applicable_counters, INTEL_PT_MAX_PEBS) {
pe = &ptq->pebs[hw_id];
if (!pe->evsel) {
- if (!pt->single_pebs)
- pr_err("PEBS-via-PT record with no matching event, hw_id %d\n",
+ if (!pt->single_pebs) {
+ pr_err("PEBS-via-PT record with no matching event, hw_id %zu\n",
hw_id);
+ }
return intel_pt_synth_single_pebs_sample(ptq);
}
err = intel_pt_do_synth_pebs_sample(ptq, pe->evsel, pe->id);
@@ -3272,7 +3273,7 @@ static int intel_pt_process_switch(struct intel_pt *pt,
if (evsel != pt->switch_evsel)
return 0;

- tid = evsel__intval(evsel, sample, "next_pid");
+ tid = (pid_t)evsel__intval(evsel, sample, "next_pid");
cpu = sample->cpu;

intel_pt_log("sched_switch: cpu %d tid %d time %"PRIu64" tsc %#"PRIx64"\n",
@@ -4258,14 +4259,14 @@ int intel_pt_process_auxtrace_info(union perf_event *event,
pt->session = session;
pt->machine = &session->machines.host; /* No kvm support */
pt->auxtrace_type = auxtrace_info->type;
- pt->pmu_type = auxtrace_info->priv[INTEL_PT_PMU_TYPE];
+ pt->pmu_type = (u32)auxtrace_info->priv[INTEL_PT_PMU_TYPE];
pt->tc.time_shift = auxtrace_info->priv[INTEL_PT_TIME_SHIFT];
- pt->tc.time_mult = auxtrace_info->priv[INTEL_PT_TIME_MULT];
+ pt->tc.time_mult = (u32)auxtrace_info->priv[INTEL_PT_TIME_MULT];
pt->tc.time_zero = auxtrace_info->priv[INTEL_PT_TIME_ZERO];
pt->cap_user_time_zero = auxtrace_info->priv[INTEL_PT_CAP_USER_TIME_ZERO];
pt->tsc_bit = auxtrace_info->priv[INTEL_PT_TSC_BIT];
pt->noretcomp_bit = auxtrace_info->priv[INTEL_PT_NORETCOMP_BIT];
- pt->have_sched_switch = auxtrace_info->priv[INTEL_PT_HAVE_SCHED_SWITCH];
+ pt->have_sched_switch = (int)auxtrace_info->priv[INTEL_PT_HAVE_SCHED_SWITCH];
pt->snapshot_mode = auxtrace_info->priv[INTEL_PT_SNAPSHOT_MODE];
pt->per_cpu_mmaps = auxtrace_info->priv[INTEL_PT_PER_CPU_MMAPS];
intel_pt_print_info(&auxtrace_info->priv[0], INTEL_PT_PMU_TYPE,
@@ -4274,8 +4275,8 @@ int intel_pt_process_auxtrace_info(union perf_event *event,
if (intel_pt_has(auxtrace_info, INTEL_PT_CYC_BIT)) {
pt->mtc_bit = auxtrace_info->priv[INTEL_PT_MTC_BIT];
pt->mtc_freq_bits = auxtrace_info->priv[INTEL_PT_MTC_FREQ_BITS];
- pt->tsc_ctc_ratio_n = auxtrace_info->priv[INTEL_PT_TSC_CTC_N];
- pt->tsc_ctc_ratio_d = auxtrace_info->priv[INTEL_PT_TSC_CTC_D];
+ pt->tsc_ctc_ratio_n = (u32)auxtrace_info->priv[INTEL_PT_TSC_CTC_N];
+ pt->tsc_ctc_ratio_d = (u32)auxtrace_info->priv[INTEL_PT_TSC_CTC_D];
pt->cyc_bit = auxtrace_info->priv[INTEL_PT_CYC_BIT];
intel_pt_print_info(&auxtrace_info->priv[0], INTEL_PT_MTC_BIT,
INTEL_PT_CYC_BIT);
@@ -4283,7 +4284,7 @@ int intel_pt_process_auxtrace_info(union perf_event *event,

if (intel_pt_has(auxtrace_info, INTEL_PT_MAX_NONTURBO_RATIO)) {
pt->max_non_turbo_ratio =
- auxtrace_info->priv[INTEL_PT_MAX_NONTURBO_RATIO];
+ (unsigned int)auxtrace_info->priv[INTEL_PT_MAX_NONTURBO_RATIO];
intel_pt_print_info(&auxtrace_info->priv[0],
INTEL_PT_MAX_NONTURBO_RATIO,
INTEL_PT_MAX_NONTURBO_RATIO);
@@ -4418,12 +4419,11 @@ int intel_pt_process_auxtrace_info(union perf_event *event,
u64 tsc_freq = intel_pt_ns_to_ticks(pt, 1000000000);

if (!pt->max_non_turbo_ratio)
- pt->max_non_turbo_ratio =
- (tsc_freq + 50000000) / 100000000;
+ pt->max_non_turbo_ratio = (unsigned int)((tsc_freq + 50000000) / 100000000);
intel_pt_log("TSC frequency %"PRIu64"\n", tsc_freq);
intel_pt_log("Maximum non-turbo ratio %u\n",
pt->max_non_turbo_ratio);
- pt->cbr2khz = tsc_freq / pt->max_non_turbo_ratio / 1000;
+ pt->cbr2khz = (unsigned int)(tsc_freq / pt->max_non_turbo_ratio / 1000);
}

err = intel_pt_setup_time_ranges(pt, session->itrace_synth_opts);
diff --git a/tools/perf/util/intel-tpebs.c b/tools/perf/util/intel-tpebs.c
index 2c421b475b3b..27916368a0c7 100644
--- a/tools/perf/util/intel-tpebs.c
+++ b/tools/perf/util/intel-tpebs.c
@@ -235,7 +235,7 @@ int tpebs_start(struct evlist *evsel_list)
continue;

pr_debug("tpebs: Retire_latency of event %s is required\n", evsel->name);
- for (i = strlen(evsel->name) - 1; i > 0; i--) {
+ for (i = (int)strlen(evsel->name) - 1; i > 0; i--) {
if (evsel->name[i] == 'R')
break;
}
@@ -293,7 +293,7 @@ int tpebs_start(struct evlist *evsel_list)
}
/* Wait for perf record initialization.*/
len = strlen(EVLIST_CTL_CMD_ENABLE_TAG);
- ret = write(control_fd[1], EVLIST_CTL_CMD_ENABLE_TAG, len);
+ ret = (int)write(control_fd[1], EVLIST_CTL_CMD_ENABLE_TAG, len);
if (ret != len) {
pr_err("perf record control write control message failed\n");
goto out;
@@ -319,7 +319,7 @@ int tpebs_start(struct evlist *evsel_list)
goto out;
}

- ret = read(ack_fd[0], ack_buf, sizeof(ack_buf));
+ ret = (int)read(ack_fd[0], ack_buf, sizeof(ack_buf));
if (ret > 0)
ret = strcmp(ack_buf, EVLIST_CTL_CMD_ACK_TAG);
else {
--
2.49.0.504.g3bcea36a83-goog