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 05-05-2023, 10:43 PM   #1
4pr3nd1z
LQ Newbie
 
Registered: Jan 2022
Distribution: Debian
Posts: 23

Rep: Reputation: 0
Question step to optimize the kernel


Hi guys,

I have a query about kernel optimization; is that I am quite new in this world and I am learning. And before doing something serious, I want to collect as much information as possible in response to my doubts.

Excuse my ignorance on the subject, but... is there a specific optimization for an exact processor/CPU model? For example, for the Pentium III there are three versions: Katmai, Coppermine and Tualatin. Or is it done generically based on the brand Intel regardless of the exact model of the processor?

Thank you in advance for your attention.
 
Old 05-06-2023, 02:44 PM   #2
Pearlseattle
Member
 
Registered: Aug 2007
Location: Zurich, Switzerland
Distribution: Gentoo
Posts: 999

Rep: Reputation: 142Reputation: 142
Hi
It's a valid/good question (if I understood it correctly )

As far as I know:
- on one hand the Linux kernel is usually not compiled to be optimized for a specific CPU model, respectively, you won't find an option that mentions your CPU model.
- on the other hand ~last year I read about kernels that could be compiled for the specific CPU model (something like "-march=native -O3") => I do not remember anymore the results but as I did not try it out I suppose that they weren't that great.

I guess that better optimizations are more related to the options in the kernel config?
E.g. right now I'm now wondering if I should activate or not "CONFIG_SCHED_CORE"; in my case it's for a host that will run PostgreSQL, so I guess that I'll have to test that on my own with my own specific workload to really understand its performance impact...

Cheers
 
Old 05-06-2023, 05:22 PM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
optimization is made by the compiler, so it depends on the compiler and obviously the invocation, the command line options.
General kernels are not really specialized to any CPU. In any case see the manual of the compiler to check the possibilities.
 
Old 05-06-2023, 07:53 PM   #4
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,416
Blog Entries: 43

Rep: Reputation: 36
If you really wanted, I'm sure the Linux kernel is NOT perfect, so you could either fork the linux kernel wherever the repository is (probably github), or you could just privately work on it, and you should probably give back your changes. Then, from that perspective, optimizing the Linux kernel is like optimizing a Hello World application. You could almost always make it more efficiant, if you try hard enough. Some changes the compiler optimization will optimize out, some changes the compiler will keep in. Heck, you could also modify the generated assembly language, and the prewritten assembly language. Or if you're really daring, the machine code. This probably isn't the quote on quote "normal" way to make the optimization you are looking for, or the easiest. But it IS possible, and I wanted you to be aware of it. You could also translate it into more efficient langauges. Since it's open source and FOSS, the possibilities are limitless. I just wanted to make you aware of endless possibility, and also make sure you didn't need to be more specific, or are you finding the answers? Even if you are finding what you're looking for, I did NOT want you to overlook this possibility.
 
Old 05-07-2023, 06:23 AM   #5
DavidMcCann
LQ Veteran
 
Registered: Jul 2006
Location: London
Distribution: PCLinuxOS, Debian
Posts: 6,138

Rep: Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314
If you are interested in optimising the kernel, the Gentoo documentation may be useful.
https://wiki.gentoo.org/wiki/Kernel/...guration_Guide
Whether it's worth doing is another question. Even many (most?) Gentoo users opt for the generic kernel and you'll note that they suggest that one motive for making a custom kernel might be "severe boredom"!
 
3 members found this post helpful.
Old 05-07-2023, 07:26 AM   #6
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth&Mars (I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that work on freest-HW; has been KDE, CLI, Novena-SBC but open.. http://goo.gl/NqgqJx &c ;-)
Posts: 4,888
Blog Entries: 2

Rep: Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567
A quick search shows 1,000,000.1 results, here's a top link: https://www.fosslinux.com/111937/tip...erformance.htm, https://liquorix.net/, https://xanmod.org/...

The post above made me think Linux From Scratch...

Last edited by jamison20000e; 05-09-2023 at 03:54 PM. Reason: typ0 +
 
Old 05-07-2023, 11:59 PM   #7
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,149

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
my 2 cents, what is your end goal? run the Kernel for a specific application? or run the Kernel without other modules that won't be needed in your device?

So, basically you can optimize it by excluding some modules. For example, if you want Linux to run on your browser, and you only need it to process for data that uses, sed, awk, or other tools.

In this way, you can optimize it by excluding drivers that you won't need so it will be lightweight.

As, what other suggested it would depend on how you compile it. Good luck, keep exploring ... and enjoy the journey.
 
Old 05-08-2023, 05:53 PM   #8
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938
FYI, if you do choose to explore the Gentoo distribution, this system does allow you to make a specific CPU-type selection and it will compile the kenel (and, "gcc") with these settings considered. Gentoo is a source-code based distribution where you actually compile everything when you install it.

I once used this on an old "slow" laptop that had been sold to me with Windows-95 installed. Using Gentoo, over time, I was able to make the machine positively fast.
 
Old 05-09-2023, 01:59 PM   #9
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth&Mars (I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that work on freest-HW; has been KDE, CLI, Novena-SBC but open.. http://goo.gl/NqgqJx &c ;-)
Posts: 4,888
Blog Entries: 2

Rep: Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567
The only optimizing of the kernel I ever "needed" on my oldest machines (originally windows 3.0 and up) was targeted drivers vs generic( with mostly a netinst and sid ). My IBM Thinkpad T20 (thrift store) still flies, even if I fire up a DE and compared to what it originally did with microcoughed.
 
Old 05-09-2023, 09:18 PM   #10
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Optimizing for a specific CPU mostly affects vectorized and floating point calculations, neither of which are used in the kernel. It's not clear you would gain much.
 
Old 05-09-2023, 09:50 PM   #11
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,416
Blog Entries: 43

Rep: Reputation: 36
My advice from my limited understanding, is unless you're trying linux for scratch, or trying to write you're own distribution or OS, unless you REALLY know what you're trying to do, I would avoid optimizing - that is, unless required, or unless you are going to contribute code to an existing distribution. However, it's possible, at least as stated. I just personally would try everything else first. However, once you get to a certain point in your programming journey, it would be an advantage to try to read and understand at least the linux kernel, unless you are going to need to make a proprietory competing OS, that uses in NO way, the Linux kernel, but does the same thing. Reading, will help you understand the language you want to program in. I've told you how I know to go about optimizing, if you want to though. Gentoo would be great, like the DavidMcCann said. Then, you might get benefits out of compiling AND optimizing.

I forgot to say, if you want it optimized some, there is almost always an existing distribution, that has already done it. But if you insist on staying with current distribution, then it might make some more sense. This should help a little more. But yes, please tell, if I didn't miss it, what you're end goal of optimizing is. That will target the discussion.

Last edited by des_a; 05-09-2023 at 09:52 PM. Reason: Forgot about distros...
 
Old 05-10-2023, 01:52 PM   #12
yvesjv
Member
 
Registered: Sep 2015
Location: Australia
Distribution: Slackware, Devuan, Freebsd
Posts: 564

Rep: Reputation: Disabled
Haven't had to heavily optimise for years and last time I did, it was for running squid proxy.
File system, the kernel, etc were modified with the target of running squid only.

This query had me googling to see if optimising today is just as easy.
First hit took me to this page and step 6 under 'Compiling your kernel' is interesting with the use of cflags, never done that before.
https://github.com/sn99/Optimizing-linux
 
Old 05-11-2023, 05:01 PM   #13
Pearlseattle
Member
 
Registered: Aug 2007
Location: Zurich, Switzerland
Distribution: Gentoo
Posts: 999

Rep: Reputation: 142Reputation: 142
Quote:
Originally Posted by DavidMcCann View Post
If you are interested in optimising the kernel, the Gentoo documentation may be useful.
https://wiki.gentoo.org/wiki/Kernel/...guration_Guide
Whether it's worth doing is another question. Even many (most?) Gentoo users opt for the generic kernel and you'll note that they suggest that one motive for making a custom kernel might be "severe boredom"!
I personally think that this is debateable and that being able to configure an ad-hoc kernel shouldn't be downplayed . Saying this because I admit that while I hate to do that (review dozens or more of new/changed settings for each major kernel upgrade), I still ~like to do it to personally keep up-to-date with introduced changes (reading docs often make me aware of new/changed functionality) and maybe other weird/interesting changes that happened since the last kernel.
 
1 members found this post helpful.
  


Reply

Tags
kernel, optimization



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
SSD? To optimize OR not to optimize that is the question /awk/ General 6 06-25-2014 09:29 AM
Step by step updating to kernel 2.6.12.5 for me Master Fox Slackware 13 08-24-2005 04:13 PM
Step by step kernel compile for fedora core 3 Braveheart1980 Fedora 6 11-11-2004 01:41 AM
step by step installation of my kernel source zexter Linux - Software 4 11-05-2004 10:31 AM
Does anyone have a good step by step on compiling a Kernel? Kramer Linux - Hardware 5 10-06-2003 05:51 PM

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

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