From: Stephen Warren <swarren@wwwdotorg.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Hiroshi Doyu <hdoyu@nvidia.com>,
"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>,
"marvin24@gmx.de" <marvin24@gmx.de>,
"balbi@ti.com" <balbi@ti.com>,
"linux@arm.linux.org.uk" <linux@arm.linux.org.uk>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [v2 3/3] ARM: tegra: Unify Device tree board files
Date: Tue, 12 Feb 2013 13:52:17 -0700 [thread overview]
Message-ID: <511AAB81.4000306@wwwdotorg.org> (raw)
In-Reply-To: <201302121732.14960.arnd@arndb.de>
On 02/12/2013 10:32 AM, Arnd Bergmann wrote:
> On Tuesday 12 February 2013, Stephen Warren wrote:
>>>>>>> I don't think that's going to help any link issues, so I'd drop it and
>>>>>>> keep this function simple.
>>>>>>
>>>>>> As explained in the above, a complier will drop unnecessary functions
>>>>>> automatically with this IS_ENABLED(), which could save many ifdefs.
>>>>>
>>>>> That sounds extremely brittle. Have you validated this on a wide variety
>>>>> of compiler versions?
>>>>
>>>> I verified with gcc-4.6.
>>>> IIRC, that's the point of IS_ENABLED() being introduced. Arnd?
>>>
>>> It's certainly expected to work with all compilers, yes. If a compiler
>>> cannot remove conditional function calls that depend on a constant
>>> expression, we have a lot of other problems alredy.
>>
>> Removing the function calls isn't guaranteed to remove the body of the
>> functions though. Those functions aren't implemented in some separate
>> file that's optionally included, but rather are implemented in the same
>> object file, now unconditionally, and they in turn reference (with no
>> IS_ENABLED logic) other functions that are implemented in conditionally
>> linked files.
>
> I think gcc should remove all of that in this case, since board_init_funcs
> becomes unused when the only code that references it cannot be reached,
> and when that array is gone, the now unused functions would be removed
> as well.
>
> We have had bugs with prerelease gcc versions that did not handle cases
> like this in the way we want it, but I think all releases get it right.
> I don't think it's mandated anywhere in the C99 standard that this is
> what happens, but we do rely on it anyway AFAIK.
Hmmm. Very surprisingly (to me), this does indeed work fine, even with
an older gcc-4.4.1 I had lying around (after fixing the test inversion
in tegra_dt_init_late).
I believe U-Boot enabled -ffunction-sections -fdata-sections or similar
(recently?) to get this kind of behaviour. I wonder why the kernel
didn't need that. Perhaps -O2 is more aggressive (within a file at
least) than I thought.
I did note a few warnings due to the ifdefs in tegra_auxdata_lookup[]:
arch/arm/mach-tegra/tegra.c:47: warning: 'tegra_ehci1_pdata' defined but
not used
arch/arm/mach-tegra/tegra.c:58: warning: 'tegra_ehci2_pdata' defined but
not used
arch/arm/mach-tegra/tegra.c:65: warning: 'tegra_ehci3_pdata' defined but
not used
(I built a tegra_defconfig kernel and modified it to enable
Tegra30+Tegra114, disable Tegra20, disable DRM)
WARNING: multiple messages have this Message-ID (diff)
From: swarren@wwwdotorg.org (Stephen Warren)
To: linux-arm-kernel@lists.infradead.org
Subject: [v2 3/3] ARM: tegra: Unify Device tree board files
Date: Tue, 12 Feb 2013 13:52:17 -0700 [thread overview]
Message-ID: <511AAB81.4000306@wwwdotorg.org> (raw)
In-Reply-To: <201302121732.14960.arnd@arndb.de>
On 02/12/2013 10:32 AM, Arnd Bergmann wrote:
> On Tuesday 12 February 2013, Stephen Warren wrote:
>>>>>>> I don't think that's going to help any link issues, so I'd drop it and
>>>>>>> keep this function simple.
>>>>>>
>>>>>> As explained in the above, a complier will drop unnecessary functions
>>>>>> automatically with this IS_ENABLED(), which could save many ifdefs.
>>>>>
>>>>> That sounds extremely brittle. Have you validated this on a wide variety
>>>>> of compiler versions?
>>>>
>>>> I verified with gcc-4.6.
>>>> IIRC, that's the point of IS_ENABLED() being introduced. Arnd?
>>>
>>> It's certainly expected to work with all compilers, yes. If a compiler
>>> cannot remove conditional function calls that depend on a constant
>>> expression, we have a lot of other problems alredy.
>>
>> Removing the function calls isn't guaranteed to remove the body of the
>> functions though. Those functions aren't implemented in some separate
>> file that's optionally included, but rather are implemented in the same
>> object file, now unconditionally, and they in turn reference (with no
>> IS_ENABLED logic) other functions that are implemented in conditionally
>> linked files.
>
> I think gcc should remove all of that in this case, since board_init_funcs
> becomes unused when the only code that references it cannot be reached,
> and when that array is gone, the now unused functions would be removed
> as well.
>
> We have had bugs with prerelease gcc versions that did not handle cases
> like this in the way we want it, but I think all releases get it right.
> I don't think it's mandated anywhere in the C99 standard that this is
> what happens, but we do rely on it anyway AFAIK.
Hmmm. Very surprisingly (to me), this does indeed work fine, even with
an older gcc-4.4.1 I had lying around (after fixing the test inversion
in tegra_dt_init_late).
I believe U-Boot enabled -ffunction-sections -fdata-sections or similar
(recently?) to get this kind of behaviour. I wonder why the kernel
didn't need that. Perhaps -O2 is more aggressive (within a file at
least) than I thought.
I did note a few warnings due to the ifdefs in tegra_auxdata_lookup[]:
arch/arm/mach-tegra/tegra.c:47: warning: 'tegra_ehci1_pdata' defined but
not used
arch/arm/mach-tegra/tegra.c:58: warning: 'tegra_ehci2_pdata' defined but
not used
arch/arm/mach-tegra/tegra.c:65: warning: 'tegra_ehci3_pdata' defined but
not used
(I built a tegra_defconfig kernel and modified it to enable
Tegra30+Tegra114, disable Tegra20, disable DRM)
next prev parent reply other threads:[~2013-02-12 20:52 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-11 6:05 [v2 1/3] ARM: tegra: Unify tegra{20,30,114}_init_early() Hiroshi Doyu
2013-02-11 6:05 ` Hiroshi Doyu
2013-02-11 6:05 ` Hiroshi Doyu
2013-02-11 6:05 ` [v2 2/3] ARM: tegra: Rename board-dt-tegra20.c to tegra.c Hiroshi Doyu
2013-02-11 6:05 ` Hiroshi Doyu
2013-02-11 6:05 ` [v2 3/3] ARM: tegra: Unify Device tree board files Hiroshi Doyu
2013-02-11 6:05 ` Hiroshi Doyu
[not found] ` <1360562743-21689-3-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-11 23:54 ` Stephen Warren
2013-02-11 23:54 ` Stephen Warren
2013-02-11 23:54 ` Stephen Warren
2013-02-12 4:12 ` Hiroshi Doyu
2013-02-12 4:12 ` Hiroshi Doyu
[not found] ` <20130212.061240.2083183700176617607.hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-12 4:47 ` Stephen Warren
2013-02-12 4:47 ` Stephen Warren
2013-02-12 4:47 ` Stephen Warren
2013-02-12 5:04 ` Hiroshi Doyu
2013-02-12 5:04 ` Hiroshi Doyu
2013-02-12 13:50 ` Arnd Bergmann
2013-02-12 13:50 ` Arnd Bergmann
[not found] ` <201302121350.15683.arnd-r2nGTMty4D4@public.gmane.org>
2013-02-12 16:35 ` Stephen Warren
2013-02-12 16:35 ` Stephen Warren
2013-02-12 16:35 ` Stephen Warren
[not found] ` <511A6F6C.8090205-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-02-12 17:32 ` Arnd Bergmann
2013-02-12 17:32 ` Arnd Bergmann
2013-02-12 17:32 ` Arnd Bergmann
2013-02-12 20:52 ` Stephen Warren [this message]
2013-02-12 20:52 ` Stephen Warren
2013-02-12 22:25 ` Arnd Bergmann
2013-02-12 22:25 ` Arnd Bergmann
2013-02-13 6:12 ` Hiroshi Doyu
2013-02-13 6:12 ` Hiroshi Doyu
2013-02-13 6:12 ` Hiroshi Doyu
[not found] ` <20130213.081240.1605796167151164030.hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-13 16:50 ` Stephen Warren
2013-02-13 16:50 ` Stephen Warren
2013-02-13 16:50 ` Stephen Warren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=511AAB81.4000306@wwwdotorg.org \
--to=swarren@wwwdotorg.org \
--cc=arnd@arndb.de \
--cc=balbi@ti.com \
--cc=hdoyu@nvidia.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=marvin24@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.