public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [Linux-ia64] Re: pfmon with kernel 2.5.35?
@ 2002-09-20 17:03 Stephane Eranian
  0 siblings, 0 replies; only message in thread
From: Stephane Eranian @ 2002-09-20 17:03 UTC (permalink / raw)
  To: linux-ia64

[-- 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;

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

only message in thread, other threads:[~2002-09-20 17:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-20 17:03 [Linux-ia64] Re: pfmon with kernel 2.5.35? Stephane Eranian

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