Please include const-sections into linux-next
Stephen,
Please includegit://github.com/andikleen/linux-misc.git const-sections in linux-next. This has a tree sweep to fix all kind of constant section issues.
I intend to send Linus a pull request next cycle and would like to get some testing in next first.
I got various acks last time it was posted and added them all. In general it falls more in the "trivial" category, but it's rather large and all over so I may have made a mistake.
Thanks,
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.
Hi Andi,
Quoted 8 lines · On Fri, 14 Oct 2011 01:38:18 +0200 Andi Kleen <[email protected]> wrote:
Please include
git://github.com/andikleen/linux-misc.gitconst-sections in linux-next. This has a tree sweep to fix all kind of constant section issues.I intend to send Linus a pull request next cycle and would like to get some testing in next first.
You picked a bad time unfortunately. Today will amost certainly be the last linux-next tree before the merge window opens (since I will be on vacation until kernel summit) so if it breaks the tree, it will impact on others testing (and there won't be a followup tree to correct the problem).
Also, the commit messages are still very terse (as a few people pointed out) and I have seen no response to Thomas' remarks either.
Quoted 3 lines
I got various acks last time it was posted and added them all. In general it falls more in the "trivial" category, but it's rather large and all over so I may have made a mistake.
It really isn't trivial because we have had various problems with init and const in the past with various toolchains (and even different problems on different architectures with the "same" toolchain).
Linus or Andrew may still want to take these, but I don't think I can add it to linux-next right now, sorry.
Signature · 3 lines
Cheers, Stephen Rothwell [email protected] http://www.canb.auug.org.au/~sfr/
James Bottomley
maintainerQuoted 7 lines · Andi Kleen
Stephen,
Please include
git://github.com/andikleen/linux-misc.gitconst-sections in linux-next. This has a tree sweep to fix all kind of constant section issues.
Quoted 6 lines
I intend to send Linus a pull request next cycle and would like to get some testing in next first.
I got various acks last time it was posted and added them all. In general it falls more in the "trivial" category, but it's rather large and all over so I may have made a mistake.
It's not incredibly trivial: it causes a compile failure on parisc:
mm/percpu.c:1372: error: __setup_str_percpu_alloc_setup causes a section type conflict
make[1]: *** [mm/percpu.o] Error 1
I have no idea why, though.
James
PATCH 1/1 parisc, iommu: add missing include for prefetchw()
prefetchw() requires it to be defined by linux/prefetch.h, or it results in a compile error:
In file included from drivers/parisc/sba_iommu.c:916:0:drivers/parisc/iommu-helpers.h: In function 'iommu_fill_pdir':drivers/parisc/iommu-helpers.h:62:4: error: implicit declaration of function 'prefetchw'
Include linux/prefetch.h.
--- drivers/parisc/iommu-helpers.h | 2 ++ 1 files changed, 2 insertions(+)
drivers/parisc/iommu-helpers.h +2 -0
@@ -1,3 +1,5 @@ +#include <linux/prefetch.h> +/** * iommu_fill_pdir - Insert coalesced scatter/gather chunks into the I/O Pdir. * @ioc: The I/O Controller.
Quoted 8 lines · James Bottomley
It's not incredibly trivial: it causes a compile failure on parisc:
mm/percpu.c:1372: error:__setup_str_percpu_alloc_setupcauses a section type conflict
make[1]: *** [mm/percpu.o] Error 1I have no idea why, though.
Not sure why this would only happen on parisc, but I haven't looked at it closely. It means something qualified with const is being defined in a section with other definitions that are not const, or vice versa.
For example:
static int x __attribute__((__section__("foo"))) = 1;
static const int y __attribute__((__section__("foo"))) = 2;will result in the same error. Since __setup_param() places __setup_str_percpu_alloc_setup in .init.rodata as const, it means something else has already been defined in .init.rodata without being qualified as such.
James Bottomley
maintainerRe: [patch] parisc, iommu: add missing include for prefetchw()
In reply to David RientjesQuoted 8 lines · David Rientjes
prefetchw()requires it to be defined bylinux/prefetch.h, or it results in a compile error:In file included from
drivers/parisc/sba_iommu.c:916:0:drivers/parisc/iommu-helpers.h: In function 'iommu_fill_pdir':drivers/parisc/iommu-helpers.h:62:4: error: implicit declaration of function 'prefetchw'Include
linux/prefetch.h.
This isn't physically possible on the parisc platform: prefetch.h is included by processor.h which, amongst other things, goes into spinlock.h which is above this file in sba_iommu.c
How did you try to compile this file?
James
James Bottomley
maintainerQuoted 8 lines · David Rientjes
Quoted 6 lines · James Bottomley
It's not incredibly trivial: it causes a compile failure on parisc:
mm/percpu.c:1372: error:__setup_str_percpu_alloc_setupcauses a section type conflict
make[1]: *** [mm/percpu.o] Error 1
Quoted 6 lines
Quoted 2 lines
I have no idea why, though.
Not sure why this would only happen on parisc, but I haven't looked at it closely. It means something qualified with const is being defined in a section with other definitions that are not const, or vice versa.
I think it's probably a compiler bug. gcc isn't as adept with section annotations as people think it is. This tends to manifest in the non-x86 toolchains because we tend to be using earlier versions.
James
Re: [patch] parisc, iommu: add missing include for prefetchw()
In reply to James BottomleyQuoted 4 lines · James Bottomley
This isn't physically possible on the parisc platform:
prefetch.his included byprocessor.hwhich, amongst other things, goes intospinlock.hwhich is above this file insba_iommu.c
asm/prefetch.h is included in processor.h, not linux/prefetch.h. Thus, it's undefined for CONFIG_PA20=n.
Quoted 2 lines
How did you try to compile this file?
make allyesconfig
make drivers/parisc/sba_iommu.o
Quoted 4 lines · James Bottomley
I think it's probably a compiler bug. gcc isn't as adept with section annotations as people think it is. This tends to manifest in the non-x86 toolchains because we tend to be using earlier versions.
It compiles fine with my cross-compiler using gcc-4.5.1.
James Bottomley
maintainerRe: [patch] parisc, iommu: add missing include for prefetchw()
In reply to David RientjesQuoted 9 lines · David Rientjes
Quoted 4 lines · James Bottomley
This isn't physically possible on the parisc platform:
prefetch.his included byprocessor.hwhich, amongst other things, goes intospinlock.hwhich is above this file insba_iommu.c
asm/prefetch.his included inprocessor.h, notlinux/prefetch.h. Thus, it's undefined forCONFIG_PA20=n.
sba_iommu isn't possible with CONFIG_PA20=n; it's a ZX1 or above feature.
Quoted 5 lines
Quoted 2 lines
How did you try to compile this file?
make allyesconfig
makedrivers/parisc/sba_iommu.o
OK, so just take one of the standard configs ... I don't think anyone's tried much randconfig testing over parisc, most of the configuration lore is handed down from the mountain on stone tablets.
James
James Bottomley
maintainerQuoted 8 lines · David Rientjes
Quoted 4 lines · James Bottomley
I think it's probably a compiler bug. gcc isn't as adept with section annotations as people think it is. This tends to manifest in the non-x86 toolchains because we tend to be using earlier versions.
It compiles fine with my cross-compiler using gcc-4.5.1.
So it's a native toolchain bug in gcc ... the point still stands:
there'll be tons of these throughout non x86 tool chains. You can't break every arch under the sun just for a dubious mark stuff const.
James
Re: [patch] parisc, iommu: add missing include for prefetchw()
In reply to James BottomleyQuoted 10 lines · James Bottomley
Quoted 5 lines
Quoted 2 lines
How did you try to compile this file?
make allyesconfig
makedrivers/parisc/sba_iommu.oOK, so just take one of the standard configs ... I don't think anyone's tried much randconfig testing over parisc, most of the configuration lore is handed down from the mountain on stone tablets.
This isn't randconfig, it's allyesconfig, and this is the only compile error that I got while trying to reproduce your percpu.c compile failure. Everything else works fine.
Quoted 1 line
I have no idea why, though.
Thanks for testing.
Yes it's hard to tell with plain gcc (before 4.7) I have a special gcc patch to tell me the other symbol :)
Usually it's because some other symbol is wrong. In this case it must be in the same translation unit.
Can you please do
make mm/percpu.i
on that build and send me the percpu.i in private email?
Thanks,
-Andi
James Bottomley
maintainerQuoted 7 lines · Andi Kleen
Quoted 1 line
I have no idea why, though.
Thanks for testing.
Yes it's hard to tell with plain gcc (before 4.7) I have a special gcc patch to tell me the other symbol :)
Quoted 8 lines
Usually it's because some other symbol is wrong. In this case it must be in the same translation unit.
Can you please do
make
mm/percpu.ion that build and send me the percpu.i in private email?
OK, so after fixing up that one, the next failure is:
drivers/net/fealnx.c:95: error: version causes a section type conflict drivers/net/fealnx.c:1944: error: fealnx_pci_tbl causes a section type conflict
James
vate email?
Quoted 6 lines
OK, so after fixing up that one, the next failure is:
drivers/net/fealnx.c:95: error: version causes a section type conflictdrivers/net/fealnx.c:1944: error:fealnx_pci_tblcauses a section type conflict
Hmm, this is weird (just like the other error)
I wonder if the pa-risc tool chain has some general problems with sections
On a successful build with the same config could you send me the output of
make drivers/net/fealnx.s
and
make drivers/net/fealnx.i
in the same config privately? From that I can see if there's something else in init.rodata that does not match my i386 build.
One alternative to track it down would be to apply the attached patch to the gcc, then gcc would print it out.
-Andi
James Bottomley
maintainerQuoted 11 lines · Andi Kleen
vate email?
Quoted 6 lines
OK, so after fixing up that one, the next failure is:
drivers/net/fealnx.c:95: error: version causes a section type conflictdrivers/net/fealnx.c:1944: error:fealnx_pci_tblcauses a section type conflictHmm, this is weird (just like the other error)
I wonder if the pa-risc tool chain has some general problems with sections
Quoted 8 lines
On a successful build with the same config could you send me the output of
make
drivers/net/fealnx.s
and
makedrivers/net/fealnx.iin the same config privately? From that I can see if there's something else in init.rodata that does not match my i386 build.
Yes, I'll send under separate cover.
Quoted 2 lines
One alternative to track it down would be to apply the attached patch to the gcc, then gcc would print it out.
I think the basic problem that excites the toolchain somehow is sectional annotations. Can't we just dump them and do it all in a linker script? Linker scripts seem to be much better tested.
James
Quoted 6 lines · James Bottomley
Quoted 3 lines
One alternative to track it down would be to apply the attached patch to the gcc, then gcc would print it out.
I think the basic problem that excites the toolchain somehow is sectional annotations. Can't we just dump them and do it all in a
We already use these annotations all over. Just currently they mess up the 'r' and 'w' bits on the sections because a few (not the majority) of declarations mismatch the ro vs rw sections. My patchkit was just trying to fix up those that were wrong
So you should be already using them.
Just need to find out what triggers your toolchain with these changes. I suspect it's some kind of toolchain bug.
Quoted 1 line
linker script? Linker scripts seem to be much better tested.
The linker script just declares the order of the section. The attributes are a union of what the compiler declares. To dump them I just use objdump --section-headers or readelf -a usually.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.
James Bottomley
maintainerQuoted 13 lines · Andi Kleen
Quoted 6 lines · James Bottomley
Quoted 3 lines
One alternative to track it down would be to apply the attached patch to the gcc, then gcc would print it out.
I think the basic problem that excites the toolchain somehow is sectional annotations. Can't we just dump them and do it all in a
We already use these annotations all over. Just currently they mess up the 'r' and 'w' bits on the sections because a few (not the majority) of declarations mismatch the ro vs rw sections. My patchkit was just trying to fix up those that were wrong
Quoted 4 lines
So you should be already using them.
Just need to find out what triggers your toolchain with these changes. I suspect it's some kind of toolchain bug.
I think I've already said 3 times that I think it's some kind of toolchain bug. The problem is it's likely in all the non-x86 toolchains.
Quoted 6 lines
Quoted 1 line
linker script? Linker scripts seem to be much better tested.
The linker script just declares the order of the section. The attributes are a union of what the compiler declares. To dump them I just use objdump --section-headers or readelf -a usually.
OK, look at it another way: why do we need the type annotations? I think it's only for section conflict checking, right? If the compiler gets it wrong anyway, why not just dump all the type annotations, then it should have no type conflicts (spurious or otherwise) to complain about. We already have link time section checking scripts (they're the useless ones that complain about section mismatches in dev annoations) so why not put them to work to make up for compiler deficiencies?
James
Quoted 3 lines
I think I've already said 3 times that I think it's some kind of toolchain bug. The problem is it's likely in all the non-x86 toolchains.
Not convinced it's everywhere. Just need to track it down.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
linker script? Linker scripts seem to be much better tested.
The linker script just declares the order of the section. The attributes are a union of what the compiler declares. To dump them I just use objdump --section-headers or readelf -a usually.
Quoted 7 lines
OK, look at it another way: why do we need the type annotations? I think it's only for section conflict checking, right? If the compiler gets it wrong anyway, why not just dump all the type annotations, then it should have no type conflicts (spurious or otherwise) to complain about. We already have link time section checking scripts (they're the useless ones that complain about section mismatches in dev annoations) so why not put them to work to make up for compiler deficiencies?
You mean removing all the init sections stuff? I think it has been proposed in the past, but it's a couple of hundred KB of memory usually. Would you accept that for PA-RISC?
If you have init sections you need to annotate them correctly because a section is defined by its rwx attributes plus name and both need to match. We didn't always check this, so there was some bitrot, but it ultimatively has to be correct.
-Andi
James Bottomley
maintainerQuoted 8 lines · Andi Kleen
Quoted 7 lines
OK, look at it another way: why do we need the type annotations? I think it's only for section conflict checking, right? If the compiler gets it wrong anyway, why not just dump all the type annotations, then it should have no type conflicts (spurious or otherwise) to complain about. We already have link time section checking scripts (they're the useless ones that complain about section mismatches in dev annoations) so why not put them to work to make up for compiler deficiencies?
Quoted 8 lines
You mean removing all the init sections stuff? I think it has been proposed in the past, but it's a couple of hundred KB of memory usually. Would you accept that for PA-RISC?
If you have init sections you need to annotate them correctly because a section is defined by its rwx attributes plus name and both need to match. We didn't always check this, so there was some bitrot, but it ultimatively has to be correct.
We're talking at cross purposes. But it doesn't matter, the error doesn't seem to be anything to do with type. This simple patch is what's causing it (I can apply it alone to the working tree) and get the error.
What I can't see is why.
James
---
drivers/net/fealnx.c +1 -1
@@ -150,7 +150,7 @@ struct chip_info {int flags; }; -static const struct chip_info skel_netdrv_tbl[]__devinitdata = { +static const struct chip_info skel_netdrv_tbl[]__devinitconst = { {"100/10M Ethernet PCI Adapter" ,HAS_MII_XCVR }, {"100/10M Ethernet PCI Adapter" ,HAS_CHIP_XCVR }, {"1000/100/10M Ethernet PCI Adapter" ,HAS_MII_XCVR },
Quoted 18 lines · James Bottomley
Quoted 8 lines · Andi Kleen
Quoted 7 lines
OK, look at it another way: why do we need the type annotations? I think it's only for section conflict checking, right? If the compiler gets it wrong anyway, why not just dump all the type annotations, then it should have no type conflicts (spurious or otherwise) to complain about. We already have link time section checking scripts (they're the useless ones that complain about section mismatches in dev annoations) so why not put them to work to make up for compiler deficiencies?
Quoted 8 lines
You mean removing all the init sections stuff? I think it has been proposed in the past, but it's a couple of hundred KB of memory usually. Would you accept that for PA-RISC?
If you have init sections you need to annotate them correctly because a section is defined by its rwx attributes plus name and both need to match. We didn't always check this, so there was some bitrot, but it ultimatively has to be correct.
Quoted 6 lines
We're talking at cross purposes. But it doesn't matter, the error doesn't seem to be anything to do with type. This simple patch is what's causing it (I can apply it alone to the working tree) and get the error.
What I can't see is why.
For some reason your compiler sets the const section read/write:
.section .devinit.data,"aw",@progbits <---- writable
.align 8
.type skel_netdrv_tbl, @object
.size skel_netdrv_tbl, 48skel_netdrv_tbl:
; chip_name:
.dword .LC56
while my x86 toolchain sets it to read only
.string "1000/100/10M Ethernet PCI Adapter"
.section .devinit.data,"a",@progbits <---- not writable
.align 16
.type skel_netdrv_tbl, @object
.size skel_netdrv_tbl, 48skel_netdrv_tbl:
# chip_name:
.quad .LC32
# flags:
.long 0
.zero 4
If you check a few other const symbols with own
section are they all also writable?
-andi
James Bottomley
maintainerQuoted 36 lines · Andi Kleen
Quoted 18 lines · James Bottomley
Quoted 8 lines · Andi Kleen
Quoted 7 lines
OK, look at it another way: why do we need the type annotations? I think it's only for section conflict checking, right? If the compiler gets it wrong anyway, why not just dump all the type annotations, then it should have no type conflicts (spurious or otherwise) to complain about. We already have link time section checking scripts (they're the useless ones that complain about section mismatches in dev annoations) so why not put them to work to make up for compiler deficiencies?
Quoted 8 lines
You mean removing all the init sections stuff? I think it has been proposed in the past, but it's a couple of hundred KB of memory usually. Would you accept that for PA-RISC?
If you have init sections you need to annotate them correctly because a section is defined by its rwx attributes plus name and both need to match. We didn't always check this, so there was some bitrot, but it ultimatively has to be correct.
Quoted 6 lines
We're talking at cross purposes. But it doesn't matter, the error doesn't seem to be anything to do with type. This simple patch is what's causing it (I can apply it alone to the working tree) and get the error.
What I can't see is why.
For some reason your compiler sets the const section read/write:
.section .devinit.data,"aw",@progbits <---- writable
.align 8
.typeskel_netdrv_tbl, @object
.sizeskel_netdrv_tbl, 48skel_netdrv_tbl:
;chip_name:.dword .LC56
Quoted 7 lines
while my x86 toolchain sets it to read only
.string "1000/100/10M Ethernet PCI Adapter"
.section .devinit.data,"a",@progbits <---- not writable
.align 16
.typeskel_netdrv_tbl, @object
.sizeskel_netdrv_tbl, 48
So most of our const stuff is "a" not "aw". However, this particular list is a list of strings ... this is probably something to do with writeable strings?
James
James Bottomley
maintainerQuoted 1 line · James Bottomley
this is probably something to do with writeable strings?
Bingo! If I add -fno-writeable-strings to the compiler directives, it works.
James
Quoted 5 lines · James Bottomley
Quoted 1 line
this is probably something to do with writeable strings?
Bingo! If I add -fno-writeable-strings to the compiler directives, it works.
Cool thanks. I assume the resulting kernel works.
This means the pa compiler defaults to -fwritable-strings? Odd.
Are you handling that or should I add a patch to the tree?
-Andi
James Bottomley
maintainerQuoted 11 lines · Andi Kleen
Quoted 5 lines · James Bottomley
Quoted 1 line
this is probably something to do with writeable strings?
Bingo! If I add -fno-writeable-strings to the compiler directives, it works.
Cool thanks. I assume the resulting kernel works.
This means the pa compiler defaults to -fwritable-strings? Odd.
Are you handling that or should I add a patch to the tree?
Actually, no, sorry ... its a false positive -fno-writeable-strings actually produces an error which was lost in all the debug output (it's at the top) so it wasn't working; I only thought it was.
James
Quoted 1 line
Actually, no, sorry ... its a false positive -fno-writeable-strings
Ok the fealnx object wasn't actually a string.
Quoted 2 lines
actually produces an error which was lost in all the debug output (it's at the top) so it wasn't working; I only thought it was.
What's the error?
-Andi