[SOLVED] How to start Linux without kernel on one core
Linux - NewbieThis 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.
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.
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)?
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.
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)?
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.
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.
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
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.
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:
Linux Journal (2003) – discussing the need for this feature when it was first introduced
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.
"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.
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680
Rep:
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.
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.
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.
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.
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 missedit, 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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.