History

perf: Pass last sampling period to perf_sample_data_init()

We always need to pass the last sample period to perf_sample_data_init(), otherwise the event distribution will be wrong. Thus, modifiyng the function interface with the required period as argument. So basically a pattern like this: perf_sample_data_init(&data, ~0ULL); data.period = event->hw.last_period; will now be like that: perf_sample_data_init(&data, ~0ULL, event->hw.last_period); Avoids unininitialized data.period and simplifies code.

Robert Richter committed 14 years ago

Commit fd0d0001 parent c75841a15 files · +25 −43Browse files

Showing the changes to kernel (1 of 15 files). Show all

Unified · Split

kernel/events/core.c+4−5
@@ -4957,7 +4957,7 @@ void __perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr) · 4956 unmodified lines
49574957 if (rctx < 0)
49584958 return;
49594959
4960− perf_sample_data_init(&data, addr);
4960+ perf_sample_data_init(&data, addr, 0);
49614961
49624962 do_perf_sw_event(PERF_TYPE_SOFTWARE, event_id, nr, &data, regs);
49634963
@@ -5215,7 +5215,7 @@ void perf_tp_event(u64 addr, u64 count, void *record, int entry_size, · 251 unmodified lines
52155215 .data = record,
52165216 };
52175217
5218− perf_sample_data_init(&data, addr);
5218+ perf_sample_data_init(&data, addr, 0);
52195219 data.raw = &raw;
52205220
52215221 hlist_for_each_entry_rcu(event, node, head, hlist_entry) {
@@ -5318,7 +5318,7 @@ void perf_bp_event(struct perf_event *bp, void *data) · 96 unmodified lines
53185318 struct perf_sample_data sample;
53195319 struct pt_regs *regs = data;
53205320
5321− perf_sample_data_init(&sample, bp->attr.bp_addr);
5321+ perf_sample_data_init(&sample, bp->attr.bp_addr, 0);
53225322
53235323 if (!bp->hw.state && !perf_exclude_event(bp, regs))
53245324 perf_swevent_event(bp, 1, &sample, regs);
@@ -5344,8 +5344,7 @@ static enum hrtimer_restart perf_swevent_hrtimer(struct hrtimer *hrtimer) · 19 unmodified lines
53445344
53455345 event->pmu->read(event);
53465346
5347− perf_sample_data_init(&data, 0);
5348− data.period = event->hw.last_period;
5347+ perf_sample_data_init(&data, 0, event->hw.last_period);
53495348 regs = get_irq_regs();
53505349
53515350 if (regs && !perf_exclude_event(event, regs)) {