LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 09-17-2010, 04:28 PM   #1
summer_intern
LQ Newbie
 
Registered: Sep 2010
Posts: 1

Rep: Reputation: 0
How to find what task is running on a particular cpu core ?


Hello ,

I am using Kernel 2.6.35.4 on an Intel Core2Duo based system.
1) I have to find on which core a particular task is running on .
OR
2) I have to just log whenever my task is scheduled on any of the cores with the cpu core number & timestamp info.
I am ready to modify the kernel to do printk or some logging .
I guess there used to be 2 fields called 'processor' and 'last_processor' in task_struct in older kernels which probably had this information .

So what do I do to find out on which core a particular task is running on ?

Or ,

Are there any utilities that are simple-to-use and can display the tasks that are running on each of the cores , including the cpu core info ? top , mpstat etc do not tell you on which cpu core a task is running on .
 
Old 09-17-2010, 10:18 PM   #2
rayfordj
Member
 
Registered: Feb 2008
Location: Texas
Distribution: Fedora, RHEL, CentOS
Posts: 475

Rep: Reputation: 73
top will, not by default, but if you add the field according to the man page on my system.

Code:
       j: P  --  Last used CPU (SMP)
          A number representing the last used processor.  In a true SMP  envi-
          ronment  this  will likely change frequently since the kernel inten-
          tionally uses weak affinity.  Also, the very act of running top  may
          break  this  weak  affinity  and cause more processes to change CPUs
          more often (because of the extra demand for cpu time).
Code:
user@system ~]$ top
f
j
<enter>
 
Old 09-17-2010, 10:29 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,497

Rep: Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077
Simplest is to use /proc/<pid>/stat (which is where top is getting it from in all likelihood).
But as per above, this is "last processor" dispatched on. Given the way the scheduler attempts to keep tasks on the same processor, this should normally suffice.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get process running CPU core and the utilisation on that core... chamila1986 Programming 5 04-28-2010 06:00 PM
How to find what core CPU is present? linuxunix Linux - Newbie 2 03-26-2010 04:18 AM
how to find on which cpu core linux kernel tasks are running zzfcpit0120 Linux - Kernel 1 10-16-2009 06:05 AM
userland: how to find the cpu currently running at aasa0001 Linux - Newbie 1 02-11-2009 05:14 AM
Strange noise while CPU is idle on Dell C600 running Fedora Core 1 theoldman Linux - Newbie 1 01-23-2004 07:47 PM


All times are GMT -5. The time now is 10:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration