perf sched: Fix data type for pid
PATCH 1/1 perf sched: Fix data type for pid
pid from perf samples is a u32. Make perf-sched consistent in data types for pid and nr/nr_tasks which are based on pid.
Signed-off-by David Ahern <[email protected]>
Cc Ingo Molnar <[email protected]>
--- tools/perf/builtin-sched.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
tools/perf/builtin-sched.c +13 -10
@@ -39,8 +39,8 @@struct sched_atom ;struct task_desc { -unsigned long nr; -unsigned long pid; +u32 nr; +u32 pid;char comm[COMM_LEN ];unsigned long nr_events;
@@ -129,7 +129,7 @@ struct trace_sched_handler {struct perf_sched {struct perf_tool tool;const char *sort_order; -unsigned long nr_tasks; +u32 nr_tasks;struct task_desc **pid_to_task;struct task_desc **tasks;const struct trace_sched_handler *tp_handler;
@@ -379,20 +379,23 @@ static void add_sched_event_sleep(struct perf_sched *sched, struct task_desc *ta }static struct task_desc *register_pid (struct perf_sched *sched, -unsigned long pid,const char *comm) +u32 pid,const char *comm) {struct task_desc *task; -static int pid_max; +static u32 pid_max; +int val;if (sched->pid_to_task ==NULL ) { -if (sysctl__read_int ("kernel/pid_max" , &pid_max) <0 ) +if (sysctl__read_int ("kernel/pid_max" , &val) <0 ) pid_max =MAX_PID ; +else + pid_max = (u32 ) val;BUG_ON ((sched->pid_to_task =calloc (pid_max,sizeof (struct task_desc *))) ==NULL ); } -if (pid >= (unsigned long )pid_max) { +if (pid >= pid_max) {BUG_ON ((sched->pid_to_task =realloc (sched->pid_to_task, (pid +1 ) *sizeof (struct task_desc *))) ==NULL ); -while (pid >= (unsigned long )pid_max) +while (pid >= pid_max) sched->pid_to_task[pid_max++] =NULL ; }
@@ -418,7 +421,7 @@ static struct task_desc *register_pid(struct perf_sched *sched, sched->tasks[task->nr] = task;if (verbose) -printf ("registered task #%ld, PID %ld (%s)\n" , sched->nr_tasks, pid, comm); +printf ("registered task #%d, PID %d (%s)\n" , sched->nr_tasks, pid, comm);return task; }
@@ -431,7 +434,7 @@ static void print_task_traces(struct perf_sched *sched)for (i =0 ; i < sched->nr_tasks; i++) { task = sched->tasks[i]; -printf ("task %6ld (%20s:%10ld), nr_events: %ld\n" , +printf ("task %6d (%20s:%10d), nr_events: %ld\n" , task->nr, task->comm, task->pid, task->nr_events); } }
Signature · 1 line
2.3.0