mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Ahern <david.ahern@oracle.com>
To: acme@kernel.org
Cc: linux-kernel@vger.kernel.org,
	David Ahern <david.ahern@oracle.com>,
	Ingo Molnar <mingo@kernel.org>
Subject: [PATCH] perf sched: Fix data type for pid
Date: Fri, 10 Apr 2015 11:55:04 -0400	[thread overview]
Message-ID: <1428681304-40224-1-git-send-email-david.ahern@oracle.com> (raw)

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


                 reply	other threads:[~2015-04-10 15:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1428681304-40224-1-git-send-email-david.ahern@oracle.com \
    --to=david.ahern@oracle.com \
    --cc=acme@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®