All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephane Eranian <eranian@frankl.hpl.hp.com>
To: linux-ia64@vger.kernel.org
Subject: [Linux-ia64] Re: pfmon with kernel 2.5.35?
Date: Fri, 20 Sep 2002 17:03:08 +0000	[thread overview]
Message-ID: <marc-linux-ia64-105590701906044@msgid-missing> (raw)

[-- Attachment #1: Type: text/plain, Size: 1123 bytes --]

Bonjour Jean-Francois,


On Fri, Sep 20, 2002 at 12:30:18PM +0200, lemerrjf wrote:
> I have tried pfmon on a Tiger machine with 4 CPUs.
> it works pretty well on a kernel 2.4.18
> 
> However on a kernel 2.5.35, I obtain, with the command
> 
> pfmon --system-wide
> 
> Thread does not run on correct CPU: 0 instead of 1
> Thread does not run on correct CPU: 0 instead of 2
> Thread does not run on correct CPU: 0 instead of 3
> 
> I observe the same problem with other kernels adding the
> "multiple run queue" functionnalities.
> 
> Have you observed the same problem?

Obviously this has not been tested with 2.5.x. Keep in mind
that this is a development (unstable) kernel. 

The problem is not in the kernel but in pfmon. The routine
that retrieves the current CPU is bogus. From 2.4.x to 2.5.x
the content of /proc/pid/stat has changed and this exposed
a bug in pfmon/pfmon_util.c:find_cpu(). The thread is indeed
running on the right CPU. 

You can apply the attached patch to pfmon-1.1 to fix 
the problem with pfmon. Note that this fix works for both
2.4.x and 2.5.x

Thanks for finding this problem.

-- 
-Stephane

[-- Attachment #2: pfmon-find-cpu.diff --]
[-- Type: text/plain, Size: 720 bytes --]

--- pfmon-1.1/pfmon/pfmon_util.c	Fri Jun 14 16:41:20 2002
+++ pfmon-1.1a/pfmon/pfmon_util.c	Fri Sep 20 09:51:02 2002
@@ -566,8 +566,10 @@
 int
 find_cpu(pid_t pid)
 {
-	FILE *fp;	
-	char *p;
+#define TASK_CPU_POSITION	39 /* position of the task cpu in /proc/pid/stat */
+	FILE *fp;
+	int count = TASK_CPU_POSITION;
+	char *p, *pp = NULL;
 	char fn[32];
 	char buffer[1024];
 
@@ -581,13 +583,19 @@
 
 	/* remove \n */
 	p[strlen(p)] = '\0';
+	p--;
 
-	p = strrchr(buffer, ' ');
-	if (p == NULL) goto error;
+	while (count-- && p) {
+		pp = ++p;
+		p = strchr(p, ' ');
+	}
+	if (count>-1) goto error;
+
+	if (p) *p = '\0';
 
 	fclose(fp);
 
-	return atoi(p);
+	return atoi(pp);
 error:
 	if (fp) fclose(fp);
 	return -1;

                 reply	other threads:[~2002-09-20 17:03 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=marc-linux-ia64-105590701906044@msgid-missing \
    --to=eranian@frankl.hpl.hp.com \
    --cc=linux-ia64@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.