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 - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-04-2013, 01:41 AM   #1
bilbi
LQ Newbie
 
Registered: Jun 2013
Posts: 4

Rep: Reputation: Disabled
where does kernel execute on smp


hi

i have a question the that i could not find an answer anywhere:
1) where does the kernel main loop execute on smp machine - i mean NOT the kernel threads or system calls.
2) how many instances of the scheduler are executing? is there an instance on every CPU once timer interrupt has expired?


thanks in advance
 
Old 06-04-2013, 03:16 PM   #2
bilbi
LQ Newbie
 
Registered: Jun 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
Smile

Up




:-D
 
Old 06-04-2013, 05:59 PM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Your attempt to bump this thread has had just the opposite result by removing it from the "Zero Reply Threads" list. Threads on that list get some automatic bumps and would also be seen by those who check that zero-reply list periodically.
 
Old 06-04-2013, 07:33 PM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by bilbi View Post
hi

i have a question the that i could not find an answer anywhere:
1) where does the kernel main loop execute on smp machine - i mean NOT the kernel threads or system calls.
Both
Quote:
2) how many instances of the scheduler are executing? is there an instance on every CPU once timer interrupt has expired?
Depends on your definition of "instance". One per processor (when idle). Normally though, all processors will go idle when there is nothing to do (and there is one idle process for each CPU). There will only be one processor examining the run queue at a time (atomic operators), so scheduling is handled appropriately with all other processors waiting.

NOTE: This does not mean there is duplicate code - just that two (or more) processors will execute the same loop. What happens is that the "loop" gets copied into local cache, and the CPU runs it out of cache.
Quote:
thanks in advance
 
Old 06-05-2013, 08:00 AM   #5
Saptarshi4031
LQ Newbie
 
Registered: May 2010
Posts: 8

Rep: Reputation: 0
Hi

in an smp system, the kernel code is shared in memory by all the processors. So only one cpu executes the kernel code in a
given instant of time. (This is an example of the big kernel lock). So accordingly, the only one cpu executes the scheduler code.
Now each cpu may have its own set of run queues of tasks. This the kernel identifies which cpu owns which queue by the CPUID instruction
supported by the hardware.

Hope this helps.
 
Old 06-05-2013, 08:36 PM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by Saptarshi4031 View Post
Hi

in an smp system, the kernel code is shared in memory by all the processors. So only one cpu executes the kernel code in a
given instant of time. (This is an example of the big kernel lock). So accordingly, the only one cpu executes the scheduler code.
Now each cpu may have its own set of run queues of tasks. This the kernel identifies which cpu owns which queue by the CPUID instruction
supported by the hardware.

Hope this helps.
That was true in version 2.2, but by the time 2.6 has rolled out the big kernel lock has been removed.

Many parts of the kernel are executed in parallel. Device drivers, kernel tasks, interrupt service... even process scheduling.

There is no "big kernel lock" anymore, instead there is a lot of small locks on specific data structures. The scheduler has such a lock - the only lock is taken while removing a process from the queue and dispatching to a processor.

There are also multiple run queues - one per processor to avoid/reduce locking overhead.

http://www.ibm.com/developerworks/library/l-scheduler/

Last edited by jpollard; 06-05-2013 at 08:39 PM.
 
Old 06-08-2013, 03:59 PM   #7
bilbi
LQ Newbie
 
Registered: Jun 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks for your reply
But still- where for example does the pgae cache execute or vfs
Or for clarity: where do fundamental kernel tasks are executed?
I mean tasks which are not related to any user( not systems calls) and is there one main loop in the kernel?
Thanks again
 
Old 06-09-2013, 04:59 AM   #8
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
The only "main loop" is the idle task.

All processors execute it when there is nothing else to do.

In an SMP, all processors execute everything as needed. Those sections that require serial access will be protected by either queues (a processor enters the task into a list, then goes to do something else while another processor executes tasks on the list, when the list is empty it goes to do something else) or locks (a processor waits until it acquires the lock, then performs the action and releases the lock). Interrupts are taken by an idle processor. If all processors a busy, one is interrupted (as long as it isn't already in a non-interruptible section).

Anything much more detailed than that would require a book/chapter on kernel design.
 
Old 06-09-2013, 08:21 AM   #9
bilbi
LQ Newbie
 
Registered: Jun 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
jpollard- what do you mean "In an SMP, all processors execute everything as needed" - what in the kernel is responsible for assigning tasks (not system calls) to processors? (i mean the routine tasks)

thanks
 
Old 06-09-2013, 11:58 AM   #10
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
The scheduler. Every processor executes the scheduler as part of the idle task. If anything is in a queue then the processor will switch to that task. When the task is completed it goes back to the idle/scheduler for the next task.
 
  


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
Upgrading a slackware 12.1 kernel (2.6.24.5-smp) to a 13 kernel (2.6.29.6-smp) f.y Linux - Kernel 3 12-09-2009 01:15 PM
Non-SMP kernel modules for SMP kernel: Best practice? gargamel Slackware 9 12-29-2008 01:13 PM
Hyperthread server goes to kernel panic with SMP kernic, boots ok with non SMP kernel abefroman Linux - Kernel 1 09-15-2006 05:43 PM
Any reason to keep a non-smp kernel installed on a smp FC3 machine? jim-j Fedora 2 03-12-2006 07:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:58 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
Open Source Consulting | Domain Registration