u32 state = perf_sample__intval(sample, "state");
u32 cpu_id = perf_sample__intval(sample, "cpu_id");
+ if (cpu_id >= MAX_CPUS) {
+ pr_debug("Out-of-bounds cpu_id %u\n", cpu_id);
+ return -1;
+ }
if (state == (u32)PWR_EVENT_EXIT)
c_state_end(tchart, cpu_id, sample->time);
else
u32 state = perf_sample__intval(sample, "state");
u32 cpu_id = perf_sample__intval(sample, "cpu_id");
+ if (cpu_id >= MAX_CPUS) {
+ pr_debug("Out-of-bounds cpu_id %u\n", cpu_id);
+ return -1;
+ }
p_state_change(tchart, cpu_id, sample->time, state);
return 0;
}
int waker = perf_sample__intval(sample, "common_pid");
int wakee = perf_sample__intval(sample, "pid");
+ if (sample->cpu >= MAX_CPUS) {
+ pr_debug("Out-of-bounds cpu %u\n", sample->cpu);
+ return -1;
+ }
sched_wakeup(tchart, sample->cpu, sample->time, waker, wakee, flags, backtrace);
return 0;
}
int next_pid = perf_sample__intval(sample, "next_pid");
u64 prev_state = perf_sample__intval(sample, "prev_state");
+ if (sample->cpu >= MAX_CPUS) {
+ pr_debug("Out-of-bounds cpu %u\n", sample->cpu);
+ return -1;
+ }
sched_switch(tchart, sample->cpu, sample->time, prev_pid, next_pid,
prev_state, backtrace);
return 0;
u64 cpu_id = perf_sample__intval(sample, "cpu_id");
u64 value = perf_sample__intval(sample, "value");
+ if (cpu_id >= MAX_CPUS) {
+ pr_debug("Out-of-bounds cpu_id %llu\n", (unsigned long long)cpu_id);
+ return -1;
+ }
c_state_start(cpu_id, sample->time, value);
return 0;
}
struct perf_sample *sample,
const char *backtrace __maybe_unused)
{
+ if (sample->cpu >= MAX_CPUS) {
+ pr_debug("Out-of-bounds cpu %u\n", sample->cpu);
+ return -1;
+ }
c_state_end(tchart, sample->cpu, sample->time);
return 0;
}
u64 cpu_id = perf_sample__intval(sample, "cpu_id");
u64 value = perf_sample__intval(sample, "value");
+ if (cpu_id >= MAX_CPUS) {
+ pr_debug("Out-of-bounds cpu_id %llu\n", (unsigned long long)cpu_id);
+ return -1;
+ }
p_state_change(tchart, cpu_id, sample->time, value);
return 0;
}
*/
static void end_sample_processing(struct timechart *tchart)
{
- u64 cpu;
- struct power_event *pwr;
+ for (u64 cpu = 0; cpu < tchart->numcpus; cpu++) {
+ struct power_event *pwr;
- for (cpu = 0; cpu <= tchart->numcpus; cpu++) {
/* C state */
#if 0
pwr = zalloc(sizeof(*pwr));
switch (feat) {
case HEADER_NRCPUS:
tchart->numcpus = ph->env.nr_cpus_avail;
+ if (tchart->numcpus > MAX_CPUS)
+ tchart->numcpus = MAX_CPUS;
break;
case HEADER_CPU_TOPOLOGY: