LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-20-2013, 03:51 PM   #1
Karimo
Member
 
Registered: Aug 2007
Location: Valencia
Distribution: slackware64-current
Posts: 67

Rep: Reputation: 15
Why Linux Kernel must be built without FP instructions?


Hi everybody,
as /usr/src/linux/arch/x86/Makefile says:

Code:
# prevent gcc from generating any FP code by mistake
KBUILD_CFLAGS += $(call cc-option,-mno-sse -mno-mmx -mno-sse2 -mno-3dnow,)
KBUILD_CFLAGS += $(call cc-option,-mno-avx,)
I'm wondering the exact reason for that... maybe the context change mechanisms should not rely on such a variery of full fledged registers? Just saying...
There is no way for the kernel internals to take advantage of hardware's FP advanced instructions?

Thanks in advance for any contribution on the topic!

Best Regards,

Karimo
 
Old 05-21-2013, 05:12 AM   #2
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
I can only theorise at this point, but possibilities that come to mind are:
  • There is nothing for which the kernel legitimately needs floating point: At least, there is nothing that I can think of that it does, but that is probably more a reflection of my (very, very) limited knowledge of this area than anything else
  • if FP was used (on, eg, x86), there would be the distinct possibility of different bugs existing for that arch and other architectures where fp was not present and this would be unnecessarily messy to debug
  • FP is slow: variably slow, depending upon arch, and in some cases (eg, AMD's core approach, where FP units are shared, and therefore there may be a queue for the use of the FP) variably variable depending on when exactly the FP routine was called and what else was going on at the time
  • Slow is not just the obvious 'lack of speed' problem, but it might create race problems
  • FP is not infinitely (infinitesimally inaccurate, actually) accurate; if you like finding out that you have 1.9999999997 ethernet adaptors connected, but only 1.00000000 wireless one, this may only be of amusement to you, but it isn't an advantage (and, ok, you could round it afterwards, but what kind of progamming is that? See the last point!)
  • Linus: I can somehow imagine Linus having a quite attention grabbing rant (justifiably) about bugs slipping in, in using fp calculation when integer was intended, and this being the outcome of that rant. Not saying it actually happened, but it is easy to imagine it happening. Maybe, the possibility of it happening was enough...
 
Old 05-21-2013, 07:55 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939
One major reason is much more mundane ... if you don't use the floating-point chip, you don't have to save-and-restore the floating point processor state unless you actually switch tasks, which many kernel-entry/exit events do not do.
 
Old 06-30-2013, 11:29 AM   #4
nobrowser
LQ Newbie
 
Registered: Mar 2009
Posts: 5

Rep: Reputation: 0
That is all true, but those instruction sets don't just do floating
point calculations - they can be used for vector operations like memcopy
and byteswap regardless of the interpretation of the bits being moved.
And they're faster than other ways of doing it. At least that is my
understanding. So by avoiding them the kernel misses a major potential
optimization on the x86 platform.
 
Old 07-01-2013, 10:07 AM   #5
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
There isn't that many places where it would be useful, and where it is, I think they save the floating point registers used (it would be in the assembly code rather than C code).
 
  


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
Built on Linux. Built on *nix. The OS X application model. drhart4000 Linux - General 2 06-10-2009 04:27 AM
Can linux kernel be built on smartphones just as on Desktops?? BilalMehdi Linux - Mobile 2 11-29-2008 10:07 AM
instructions on how to patch the linux kernel hughes28105 Ubuntu 3 04-04-2007 12:06 PM
built in gui for the linux kernel user222 Linux - General 2 03-21-2005 09:34 AM
Kernel nuking instructions..... CaptainInsane Red Hat 2 12-09-2003 07:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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