[PATCH] perf sched: Fix data type for pid

From: David Ahern
Date: Fri Apr 10 2015 - 11:55:25 EST


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 <david.ahern@xxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
---
tools/perf/builtin-sched.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index f31353bf8453..8e2d5c9809c4 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -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);
}
}
--
2.3.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/