Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Kernel patch for additional CPU for GCC optimizations
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
emc
Guru
Guru


Joined: 02 Jul 2004
Posts: 564
Location: Cracow, Poland

PostPosted: Tue Jun 11, 2013 2:51 pm    Post subject: Kernel patch for additional CPU for GCC optimizations Reply with quote

Really nice patch:
https://github.com/graysky2/kernel_gcc_patch

Kernel patch adds additional CPU options to the Linux kernel accessible under: Processor type and features ---> Processor family --->

Why a specific patch? The kernel uses its own set of CFLAGS, KCFLAGS. For exmaple, see:
arch/x86/Makefile
arch/x86/Makefile_32.cpu
arch/x86/Kconfig.cpu

CPU Family/GCC Optimization:
Native optimizations autodetected by GCC
-march=native

AMD K10-family
-march=amdfam10

AMD Family 10h (Barcelona)
-march=barcelona

AMD Family 14h (Bobcat)
-march=brver1

AMD Family 15h (Bulldozer)
-march=bdver1

Piledriver Family 15h (Piledriver)
-march=bdver2

Intel 1st Gen Core i3/i5/i7-family (Nehalem)
-march=corei7

Intel 2nd Gen Core i3/i5/i7-family (Sandybridge)
-march=corei7-avx

Intel 3rd Gen Core i3/i5/i7-family (Ivybridge)
-march=core-avx-i

Intel 4th Gen Core i3/i5/i7-family (Haswell)
-march=core-avx2
Back to top
View user's profile Send private message
trippels
Tux's lil' helper
Tux's lil' helper


Joined: 24 Nov 2010
Posts: 137
Location: Berlin

PostPosted: Fri Jun 14, 2013 9:31 am    Post subject: Reply with quote

Yeah. I've been using the following on my k10 for ages:

Code:

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 5c47726..748e5c8 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -61,7 +61,7 @@ else
        KBUILD_CFLAGS += $(call cc-option,-mno-sse -mpreferred-stack-boundary=3)
 
         # FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu)
-        cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
+        cflags-$(CONFIG_MK8) += $(call cc-option,-march=native)
         cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
 
         cflags-$(CONFIG_MCORE2) += \
Back to top
View user's profile Send private message
vexatious
Tux's lil' helper
Tux's lil' helper


Joined: 24 Aug 2010
Posts: 85

PostPosted: Wed Jun 19, 2013 12:00 am    Post subject: Reply with quote

Do you know how to contact the maintainer (graysky2)? Wondering if a custom cpu option could be added (use custom cflags). This would be beneficial for modules that require msseregparm (it is recommended to compile all libraries and modules with msseregparm if anything uses msseregparm); mfpmath might improve speed too.
_________________
Gentoo
Slackware
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Thu Jun 20, 2013 10:15 am    Post subject: Reply with quote

vexatious wrote:
Do you know how to contact the maintainer (graysky2)?

Look at the Arch Linux forums.
Back to top
View user's profile Send private message
olutyo
n00b
n00b


Joined: 20 Jun 2013
Posts: 2

PostPosted: Tue Jul 02, 2013 12:06 am    Post subject: Reply with quote

Thank you very much
Finally you can configure the kernel characteristics
Back to top
View user's profile Send private message
GFCCAE6xF
Apprentice
Apprentice


Joined: 06 Aug 2012
Posts: 295

PostPosted: Tue Jul 30, 2013 1:40 pm    Post subject: Reply with quote

Just got round to trying this, certainly works (and is worth it) even if the returns are so small. Only bad thing is now I shall have to move pf-sources back in to my local and keep things going in there rather then clutter up and forget /etc/portage/patches/* since that's somewhat an obscure place for package patches imo.

This patch(es) would be extra nice as an, even masked, custom-optimizations flag or similar.

Edit: Loosing my mind, corrections ahoy :)
Back to top
View user's profile Send private message
smartass
Apprentice
Apprentice


Joined: 04 Jul 2011
Posts: 189
Location: right behind you ... (you did turn around, didn't you?)

PostPosted: Tue Jul 30, 2013 4:01 pm    Post subject: Reply with quote

Sounds like ricing, if it was safe, wouldn't it be the standard procedure? I can easily imagine a poorly written driver to fail with some optimizations.
Back to top
View user's profile Send private message
broken_chaos
Guru
Guru


Joined: 18 Jan 2006
Posts: 370
Location: Ontario, Canada

PostPosted: Wed Jul 31, 2013 12:19 am    Post subject: Reply with quote

smartass wrote:
Sounds like ricing, if it was safe, wouldn't it be the standard procedure? I can easily imagine a poorly written driver to fail with some optimizations.

All it changes is the march option. It's completely safe, as it only adjusts the features GCC compiles for compatibility with (sse, avx, and similar), so barring some hardware problem with those features (i.e., a processor reporting it supports AVX when it doesn't, which happens under xen sometimes -- and is just as much of a problem for the march in make.conf which is considered safe), there's no danger at all.

The kernel developers are just a bit weird about what gcc optimizations they've set to be configured. (Partly because a lot of the 'major' CPU features are detected and enabled in the kernel code itself, rather than via GCC.)
Back to top
View user's profile Send private message
smartass
Apprentice
Apprentice


Joined: 04 Jul 2011
Posts: 189
Location: right behind you ... (you did turn around, didn't you?)

PostPosted: Thu Aug 01, 2013 7:45 am    Post subject: Reply with quote

broken_chaos, your arguments do make sense, but I'd still like to see some real evidence or an opinion of a kernel developer.
Back to top
View user's profile Send private message
okias
n00b
n00b


Joined: 03 Jul 2007
Posts: 17
Location: Czech Republic

PostPosted: Sun Dec 08, 2013 3:23 am    Post subject: Reply with quote

I plan include this patch in mptcp-sources, because it seems totally safe.

Maybe it could be added to gentoo-sources with experimental USE flag enabled?
Back to top
View user's profile Send private message
BartNL
n00b
n00b


Joined: 29 Aug 2004
Posts: 65

PostPosted: Wed Mar 05, 2014 12:16 pm    Post subject: Reply with quote

Sorry for bumping up an old topic. How do i install the patch? Can i only apply it to gentoo-sources?
Back to top
View user's profile Send private message
SirRobin2318
Apprentice
Apprentice


Joined: 24 Apr 2004
Posts: 241
Location: Strasbourg, france.

PostPosted: Wed Mar 05, 2014 2:42 pm    Post subject: Reply with quote

add:
Code:
sys-kernel/gentoo-sources experimental

In your use flags files.
Back to top
View user's profile Send private message
BartNL
n00b
n00b


Joined: 29 Aug 2004
Posts: 65

PostPosted: Wed Mar 05, 2014 5:53 pm    Post subject: Reply with quote

SirRobin2318 wrote:
add:
Code:
sys-kernel/gentoo-sources experimental

In your use flags files.


Thank you. I added that to package.use, re-emerged gentoo-sources and did a make oldconfig. The only thing that came up was BFQ-scheduler. I also tried make distclean but no extra processor types showed up.
Back to top
View user's profile Send private message
SirRobin2318
Apprentice
Apprentice


Joined: 24 Apr 2004
Posts: 241
Location: Strasbourg, france.

PostPosted: Wed Mar 05, 2014 8:21 pm    Post subject: Reply with quote

in make menuconfig
Code:
Processor type and features  --->
  Processor family (...) --->

you don't see Native optimizations autodetected by GCC?
https://wiki.gentoo.org/wiki/Project:Kernel/Experimental
The patch is listed, and I'm using it. What version are you using?

Have you selected the latest installed kernel in:
Code:
eselect kernel list
Back to top
View user's profile Send private message
BartNL
n00b
n00b


Joined: 29 Aug 2004
Posts: 65

PostPosted: Wed Mar 05, 2014 9:16 pm    Post subject: Reply with quote

SirRobin2318 wrote:
in make menuconfig
Code:
Processor type and features  --->
  Processor family (...) --->

you don't see Native optimizations autodetected by GCC?
https://wiki.gentoo.org/wiki/Project:Kernel/Experimental
The patch is listed, and I'm using it. What version are you using?

Have you selected the latest installed kernel in:
Code:
eselect kernel list


My kernel :
Code:

gbox ~ # eselect kernel list
Available kernel symlink targets:
  [1]   linux-3.10.25-gentoo


I see only: generic, intel atom, core2, intel p4 and opteron. Very strange.
Back to top
View user's profile Send private message
SirRobin2318
Apprentice
Apprentice


Joined: 24 Apr 2004
Posts: 241
Location: Strasbourg, france.

PostPosted: Wed Mar 05, 2014 10:32 pm    Post subject: Reply with quote

Check if the experimental flags are enabled using emerge -1av gentoo-sources.
If that's the case maybe it's available for newer kernels only, I'm using 3.13.5. But I find this strange, I thought I used this with 3.10.
Back to top
View user's profile Send private message
BartNL
n00b
n00b


Joined: 29 Aug 2004
Posts: 65

PostPosted: Wed Mar 05, 2014 10:53 pm    Post subject: Reply with quote

SirRobin2318 wrote:
Check if the experimental flags are enabled using emerge -1av gentoo-sources.
If that's the case maybe it's available for newer kernels only, I'm using 3.13.5. But I find this strange, I thought I used this with 3.10.


Confirm. Are you using gentoo-sources unstable? I did ab emerge --sync before i installed experimental.
Back to top
View user's profile Send private message
SirRobin2318
Apprentice
Apprentice


Joined: 24 Apr 2004
Posts: 241
Location: Strasbourg, france.

PostPosted: Wed Mar 05, 2014 11:02 pm    Post subject: Reply with quote

Yes, I am. Does emerge -1av gentoo-sources not mention the experimental flag? If it does, you should consider using 3.13.x.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum