You are not logged in.

#1 2011-09-04 08:42:01

algorythm
Member
From: /usr/share/zoneinfo/Europe/FIN
Registered: 2009-07-17
Posts: 181

linux-ck KC(PP)FLAGS

To prevent broken monitors and/or keyboards actions have taken place to create this topic. The long talk behind this can be found here: https://aur.archlinux.org/packages.php?ID=50911

So. My suggestions:

1) Remove the "-O2" GCC flag to allow the usage of "CONFIG_CC_OPTIMIZE_FOR_SIZE=y" (Optimize for size: -Os):
Reference: "Enabling this option will pass "-Os" instead of "-O2" to gcc resulting in a smaller kernel." -CONFIG_CC_OPTIMIZE_FOR_SIZE option's description.

2) Remove the "-fstack-protector" GCC flag since it's used by default.
Reference: "What I know about this topic: the -fstack-protector option has been enabled in our _kernel_ builds for at least half a year." -Thomas Bächler (https://bugs.archlinux.org/task/18864)

3) Come up with something for the Intel CPU/32-bit OS issue to satisfy: http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel (<- Really an issue?)
Solution #1: Do a check, e.g:

if [[ "$CARCH" = 'i686' ]] && [[ `gcc -c -Q -march=native --help=target | grep march` = *corei7-avx* ]]; then
  make ${MAKEFLAGS} KCFLAGS="-march=prescott -pipe" KCPPFLAGS="-march=prescott -pipe" bzImage modules
else
  make ${MAKEFLAGS} KCFLAGS="-march=native -pipe" KCPPFLAGS="-march=native -pipe" bzImage modules
fi

Solution #2: Remove the "-march=native" flag altogether and let the user worry about that.
Reference: What t3ddy said: https://aur.archlinux.org/packages.php? … mments=all

Last edited by algorythm (2011-09-22 12:31:16)


“Talent you can bloom. Instinct you can polish.”  — Haikyuu!! (adapted)
“If everybody thought alike, no one would be thinking very much.”  — Walter Lippmann (adapted)
“The important thing is to be able, at any moment, to sacrifice what we are for what we could become.”  — Charles Dubois

Offline

#2 2011-09-04 08:50:28

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: linux-ck KC(PP)FLAGS

@al - For 1 and 2

It currently reads:

make ${MAKEFLAGS} KCFLAGS="-march=native -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2" KCPPFLAGS="-march=native -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2" bzImage modules

You're proposing to change it to:
"-march=native -pipe --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2"

Right?

As to 3.... The discussion in the aur about this was confusing to me and some of the posts have been removed.  I thought that the gentoo wiki was incorrect... plus, when t3ddy used by pkgbuild linked in the aur discussion from Mon, 29 Aug 2011 19:33:13 he got a successful build.  Note that used both march and mtune =corei7-avx

Last edited by graysky (2011-09-04 08:55:15)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#3 2011-09-04 11:32:06

algorythm
Member
From: /usr/share/zoneinfo/Europe/FIN
Registered: 2009-07-17
Posts: 181

Re: linux-ck KC(PP)FLAGS

graysky wrote:

@al - For 1 and 2
You're proposing to change it to:
"-march=native -pipe --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2"

Yeah. For now at least.

graysky wrote:

As to 3.... The discussion in the aur about this was confusing to me and some of the posts have been removed.

None of them have been removed. Click the *Show all 103 comments* button: https://aur.archlinux.org/packages.php? … mments=all

graysky wrote:

I thought that the gentoo wiki was incorrect... plus, when t3ddy used by pkgbuild linked in the aur discussion from Mon, 29 Aug 2011 19:33:13 he got a successful build.  Note that used both march and mtune =corei7-avx

Well, "march=something" also means "mtune=something" anyway, but so he e-mailed you and told that "-march=corei7-avx" (in the PKGBUILD) suddenly started working? I really doubt that's what happened because I think we've proved it won't.

Last edited by algorythm (2011-09-23 07:32:36)


“Talent you can bloom. Instinct you can polish.”  — Haikyuu!! (adapted)
“If everybody thought alike, no one would be thinking very much.”  — Walter Lippmann (adapted)
“The important thing is to be able, at any moment, to sacrifice what we are for what we could become.”  — Charles Dubois

Offline

#4 2011-09-04 11:44:03

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: linux-ck KC(PP)FLAGS

So for 1 and 2... the bug report you listed shows that as it applies to C{,XX}FLAGS not KC(,PP}FLAGS... this is why I'm not sure that it's defaulted.  I did read the description in the nconfig for optimize for size, but the descriptions in the Makefile are different.

algorythm wrote:

Well, "march=something" also means "mtune=something" anyway, but so he e-mailed you and told that "-march=corei7-avx" (in the PKGBUILD) suddenly started working? I really doubt that's what happened because I think we've proved it won't.

But the fact remains that the PKGBUILD I used has these in it and that package works for him.

Last edited by graysky (2011-09-04 11:48:04)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#5 2011-09-04 16:27:12

algorythm
Member
From: /usr/share/zoneinfo/Europe/FIN
Registered: 2009-07-17
Posts: 181

Re: linux-ck KC(PP)FLAGS

graysky wrote:

So for 1 and 2... the bug report you listed shows that as it applies to C{,XX}FLAGS not KC(,PP}FLAGS... this is why I'm not sure that it's defaulted.

*Smiles*. KCPPFLAGS _are_ CXXFLAGS. They are the _kernel_ CXXFLAGS. There's no separate CXXFLAGS to separately optimize the same kernel image.

Could you please just test build yourself to convince yourself?

graysky wrote:

I did read the description in the nconfig for optimize for size, but the descriptions in the Makefile are different.

The only thing it says in the Makefile (at least in mine) is this:

ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
KBUILD_CFLAGS	+= -Os
else
KBUILD_CFLAGS	+= -O2
endif
graysky wrote:

But the fact remains that the PKGBUILD I used has these in it and that package works for him.

Nnnooo? Where did he mention that? The whole talk in the comment section there is about "-march=native" in the KC(PP)FLAGS _not_ working for him.

Trust me: "-march=prescott" does work for him - "-march=native" ("-march=corei7-avx") does not.

We can contact t3ddy about this, if you don't believe me (or the whole discussion there).

Last edited by algorythm (2011-09-22 12:13:47)


“Talent you can bloom. Instinct you can polish.”  — Haikyuu!! (adapted)
“If everybody thought alike, no one would be thinking very much.”  — Walter Lippmann (adapted)
“The important thing is to be able, at any moment, to sacrifice what we are for what we could become.”  — Charles Dubois

Offline

#6 2011-09-04 17:23:48

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: linux-ck KC(PP)FLAGS

@al - it's not that I don't believe you, I'm just trying to get my facts straight smile


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#7 2011-09-05 10:24:36

algorythm
Member
From: /usr/share/zoneinfo/Europe/FIN
Registered: 2009-07-17
Posts: 181

Re: linux-ck KC(PP)FLAGS

So you gonna want to test for this first or... what?


“Talent you can bloom. Instinct you can polish.”  — Haikyuu!! (adapted)
“If everybody thought alike, no one would be thinking very much.”  — Walter Lippmann (adapted)
“The important thing is to be able, at any moment, to sacrifice what we are for what we could become.”  — Charles Dubois

Offline

#8 2011-09-05 11:32:01

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: linux-ck KC(PP)FLAGS

@al - yes, but the right experiment in my opinion is to have someone with the cpu in question on i686 and x86_64 try it.  I don't have one.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#9 2011-09-06 08:37:17

algorythm
Member
From: /usr/share/zoneinfo/Europe/FIN
Registered: 2009-07-17
Posts: 181

Re: linux-ck KC(PP)FLAGS

I actually meant 1 and 2 but so... you don't trust t3ddy or the whole Gentoo Wiki (a distro where every single package is compiled from source and who created a Wiki page based on their years of findings)?

Seriously, I would trust that Wiki with my life. It's not incorrect.

Last edited by algorythm (2011-09-06 13:21:02)


“Talent you can bloom. Instinct you can polish.”  — Haikyuu!! (adapted)
“If everybody thought alike, no one would be thinking very much.”  — Walter Lippmann (adapted)
“The important thing is to be able, at any moment, to sacrifice what we are for what we could become.”  — Charles Dubois

Offline

#10 2011-09-07 19:47:09

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: linux-ck KC(PP)FLAGS

t3ddy reported that the repo packages worked just fine.  Recall that I build the i686/corei7-avx packages with the march-=corei7-avx and it booted/ran just fine for him.

PKGBUILD: http://pastebin.com/MXFRfFJh
config: http://pastebin.com/uKPh2P1Z
makepkg.conf: http://pastebin.com/MBcjaZgY

Also, I have found and corrected several errors on the gentoo wiki tongue

Last edited by graysky (2011-09-07 19:47:47)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#11 2011-09-08 11:25:56

algorythm
Member
From: /usr/share/zoneinfo/Europe/FIN
Registered: 2009-07-17
Posts: 181

Re: linux-ck KC(PP)FLAGS

graysky wrote:

t3ddy reported that the repo packages worked just fine.  Recall that I build the i686/corei7-avx packages with the march-=corei7-avx and it booted/ran just fine for him.

Which I don't understand. You build it for him - it works. He builds it - it doesn't work.

Are you absolutely sure that _that_ is the PKGBUILD you used for the i686 build (makepkg.conf still has no effect in the kernel, btw)? Even this GCC doc here says that it's a 64-bit extension:

corei7-avx
        Intel Core i7 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AES and PCLMUL instruction set support.

graysky wrote:

Also, I have found and corrected several errors on the gentoo wiki tongue

I found only 3 smile: http://en.gentoo-wiki.com/wiki/Special: … ns/Graysky

But so what about the -O2 and -fstack-protector GCC flags. You tested them yet?

Last edited by algorythm (2011-09-08 11:33:32)


“Talent you can bloom. Instinct you can polish.”  — Haikyuu!! (adapted)
“If everybody thought alike, no one would be thinking very much.”  — Walter Lippmann (adapted)
“The important thing is to be able, at any moment, to sacrifice what we are for what we could become.”  — Charles Dubois

Offline

#12 2011-09-15 12:19:25

algorythm
Member
From: /usr/share/zoneinfo/Europe/FIN
Registered: 2009-07-17
Posts: 181

Re: linux-ck KC(PP)FLAGS

You still alive?


“Talent you can bloom. Instinct you can polish.”  — Haikyuu!! (adapted)
“If everybody thought alike, no one would be thinking very much.”  — Walter Lippmann (adapted)
“The important thing is to be able, at any moment, to sacrifice what we are for what we could become.”  — Charles Dubois

Offline

#13 2011-09-15 19:55:12

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: linux-ck KC(PP)FLAGS

Sorry, fell off my RADAR screen.  I'd like to have someone with the machine verify the switches before I change them.  I am 100 % sure that is the PKGBUILD for i686 (my script saves them for each ARCH so I can go back and audit for troubleshooting).


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#14 2011-09-16 12:49:17

algorythm
Member
From: /usr/share/zoneinfo/Europe/FIN
Registered: 2009-07-17
Posts: 181

Re: linux-ck KC(PP)FLAGS

Ok then. And "-O2" and "-fstack-protector"?


“Talent you can bloom. Instinct you can polish.”  — Haikyuu!! (adapted)
“If everybody thought alike, no one would be thinking very much.”  — Walter Lippmann (adapted)
“The important thing is to be able, at any moment, to sacrifice what we are for what we could become.”  — Charles Dubois

Offline

#15 2011-09-16 15:26:16

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: linux-ck KC(PP)FLAGS

Can you offer a method I can use to see that indeed those switches are included in the KCFLAGS/KCPPFLAGS?  I can see for example via a ps aux | grep sequence what gcc is using - presumably the CFLAGS - but I'm not sure how to see the KC/KCPP.

ps aux | grep cc | grep fstack

CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#16 2011-09-17 10:52:44

algorythm
Member
From: /usr/share/zoneinfo/Europe/FIN
Registered: 2009-07-17
Posts: 181

Re: linux-ck KC(PP)FLAGS

Well, I've been trying to tell you to just simply build the kernel without those flags and see whether it affects the size. All the other flags do, Q.E.D: "-O2" and "-fstack-protector" are redundant.

Md5/sha1sum can't be trusted because of e.g. the kernel image's build date that keeps changing upon every rebuild.

Last edited by algorythm (2011-09-17 10:53:50)


“Talent you can bloom. Instinct you can polish.”  — Haikyuu!! (adapted)
“If everybody thought alike, no one would be thinking very much.”  — Walter Lippmann (adapted)
“The important thing is to be able, at any moment, to sacrifice what we are for what we could become.”  — Charles Dubois

Offline

#17 2011-09-17 10:56:12

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: linux-ck KC(PP)FLAGS

I don't think size will give a definitive answer.  To me the correct experiment here is to see the compiler actually use the defaults in question.  I don't know how to do that with the KCF/KCPPFLAGS as I mentioned in post 15.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#18 2011-09-17 11:55:51

algorythm
Member
From: /usr/share/zoneinfo/Europe/FIN
Registered: 2009-07-17
Posts: 181

Re: linux-ck KC(PP)FLAGS

Well then I can't help you.


“Talent you can bloom. Instinct you can polish.”  — Haikyuu!! (adapted)
“If everybody thought alike, no one would be thinking very much.”  — Walter Lippmann (adapted)
“The important thing is to be able, at any moment, to sacrifice what we are for what we could become.”  — Charles Dubois

Offline

#19 2011-09-19 10:29:25

algorythm
Member
From: /usr/share/zoneinfo/Europe/FIN
Registered: 2009-07-17
Posts: 181

Re: linux-ck KC(PP)FLAGS

By the way, should I "close" this thread? I've kinda lost interest in this.


“Talent you can bloom. Instinct you can polish.”  — Haikyuu!! (adapted)
“If everybody thought alike, no one would be thinking very much.”  — Walter Lippmann (adapted)
“The important thing is to be able, at any moment, to sacrifice what we are for what we could become.”  — Charles Dubois

Offline

#20 2011-09-19 11:51:19

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: linux-ck KC(PP)FLAGS

algorythm wrote:

By the way, should I "close" this thread? I've kinda lost interest in this.

If you want to. Just mark it [SOLVED] or the like (not "closed", please) by editing the title of your first post.


To know or not to know ...
... the questions remain forever.

Offline

#21 2011-09-19 19:43:24

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: linux-ck KC(PP)FLAGS

algorythm wrote:

By the way, should I "close" this thread? I've kinda lost interest in this.

I appreciate your level of interest and I'm not trying to be a dick about taking no action - I just want to be sure I have the data to say the current incarnation is wrong.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#22 2011-09-20 11:09:36

algorythm
Member
From: /usr/share/zoneinfo/Europe/FIN
Registered: 2009-07-17
Posts: 181

Re: linux-ck KC(PP)FLAGS

bernarcher wrote:

If you want to. Just mark it [SOLVED] or the like (not "closed", please) by editing the title of your first post.

That sort of crossed my mind, but this wouldn't really leave it as "solved". More like "abandoned".

graysky wrote:

I appreciate your level of interest and I'm not trying to be a dick about taking no action - I just want to be sure I have the data to say the current incarnation is wrong.

Well, I really don't know what else should I tell you. The [linux] maintainer himself said almost a year and a half ago that "-fstack-protector" had been used for "at least half a year".

I also found out about the config option "CONFIG_CC_STACKPROTECTOR" that apparently toggles the said flag: http://cateee.net/lkddb/web-lkddb/CC_ST … ECTOR.html (also enabled by default in [linux]: http://projects.archlinux.org/svntogit/ … ges/linux).

Then there's "-O2". The description of the config option "CONFIG_CC_OPTIMIZE_FOR_SIZE" clearly states:

CONFIG_CC_OPTIMIZE_FOR_SIZE's description wrote:

Enabling this option will pass "-Os" instead of "-O2" to gcc resulting in a smaller kernel.

With "-O1" or "-O3" (which is stupid with the kernel, by the way) the difference in size would also be noticable. Yet with our without the manual flag they are the exact same size.

The manually set "-O2" KC(PP)FLAG also ruins "CONFIG_CC_OPTIMIZE_FOR_SIZE", as mentioned in the linux-ck comment section.

You don't need to see any GCC logs or outputs to confirm this. Being a strict maintainer is one thing, being just too stubborn is something entirely different.

And I'd appreciate it, if you went with the former.


“Talent you can bloom. Instinct you can polish.”  — Haikyuu!! (adapted)
“If everybody thought alike, no one would be thinking very much.”  — Walter Lippmann (adapted)
“The important thing is to be able, at any moment, to sacrifice what we are for what we could become.”  — Charles Dubois

Offline

#23 2011-09-20 15:24:32

Grinch
Member
Registered: 2010-11-07
Posts: 265

Re: linux-ck KC(PP)FLAGS

algorythm wrote:

With "-O1" or "-O3" (which is stupid with the kernel, by the way)

Yes, as I recall the possible speedups given by the optimizations which -O3 enables above -O2 are pointless in the kernel given that those type of optimizations are done 'manually' by the kernel devs using compiler extensions which offers a much higher degree of control and thus performance. Of course, only by benchmarking can we know for certain wheter this is true or not.

Offline

#24 2011-09-20 19:38:11

Griemak
Member
Registered: 2011-05-10
Posts: 46

Re: linux-ck KC(PP)FLAGS

Ugh... I was completely unaware of this in the PKGBUILD sad

Quick question: Why is it not simply:

 make ${MAKEFLAGS} bzImage modules

As far as I understand the makefile from source, the KBUILD_CFLAGS are specifically set for GCC Kernel compilation tuned to specific optimizations and behaviors; starting around line 560.

https://github.com/mirrors/linux/blob/master/Makefile

to include a switch between -O2 and -Os as well as -fno-stack-protector.

I very much enjoy your packages and repo's Graysky and will continue to utilize them as a base for my needs as long as you are willing to thankfully provide.  I think the charge that the fixed KCFLAGS in the PKGBUILD are redundant/unnecessary may have merit, is there anything specific that I may put time/effort into finding/testing to further a fruitful discussion on this matter? 

However, I can not figure out what the business regarding corei7-AVX is...  this is a valid i686 march and mtune.  While it may serve no difference over corei7 or prescott march/mtunes on 32-bit, nothing guarantees it to remain that way.


There are only two ways to live your life: One is as though nothing is a miracle. The other is as though everything is a miracle. - Albert Einstein

How wonderful it is that nobody need wait a single moment before starting to improve the world. - Anne Frank

Offline

#25 2011-09-20 21:44:51

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: linux-ck KC(PP)FLAGS

@Griemak and alg. - at last, some evidence! 

How about I trim it down to:

make ${MAKEFLAGS} KCFLAGS="-march=native -pipe" KCPPFLAGS="-march=native -pipe" bzImage modules

Last edited by graysky (2011-09-20 21:45:19)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

Board footer

Powered by FluxBB