mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] perf sched: Fix data type for pid
@ 2015-04-10 15:55 David Ahern
  0 siblings, 0 replies; only message in thread
From: David Ahern @ 2015-04-10 15:55 UTC (permalink / raw)
  To: acme; +Cc: linux-kernel, David Ahern, Ingo Molnar

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@oracle.com>
Cc: Ingo Molnar <mingo@kernel.org>
---
 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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-04-10 15:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-10 15:55 [PATCH] perf sched: Fix data type for pid David Ahern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®