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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
04-25-2017, 11:50 AM
|
#1
|
LQ Newbie
Registered: Apr 2017
Posts: 2
Rep:
|
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)?
|
|
|
04-25-2017, 01:40 PM
|
#2
|
Member
Registered: Sep 2016
Location: USA
Posts: 275
Rep:
|
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.
|
|
|
04-25-2017, 01:42 PM
|
#3
|
LQ Addict
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680
|
Something similar may be possibe with virtual machines but the concept looks impossible.
|
|
|
04-25-2017, 05:55 PM
|
#4
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908
|
Quote:
Originally Posted by tanklau
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.
|
|
|
04-25-2017, 09:21 PM
|
#5
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,285
|
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.
|
|
|
04-26-2017, 06:55 AM
|
#6
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908
|
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 06:58 AM.
|
|
|
04-26-2017, 07:02 AM
|
#7
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 23,228
|
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
|
|
|
04-26-2017, 07:50 AM
|
#8
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908
|
Quote:
Originally Posted by pan64
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.
|
|
|
04-26-2017, 08:46 AM
|
#9
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 23,228
|
Quote:
Originally Posted by jpollard
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
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).
|
|
|
04-26-2017, 09:15 AM
|
#10
|
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,962
|
Quote:
Originally Posted by jpollard
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 09:26 AM.
|
|
|
04-26-2017, 09:45 AM
|
#11
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908
|
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.
|
04-26-2017, 01:42 PM
|
#12
|
LQ Addict
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680
|
Quote:
Originally Posted by jpollard
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.
|
|
|
04-26-2017, 02:45 PM
|
#13
|
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,962
|
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 02:50 PM.
|
|
|
04-26-2017, 09:08 PM
|
#14
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908
|
Quote:
Originally Posted by sundialsvcs
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 09:10 PM.
|
|
|
04-26-2017, 10:12 PM
|
#15
|
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,962
|
Quote:
Originally Posted by jpollard
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 10:15 PM.
|
|
|
All times are GMT -5. The time now is 09:59 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|