pfmon with kernel 2.5.35?
Bonjour Jean-Francois,
Quoted 7 lines · lemerrjf
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
Quoted 8 lines
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.
Signature · 1 line
-Stephane
pfmon/pfmon_util.c +13 -5
@@ -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 ;