LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 10-16-2009, 04:40 AM   #1
zzfcpit0120
LQ Newbie
 
Registered: Oct 2009
Posts: 1

Rep: Reputation: 0
how to find on which cpu core linux kernel tasks are running


On one multiple cpu cores(SMP) system,
(1) how to find on which core the linux kernel tasks (for example, the schduler, etc., not the userspace application tasks) are running.
(2) how to force the Linux kernel tasks run on one specific cpu core?
 
Old 10-16-2009, 05:05 AM   #2
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 988
Blog Entries: 4

Rep: Reputation: 254Reputation: 254Reputation: 254
CPU Affinity - Soft vs Hard

Greetingz!

There are two ways to do this, however you have to remember that both cores are each treated as their own CPU. So this will apply if you have one Dual-Core CPU, or two separate CPUs.

Prerequisites:
You have to at least have glibc 2.3.1 and a minimum of kernel 2.5.8-pre3. Plus, that kernel has to be compiled to be SMP-aware.
To find out, try typing "uname -a" and if "-smp" is listed, you're off to a great start. If not, look for the file /proc/config.gz or /proc/.config
and "cat /proc/<filename> | grep -i smp" to see if it's set.
Barring that, just cross your fingers, most newer Linux distributions come with SMP-aware kernels, so if you're running Red Hat 9 or higher, you're good.

Soft Affinity
Most schedulers in the kernel will try to move processes around between CPUs to try and keep their utilization even. This is to prevent any single CPU from becoming overloaded.
Most schedulers in 2.5 and 2.6 kernels have great "natural" affinity. The 2.4 scheduler had a pretty bad implementation, and would "ping-pong" processes around unnecessarily, almost to the point of hilarity.

Hard Affinity
If you're running a Red Hat based Linux distribution (like CentOS, for example), you'll have to make sure you have the "taskset" command.
With that, you can set the masks you need so you can bind process IDs to one or more CPUs.

It's fairly easy to use, for example, to bind process ID 12345 to the first CPU, just type the following;

taskset 0x00000001 -p 12345

Or if you don't need to impress the boss, just use the simpler form;

taskset -c 1 -p 12345

You can also bind a process to more than one CPU;

taskset -c 1,2 -p 12345

Hope this helps!
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
userland: how to find the cpu currently running at aasa0001 Linux - Newbie 1 02-11-2009 04:14 AM
On which core is Linux kernel running on Dual-core machine? kushalkoolwal Linux - Hardware 22 01-05-2009 02:33 PM
CPU Intensive Tasks Drown My Internet. IamI Slackware 1 09-09-2005 12:36 AM
Power failure during cpu intensive tasks catalyst4000 Linux - Hardware 5 01-11-2005 09:58 PM
Strange noise while CPU is idle on Dell C600 running Fedora Core 1 theoldman Linux - Newbie 1 01-23-2004 06:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 04:17 PM.

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
Open Source Consulting | Domain Registration