Skip to contentSkip to conversation

move __attribute__((__cold__)) functions back into final .text section

PATCH Applied Jan Beulich 5 participants 6 messages Jun 18, 2008 – Jul 6, 2008 Generic include/asm header files

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 move __attribute__((__cold__)) functions back into final .text section

Due to the addition of __attribute__((__cold__)) to a few symbols without adjusting the linker scripts, those symbols currently may end up outside the [_stext,_etext) range, as they get placed in .text.unlikely by (at least) gcc 4.3.0. This may confuse code not only outside of the kernel, symbol_put_addr()'s BUG() could also trigger. Hence we need to add .text.unlikely (and for future uses of __attribute__((__hot__)) also .text.hot) to the TEXT_TEXT() macro.

Issue observed by Lukas Lipavsky.

Cc Lukas Lipavsky <[email protected]>
---
 include/asm-generic/vmlinux.lds.h |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
include/asm-generic/vmlinux.lds.h +3 -1
@@ -204,6 +204,7 @@
  * during second ld run in second ld pass when generating System.map */
 #define TEXT_TEXT							\
 		ALIGN_FUNCTION();					\
+		*(.text.hot)						\
 		*(.text)						\
 		*(.ref.text)						\
 		*(.text.init.refok)					\
@@ -213,7 +214,8 @@
 	CPU_KEEP(init.text)						\
 	CPU_KEEP(exit.text)						\
 	MEM_KEEP(init.text)						\
-	MEM_KEEP(exit.text)
+	MEM_KEEP(exit.text)						\
+		*(.text.unlikely)
 
 
 /* sched.text is aling to function alignment to secure we have same
Tested-by on v1 1/1
#1 lore raw

Jan Beulich píše v St 18. 06. 2008 v 12:36 +0100:

Quoted 9 lines

Due to the addition of __attribute__((__cold__)) to a few symbols without adjusting the linker scripts, those symbols currently may end up outside the [_stext,_etext) range, as they get placed in .text.unlikely by (at least) gcc 4.3.0. This may confuse code not only outside of the kernel, symbol_put_addr()'s BUG() could also trigger. Hence we need to add .text.unlikely (and for future uses of __attribute__((__hot__)) also .text.hot) to the TEXT_TEXT() macro.

Cc Lukas Lipavsky <[email protected]>
Applied
#2 lore raw
In reply to Jan Beulich
Quoted 8 lines · Jan Beulich

Due to the addition of __attribute__((__cold__)) to a few symbols without adjusting the linker scripts, those symbols currently may end up outside the [_stext,_etext) range, as they get placed in .text.unlikely by (at least) gcc 4.3.0. This may confuse code not only outside of the kernel, symbol_put_addr()'s BUG() could also trigger. Hence we need to add .text.unlikely (and for future uses of __attribute__((__hot__)) also .text.hot) to the TEXT_TEXT() macro.

Quoted 4 lines

Issue observed by Lukas Lipavsky.

Cc Lukas Lipavsky <[email protected]>

Applied.

Sam

#3 lore raw
In reply to Jan Beulich
Quoted 29 lines · On Wed, 18 Jun 2008 12:36:01 +0100 "Jan Beulich" <[email protected]> wrote:

Due to the addition of __attribute__((__cold__)) to a few symbols without adjusting the linker scripts, those symbols currently may end up outside the [_stext,_etext) range, as they get placed in .text.unlikely by (at least) gcc 4.3.0. This may confuse code not only outside of the kernel, symbol_put_addr()'s BUG() could also trigger. Hence we need to add .text.unlikely (and for future uses of __attribute__((__hot__)) also .text.hot) to the TEXT_TEXT() macro.

Issue observed by Lukas Lipavsky.

Cc Lukas Lipavsky <[email protected]>
---
 include/asm-generic/vmlinux.lds.h |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
include/asm-generic/vmlinux.lds.h +1 -0
@@ -204,6 +204,7 @@
  * during second ld run in second ld pass when generating System.map */
 #define TEXT_TEXT							\
 		ALIGN_FUNCTION();					\
+		*(.text.hot)						\
 		*(.text)						\
 		*(.ref.text)						\
 		*(.text.init.refok)					\

include/asm-generic/vmlinux.lds.h line 221

Quoted 9 lines
include/asm-generic/vmlinux.lds.h +2 -1
@@ -213,7 +214,8 @@
 	CPU_KEEP(init.text)						\
 	CPU_KEEP(exit.text)						\
 	MEM_KEEP(init.text)						\
-	MEM_KEEP(exit.text)
+	MEM_KEEP(exit.text)						\
+		*(.text.unlikely)
 
 
 /* sched.text is aling to function alignment to secure we have same

So this is now in Sam's git+ssh://master.kernel.org/pub/scm/linux/kernel/git/sam/kbuild-next.git. But it is not in the present linux-next. Either because Sam added it after Stephen pulled Sam's tree, or because something screwed up.

So I'll now be dropping it. Sam, please ensure that it gets into 2.6.26 and 2.6.25.x (IMO).

Thanks.

#4 lore raw

Hi Andrew,

Quoted 5 lines · On Tue, 1 Jul 2008 23:17:17 -0700 Andrew Morton <[email protected]>…

So this is now in Sam's git+ssh://master.kernel.org/pub/scm/linux/kernel/git/sam/kbuild-next.git. But it is not in the present linux-next. Either because Sam added it after Stephen pulled Sam's tree, or because something screwed up.

Its in the linux-next tree I have just (in the last 30 minutes) published (but not yet announced) (tag next-20080702).

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/
#5 lore raw
In reply to Andrew Morton
Quoted 46 lines · Andrew Morton
Quoted 29 lines · On Wed, 18 Jun 2008 12:36:01 +0100 "Jan Beulich" <[email protected]> wrote:

Due to the addition of __attribute__((__cold__)) to a few symbols without adjusting the linker scripts, those symbols currently may end up outside the [_stext,_etext) range, as they get placed in .text.unlikely by (at least) gcc 4.3.0. This may confuse code not only outside of the kernel, symbol_put_addr()'s BUG() could also trigger. Hence we need to add .text.unlikely (and for future uses of __attribute__((__hot__)) also .text.hot) to the TEXT_TEXT() macro.

Issue observed by Lukas Lipavsky.

Cc Lukas Lipavsky <[email protected]>
---
 include/asm-generic/vmlinux.lds.h |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
include/asm-generic/vmlinux.lds.h +1 -0
@@ -204,6 +204,7 @@
  * during second ld run in second ld pass when generating System.map */
 #define TEXT_TEXT							\
 		ALIGN_FUNCTION();					\
+		*(.text.hot)						\
 		*(.text)						\
 		*(.ref.text)						\
 		*(.text.init.refok)					\

include/asm-generic/vmlinux.lds.h line 221

Quoted 9 lines
include/asm-generic/vmlinux.lds.h +2 -1
@@ -213,7 +214,8 @@
 	CPU_KEEP(init.text)						\
 	CPU_KEEP(exit.text)						\
 	MEM_KEEP(init.text)						\
-	MEM_KEEP(exit.text)
+	MEM_KEEP(exit.text)						\
+		*(.text.unlikely)
 
 
 /* sched.text is aling to function alignment to secure we have same

So this is now in Sam's git+ssh://master.kernel.org/pub/scm/linux/kernel/git/sam/kbuild-next.git. But it is not in the present linux-next. Either because Sam added it after Stephen pulled Sam's tree, or because something screwed up.

Quoted 2 lines

So I'll now be dropping it. Sam, please ensure that it gets into 2.6.26 and 2.6.25.x (IMO).

I have added a Cc: <[email protected]> so the stable team should pick it when applied to -linus.

Sam