diff mbox

modpost.c: Add .text.unlikely to TEXT_SECTIONS

Message ID 1366842363-7513-1-git-send-email-trini@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tom Rini April 24, 2013, 10:26 p.m. UTC
Recent gcc's may place functions into the .text.unlikely section and we
need to check this section as well for section mismatches now otherwise
we may have false negatives for this test.

Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org
Cc: linux-kbuild@vger.kernel.org
Signed-off-by: Tom Rini <trini@ti.com>
---
 scripts/mod/modpost.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Rusty Russell April 29, 2013, 2:59 a.m. UTC | #1
Tom Rini <trini@ti.com> writes:

> Recent gcc's may place functions into the .text.unlikely section and we
> need to check this section as well for section mismatches now otherwise
> we may have false negatives for this test.

Hmm, I don't think it's all that recent, is it?  I can find it back to
gcc 4.0.4:

`-freorder-functions'
     Reorder functions in the object file in order to improve code
     locality.  This is implemented by using special subsections
     `.text.hot' for most frequently executed functions and
     `.text.unlikely' for unlikely executed functions.  Reordering is
     done by the linker so object file format must support named
     sections and linker must place them in a reasonable way.

     Also profile feedback must be available in to make this option
     effective.  See `-fprofile-arcs' for details.

     Enabled at levels `-O2', `-O3', `-Os'.

The comment is the same in in gcc 4.7.

So is your real issue that this section is generated with
-fprofile-arcs, or has something changed with gcc 4.8, or...?

Thanks,
Rusty.

> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-kbuild@vger.kernel.org
> Signed-off-by: Tom Rini <trini@ti.com>
> ---
>  scripts/mod/modpost.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index ff36c50..13ff12f 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -880,7 +880,7 @@ static void check_section(const char *modname, struct elf_info *elf,
>  #define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS
>  
>  #define DATA_SECTIONS ".data$", ".data.rel$"
> -#define TEXT_SECTIONS ".text$"
> +#define TEXT_SECTIONS ".text$", ".text.unlikely$"
>  
>  #define INIT_SECTIONS      ".init.*"
>  #define CPU_INIT_SECTIONS  ".cpuinit.*"
> -- 
> 1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tom Rini April 29, 2013, 1:15 p.m. UTC | #2
On 04/28/2013 10:59 PM, Rusty Russell wrote:
> Tom Rini <trini@ti.com> writes:
> 
>> Recent gcc's may place functions into the .text.unlikely section and we
>> need to check this section as well for section mismatches now otherwise
>> we may have false negatives for this test.
> 
> Hmm, I don't think it's all that recent, is it?  I can find it back to
> gcc 4.0.4:
> 
> `-freorder-functions'
>      Reorder functions in the object file in order to improve code
>      locality.  This is implemented by using special subsections
>      `.text.hot' for most frequently executed functions and
>      `.text.unlikely' for unlikely executed functions.  Reordering is
>      done by the linker so object file format must support named
>      sections and linker must place them in a reasonable way.
> 
>      Also profile feedback must be available in to make this option
>      effective.  See `-fprofile-arcs' for details.
> 
>      Enabled at levels `-O2', `-O3', `-Os'.
> 
> The comment is the same in in gcc 4.7.
> 
> So is your real issue that this section is generated with
> -fprofile-arcs, or has something changed with gcc 4.8, or...?

I've started seeing this with Linaro based 4.7 toolchains.  I can go
back through their releases and see when it starts showing up there if
it helps.  I didn't add .text.hot as I didn't have that section at all,
fwiw.
Rusty Russell May 1, 2013, 2:19 a.m. UTC | #3
Tom Rini <trini@ti.com> writes:
> On 04/28/2013 10:59 PM, Rusty Russell wrote:
>> Tom Rini <trini@ti.com> writes:
>> 
>>> Recent gcc's may place functions into the .text.unlikely section and we
>>> need to check this section as well for section mismatches now otherwise
>>> we may have false negatives for this test.
>> 
>> Hmm, I don't think it's all that recent, is it?  I can find it back to
>> gcc 4.0.4:
>> 
>> `-freorder-functions'
>>      Reorder functions in the object file in order to improve code
>>      locality.  This is implemented by using special subsections
>>      `.text.hot' for most frequently executed functions and
>>      `.text.unlikely' for unlikely executed functions.  Reordering is
>>      done by the linker so object file format must support named
>>      sections and linker must place them in a reasonable way.
>> 
>>      Also profile feedback must be available in to make this option
>>      effective.  See `-fprofile-arcs' for details.
>> 
>>      Enabled at levels `-O2', `-O3', `-Os'.
>> 
>> The comment is the same in in gcc 4.7.
>> 
>> So is your real issue that this section is generated with
>> -fprofile-arcs, or has something changed with gcc 4.8, or...?
>
> I've started seeing this with Linaro based 4.7 toolchains.  I can go
> back through their releases and see when it starts showing up there if
> it helps.  I didn't add .text.hot as I didn't have that section at all,
> fwiw.

Weird, did you turn on CONFIG_GCOV_KERNEL?  AFAICT you shouldn't see
this section without that.

Thanks,
Rusty.
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tom Rini May 1, 2013, 11:18 a.m. UTC | #4
On 04/30/2013 10:19 PM, Rusty Russell wrote:
> Tom Rini <trini@ti.com> writes:
>> On 04/28/2013 10:59 PM, Rusty Russell wrote:
>>> Tom Rini <trini@ti.com> writes:
>>>
>>>> Recent gcc's may place functions into the .text.unlikely section and we
>>>> need to check this section as well for section mismatches now otherwise
>>>> we may have false negatives for this test.
>>>
>>> Hmm, I don't think it's all that recent, is it?  I can find it back to
>>> gcc 4.0.4:
>>>
>>> `-freorder-functions'
>>>      Reorder functions in the object file in order to improve code
>>>      locality.  This is implemented by using special subsections
>>>      `.text.hot' for most frequently executed functions and
>>>      `.text.unlikely' for unlikely executed functions.  Reordering is
>>>      done by the linker so object file format must support named
>>>      sections and linker must place them in a reasonable way.
>>>
>>>      Also profile feedback must be available in to make this option
>>>      effective.  See `-fprofile-arcs' for details.
>>>
>>>      Enabled at levels `-O2', `-O3', `-Os'.
>>>
>>> The comment is the same in in gcc 4.7.
>>>
>>> So is your real issue that this section is generated with
>>> -fprofile-arcs, or has something changed with gcc 4.8, or...?
>>
>> I've started seeing this with Linaro based 4.7 toolchains.  I can go
>> back through their releases and see when it starts showing up there if
>> it helps.  I didn't add .text.hot as I didn't have that section at all,
>> fwiw.
> 
> Weird, did you turn on CONFIG_GCOV_KERNEL?  AFAICT you shouldn't see
> this section without that.

Nope, CONFIG_GCOV_KERNEL is off.  Must be related to whatever flags the
Linaro folks set as default on -O2 (at least in their 2013.03 release),
after reading over one of the .o.cmd files in the build.

Do you want me to re-word the commit message a bit or ?  Thanks!
Tom Rini May 1, 2013, 6:14 p.m. UTC | #5
On 05/01/2013 07:18 AM, Tom Rini wrote:
> On 04/30/2013 10:19 PM, Rusty Russell wrote:
>> Tom Rini <trini@ti.com> writes:
>>> On 04/28/2013 10:59 PM, Rusty Russell wrote:
>>>> Tom Rini <trini@ti.com> writes:
>>>>
>>>>> Recent gcc's may place functions into the .text.unlikely section and we
>>>>> need to check this section as well for section mismatches now otherwise
>>>>> we may have false negatives for this test.
>>>>
>>>> Hmm, I don't think it's all that recent, is it?  I can find it back to
>>>> gcc 4.0.4:
>>>>
>>>> `-freorder-functions'
>>>>      Reorder functions in the object file in order to improve code
>>>>      locality.  This is implemented by using special subsections
>>>>      `.text.hot' for most frequently executed functions and
>>>>      `.text.unlikely' for unlikely executed functions.  Reordering is
>>>>      done by the linker so object file format must support named
>>>>      sections and linker must place them in a reasonable way.
>>>>
>>>>      Also profile feedback must be available in to make this option
>>>>      effective.  See `-fprofile-arcs' for details.
>>>>
>>>>      Enabled at levels `-O2', `-O3', `-Os'.
>>>>
>>>> The comment is the same in in gcc 4.7.
>>>>
>>>> So is your real issue that this section is generated with
>>>> -fprofile-arcs, or has something changed with gcc 4.8, or...?
>>>
>>> I've started seeing this with Linaro based 4.7 toolchains.  I can go
>>> back through their releases and see when it starts showing up there if
>>> it helps.  I didn't add .text.hot as I didn't have that section at all,
>>> fwiw.
>>
>> Weird, did you turn on CONFIG_GCOV_KERNEL?  AFAICT you shouldn't see
>> this section without that.
> 
> Nope, CONFIG_GCOV_KERNEL is off.  Must be related to whatever flags the
> Linaro folks set as default on -O2 (at least in their 2013.03 release),
> after reading over one of the .o.cmd files in the build.
> 
> Do you want me to re-word the commit message a bit or ?  Thanks!

I poked around, and every Linaro binary I can grab (2012.01 and gcc 4.6
to 2013.04 and gcc 4.8) has this behaviour.
diff mbox

Patch

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index ff36c50..13ff12f 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -880,7 +880,7 @@  static void check_section(const char *modname, struct elf_info *elf,
 #define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS
 
 #define DATA_SECTIONS ".data$", ".data.rel$"
-#define TEXT_SECTIONS ".text$"
+#define TEXT_SECTIONS ".text$", ".text.unlikely$"
 
 #define INIT_SECTIONS      ".init.*"
 #define CPU_INIT_SECTIONS  ".cpuinit.*"