LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 04-25-2017, 10:50 AM   #1
tanklau
LQ Newbie
 
Registered: Apr 2017
Posts: 2

Rep: Reputation: Disabled
How to start Linux without kernel on one core


Hi everyone! I am just wondering if this is possible. I have a 4 processor machine running Ubuntu. Is it possible to start up the system with the Linux kernel running on 3 of the processors only leaving one completely off? Then on the empty core, is it possible to access it and run a simple program (like an assembly program)?
 
Old 04-25-2017, 12:40 PM   #2
linux4evr5581
Member
 
Registered: Sep 2016
Location: USA
Posts: 275

Rep: Reputation: Disabled
In the Windows world I think what you're trying to do would be done through the msconfig utility. But in Linux you may need to use a distro like Gentoo which has more advanced customizable options like makeopts, which allows you to set the number of threads a program should use.. You most likely can do this with any flavor of Linux though (I personally don't know how), but I hear Gentoo tends to make doing these types of things easier.
 
Old 04-25-2017, 12:42 PM   #3
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Something similar may be possibe with virtual machines but the concept looks impossible.
 
Old 04-25-2017, 04:55 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 tanklau View Post
Hi everyone! I am just wondering if this is possible. I have a 4 processor machine running Ubuntu. Is it possible to start up the system with the Linux kernel running on 3 of the processors only leaving one completely off? Then on the empty core, is it possible to access it and run a simple program (like an assembly program)?
Perhaps
https://unix.stackexchange.com/quest...essor-on-linux

But note: you don't use a CPU after it is disabled.

The problem is that the CPU has full access to main memory - and there is nothing managing that CPU to associate some use of the CPU with memory for that CPU.

That is the function of the kernel.

The only reason to disable a CPU is if you have traced a fault to a particular core, and wish to disable it so that it will not affect the rest of the system.
 
Old 04-25-2017, 08:21 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
No.
cgroups gives the functionality you are probably looking for. You can limit even the interrupt handlers to not run on your "preferred" core, but certain kernel threads will always be candidates for dispatch on any core. Their effect should be negligible.
I use this approach when running benchmarks - I keep a core for my monitoring tasks, and my shell so I can get in if something runs amok.
 
Old 04-26-2017, 05:55 AM   #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
cgroups can not disable a CPU.

This is part of the hotplug support for hot replacement of CPUs in appropriate hardware.

A non-disabled CPU is actively running kernel code - even if it is only the idle process.

What the OP is requesting is partitioning... Not something an Intel (or ARM for that matter) can do.

A Power system might - if the partitioning is implemented and supported by the hardware and boot.

Last edited by jpollard; 04-26-2017 at 05:58 AM.
 
Old 04-26-2017, 06:02 AM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,846

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
a program cannot run without kernel, that is more or less impossible. But you may associate one core with your app and in that case your app will use that core only (almost), see post #5
 
Old 04-26-2017, 06:50 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
Quote:
Originally Posted by pan64 View Post
a program cannot run without kernel, that is more or less impossible. But you may associate one core with your app and in that case your app will use that core only (almost), see post #5
Yes, but that isn't what was requested.

And a program can run without a kernel. After all, that is what grub does, and what the bios/ufi do.
 
Old 04-26-2017, 07:46 AM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,846

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
Quote:
Originally Posted by jpollard View Post
Yes, but that isn't what was requested.
it was the title of the thread:
Quote:
How to start Linux without kernel on one core
Quote:
Originally Posted by jpollard View Post
And a program can run without a kernel. After all, that is what grub does, and what the bios/ufi do.
Yes, a program can run without kernel on ZX81, on C64 too. But not on a system where a linux was booted (and running).
 
Old 04-26-2017, 08:15 AM   #10
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Quote:
Originally Posted by jpollard View Post
Yes, but that isn't what was requested.
And a program can run without a kernel. After all, that is what grub does, and what the bios/ufi do.
Booting is a special case, intended only to load an operating system kernel.

Fundamentally, "the kernel controls everything," and every CPU/core will be running some amount of kernel code, even if that code puts it into a wait-state and keeps it there.

You might be asking for affinity controls: to specify that a particular program should be dedicated to a particular core(s) and vice-versa.

Here are some discussions of it – some quite old:

There is no advantage to having a core sitting idle, nor under-utilized. All cores should be as active as possible. But, as the first referenced article discusses at some length, there are legitimate purposes for specifying affinity.
Quote:
Originally Posted by Linux Journal article above:

Why One Needs CPU Affinity

Before we cover the new system calls, let's discuss why anyone would need such a feature. The first benefit of CPU affinity is optimizing cache performance. I said the O(1) scheduler tries hard to keep tasks on the same processor, and it does. But in some performance-critical situations—perhaps a large database or a highly threaded Java server—it makes sense to enforce the affinity as a hard requirement. Multiprocessing computers go through a lot of trouble to keep the processor caches valid. Data can be kept in only one processor's cache at a time. Otherwise, the processor's cache may grow out of sync, leading to the question, who has the data that is the most up-to-date copy of the main memory? Consequently, whenever a processor adds a line of data to its local cache, all the other processors in the system also caching it must invalidate that data. This invalidation is costly and unpleasant. But the real problem comes into play when processes bounce between processors: they constantly cause cache invalidations, and the data they want is never in the cache when they need it. Thus, cache miss rates grow very large. CPU affinity protects against this and improves cache performance.

A second benefit of CPU affinity is a corollary to the first. If multiple threads are accessing the same data, it might make sense to bind them all to the same processor. Doing so guarantees that the threads do not contend over data and cause cache misses. This does diminish the performance gained from multithreading on SMP. If the threads are inherently serialized, however, the improved cache hit rate may be worth it.

The third and final benefit is found in real-time or otherwise time-sensitive applications. In this approach, all the system processes are bound to a subset of the processors on the system. The specialized application then is bound to the remaining processors. Commonly, in a dual-processor system, the specialized application is bound to one processor, and all other processes are bound to the other. This ensures that the specialized application receives the full attention of the processor.
Note that some comments made in the aforementioned article assume much-earlier versions of the Linux scheduler – which of course were contemporary at that time. Much development attention has been given to these issues since the article was written.

Last edited by sundialsvcs; 04-26-2017 at 08:26 AM.
 
Old 04-26-2017, 08:45 AM   #11
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
All of which is true - but not what was asked.

"Hi everyone! I am just wondering if this is possible. I have a 4 processor machine running Ubuntu. Is it possible to start up the system with the Linux kernel running on 3 of the processors only leaving one completely off? Then on the empty core, is it possible to access it and run a simple program (like an assembly program)?"

And that has nothing to do with CPU affinity, or VMs, or anything but disabling a CPU and then using it for bare bones assembly.

Disabling a CPU is possible, and sometimes necessary as I indicated.

Using it for something else... I've only seen that on Power - and not the cheap ones either.
 
1 members found this post helpful.
Old 04-26-2017, 12:42 PM   #12
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Quote:
Originally Posted by jpollard View Post
All of which is true - but not what was asked.

"Hi everyone! I am just wondering if this is possible. I have a 4 processor machine running Ubuntu. Is it possible to start up the system with the Linux kernel running on 3 of the processors only leaving one completely off? Then on the empty core, is it possible to access it and run a simple program (like an assembly program)?"

And that has nothing to do with CPU affinity, or VMs, or anything but disabling a CPU and then using it for bare bones assembly.

Disabling a CPU is possible, and sometimes necessary as I indicated.

Using it for something else... I've only seen that on Power - and not the cheap ones either.
That is how I read it also. My mention of VMs was because, for all I know, it may be possible to give a host 4 cores and divide them up if, for whatever reason, that's needed for experimental purposes.
 
Old 04-26-2017, 01:45 PM   #13
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
In Linux, at least, I'm confident that the answer is "no." The kernel identifies and then controls everything. You can designate that work is to be done on this-or-that core, and that this-or-that core is to do nothing else, but the kernel is still dispatching the work on the system; still maintaining the overall execution environment.

You can prevent Linux from using all of the cores that it detects, but so far as I know you cannot $ VARY OFF CPU3. (This isn't MVS, folks.)

Last edited by sundialsvcs; 04-26-2017 at 01:50 PM.
 
Old 04-26-2017, 08:08 PM   #14
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 sundialsvcs View Post
In Linux, at least, I'm confident that the answer is "no." The kernel identifies and then controls everything. You can designate that work is to be done on this-or-that core, and that this-or-that core is to do nothing else, but the kernel is still dispatching the work on the system; still maintaining the overall execution environment.

You can prevent Linux from using all of the cores that it detects, but so far as I know you cannot $ VARY OFF CPU3. (This isn't MVS, folks.)
Well... yes you can. All you do is send "echo 0 >/sys/devices/system/cpu/cpu3/online" and that disables the kernels use of CPU3.

https://www.kernel.org/doc/Documenta...ces-system-cpu
https://www.kernel.org/doc/html/late...u_hotplug.html

In those systems with the capability, you are supposed to be able to remove the CPU, insert a new one, and tell the kernel to start using it.

Of course, this requires the hardware support the capability. As far as I know, no motherboards have the capability to remove a CPU without first powering down the entire system.

BTW, Linux does run on mainframes with this capability.

Last edited by jpollard; 04-26-2017 at 08:10 PM.
 
Old 04-26-2017, 09:12 PM   #15
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Quote:
Originally Posted by jpollard View Post
Well... yes you can. All you do is send "echo 0 >/sys/devices/system/cpu/cpu3/online" and that disables the kernels use of CPU3.

In those systems with the capability, you are supposed to be able to remove the CPU, insert a new one, and tell the kernel to start using it.

Of course, this requires the hardware support the capability. As far as I know, no motherboards have the capability to remove a CPU without first powering down the entire system.

BTW, Linux does run on mainframes with this capability.
I graciously yield to your greater knowledge on the subject, and thank you for informing me.

The last time I had the chance to run a Unix-like system on a mainframe was back when I worked for Amdahl Corporation at my first "Silicon Valley" job – running their UTS® system on Amdahl's copy of "big iron." (And, "woo, hoo!" To witness what such hardware could actually do, without MVS® in the way! For a little while, I got to play with "a most-improbable PC!")

(Koff, koff ... guess the kids don't have kucking-floo what we're on about ...) ... (tough luck, kids, you missed it, that's all ...)

Nevertheless – this still basically seems to be VARY OFF situation: instructing the operating system not to use a particular hardware resource. Which is not the same thing as "then sneaking-off somewhere and 'playing hooky' with it," as the OP's question implies. So far as I know, "you simply can't cut the operating system entirely out of the picture."

Last edited by sundialsvcs; 04-26-2017 at 09:15 PM.
 
  


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
linux kernel 4.4.4 and up - almost no all core boost transman Linux - Hardware 2 03-14-2016 01:17 AM
LXer: Tiny Core: this is what a Linux guru should start with LXer Syndicated Linux News 0 07-15-2011 09:00 AM
On which core is Linux kernel running on Dual-core machine? kushalkoolwal Linux - Hardware 22 01-05-2009 02:33 PM
Kernel Panic on Intel Core 2 Duo E6700 Dual Core Processor nwongrat Linux - Hardware 2 01-08-2008 10:13 PM

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

All times are GMT -5. The time now is 01:25 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