LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   On which core is Linux kernel running on Dual-core machine? (https://www.linuxquestions.org/questions/linux-hardware-18/on-which-core-is-linux-kernel-running-on-dual-core-machine-693741/)

kushalkoolwal 12-29-2008 07:47 PM

On which core is Linux kernel running on Dual-core machine?
 
I am new to Dual-core world and I just got a AMD X2 64-bit Dual Core processor machine and have installed Debian Lenny (64-bit) on it with the SMP kernel (64-bit).

Now as I understand dual-core means there are two cores i.e. the OS see two cpus as correctly identified by:
Code:


debian-workstation:~# cat /proc/cpuinfo
processor      : 0
vendor_id      : AuthenticAMD
cpu family      : 15
model          : 107
model name      : AMD Athlon(tm) 64 X2 Dual Core Processor 5600+
stepping        : 2
cpu MHz        : 2000.000
cache size      : 512 KB
physical id    : 0
siblings        : 2
core id        : 0
cpu cores      : 2
apicid          : 0
initial apicid  : 0
............

Now my following question might sound little strange but I got curious:
Is there a way to know on which of the two cores is the Linux kernel running on? Does it run partially on both the cores or does it just runs on a single core? If it runs on a single core, then which core?

How can I determine this?

PatrickNew 12-29-2008 08:17 PM

As I understand it, the kernels run on both cores. I know that's how it works for multiprocessor machines, but I'm not sure about multicore.

Quakeboy02 12-29-2008 08:32 PM

Linux boots on the number one core, then shifts to multiprocessor mode at some point when it is ready. I believe that the number one core continues to allocate processes to all cores, but I could be wrong on that point.

kushalkoolwal 12-29-2008 08:36 PM

Quote:

Originally Posted by Quakeboy02 (Post 3391053)
Linux boots on the number one core, then shifts to multiprocessor mode at some point when it is ready. I believe that the number one core continues to allocate processes to all cores, but I could be wrong on that point.

Wonder if there is tool/utility to find that out just like there are so many for determining whether the kernel is a dual-core or not (proc/cpuinfo and top).

Edit: I just noticed that this is my 1000th post.....

IBall 12-30-2008 05:10 AM

The kernel would run on both cores (or as many cores as is available).
The kernel would also allocate threads from each application to an appropriate core.

I don't know which core would do the scheduling to allocate threads to a particular core. It may not even be a static thing.

To complicate things even further, there is a degree of hardware scheduling between the cores.

--Ian

syg00 12-30-2008 05:35 AM

Quote:

Originally Posted by IBall (Post 3391366)
The kernel would run on both cores (or as many cores as is available).

Do you have evidence to support this statement, or merely presuming a "SMP kernel" might (should ?) work this way ???.

I'm inclined to agree with Quakeboy02, but I haven't tracked through the code. Depends on what one means by "the kernel" of course - (some) kernel threads can run on any "engine". But then again, they can be bound to a specific "engine".
The (non-threaded) kernel itself ??? - mmmm. I'd be thinking just the one - Linux generally works that way to ensure things like cache flushes are minimized. Maybe one should peruse the code on a balmy New Years Eve rather than drinking and enjoying oneself.
.
.
Maybe.

johnsfine 12-30-2008 08:48 AM

Isn't the "system" time reported by top the answer to this question?

Run top. Press "1" if necessary to see the categories of time per core. Watch it while you run some ordinary tasks.

farslayer 12-30-2008 09:18 AM

all discussion on SMP and the Linux kernel I find are centered around the scheduler and threads or processes..
just tagging this thread so I can see what you all may find..

http://www.ibm.com/developerworks/library/l-linux-smp/
Quote:

SMP in the kernel
To understand how SMP is initialized for a given architecture, check out the smp.c or smpboot.c files within the kernel at ./linux/arch/<arch>/kernel/ (for most architectures and platforms).
http://www.ibm.com/developerworks/li...-linux-kernel/
http://www.ibm.com/developerworks/li...y/l-scheduler/



Interesting topic.

PTrenholme 12-30-2008 10:33 AM

If you like "geek" toys, install gkrelm (although, come to think of it, it's not the the Ubuntu repositories). It runs on most window managers (but "best" under GNOME) and, among other things, can show you a "5-second updated" chart of CPU usage by core.

<edit>
Oops! :eek: apt-get install gkrellm does get it.
</edit>

Brian1 12-30-2008 11:06 AM

gkrellm is a cool tool. Looks cool on the cpu usuage of a quad core and compiling a new kernel with the -j8 option with make. It is working all 4 processors when compiling.

Brian

salasi 12-30-2008 04:31 PM

If you have a non-smp kernel (which would be old, presumably), my experience is that it runs on Core 0 and Core 1 idles.

SMP kernels (anything recent should be SMP, except for oddball things that are specifically low-resource) split the load over the two (err, sometimes with a load of zero for one cores, if the load is low).

Note that ksysguard and Gnome system monitor can also do the trick of showing the load for the individual cores.

HackTidus 12-30-2008 05:52 PM

very interesting indeed, I asked that question to myself some time ago and I've learned some interesting stuff reading this...

Good work!

bastl 12-30-2008 06:41 PM

I think the process splitting is done by the pipelining system of the cores means, that software does not have any possibility to choose where to be executed.
So I think if the pipeline recognizes a call instruction then it gives that code until ret (iret) to the next free PU. So you can say that an interrupt (IRQ) is executed surely only on one PU. I can also imagine that a arithmetic work on the pipeline is pushed forward to a free PU and when the result is calculated then the other PU is at that point it needs that result.
Before I guess something wrong, you can download the datasheets for the AMD multicore CPU chips from here:
http://www.amd.com/us-en/Processors/..._15343,00.html

Quakeboy02 12-30-2008 08:00 PM

Here's an interesting article on interrupt scheduling in an SMP environment.

http://software.intel.com/en-us/arti...essor-affinity

salasi 01-03-2009 06:43 PM

Quote:

Originally Posted by bastl (Post 3392142)
I think the process splitting is done by the pipelining system of the cores means, that software does not have any possibility to choose where to be executed.

If this were true, you wouldn't be able to set affinity. And if the pipelining system were doing this, which part ensures that instructions work on the correct registers?


All times are GMT -5. The time now is 04:11 AM.