All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Lee Jones <lee.jones@linaro.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Cc: Denis Sadykov <denis.m.sadykov@intel.com>,
	Linux PM <linux-pm@vger.kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Dominik Brodowski <linux@brodo.de>
Subject: Re: [PATCH 09/13] cpufreq: acpi-cpufreq: Remove unused ID structs
Date: Wed, 15 Jul 2020 13:30:36 +0100	[thread overview]
Message-ID: <4ba45e6b-7c49-7a7b-ae76-12d912629e4d@arm.com> (raw)
In-Reply-To: <20200715121657.GE3165313@dell>

On 2020-07-15 13:16, Lee Jones wrote:
> On Wed, 15 Jul 2020, Rafael J. Wysocki wrote:
> 
>> On Wed, Jul 15, 2020 at 1:50 PM Lee Jones <lee.jones@linaro.org> wrote:
>>>
>>> On Wed, 15 Jul 2020, Rafael J. Wysocki wrote:
>>>
>>>> On Wed, Jul 15, 2020 at 1:34 PM Lee Jones <lee.jones@linaro.org> wrote:
>>>>>
>>>>> On Wed, 15 Jul 2020, Rafael J. Wysocki wrote:
>>>>>
>>>>>> On Wed, Jul 15, 2020 at 5:27 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>>>>>>>
>>>>>>> On 15-07-20, 08:54, Viresh Kumar wrote:
>>>>>>>> On 14-07-20, 22:03, Lee Jones wrote:
>>>>>>>>> On Tue, 14 Jul 2020, Rafael J. Wysocki wrote:
>>>>>>>>>
>>>>>>>>>> On Tue, Jul 14, 2020 at 4:51 PM Lee Jones <lee.jones@linaro.org> wrote:
>>>>>>>>>>>
>>>>>>>>>>> Can't see them being used anywhere and the compiler doesn't complain
>>>>>>>>>>> that they're missing, so ...
>>>>>>>>>>
>>>>>>>>>> Aren't they needed for automatic module loading in certain configurations?
>>>>>>>>>
>>>>>>>>> Any idea how that works, or where the code is for that?
>>>>>>>>
>>>>>>>> The MODULE_DEVICE_TABLE() thingy creates a map of vendor-id,
>>>>>>>> product-id that the kernel keeps after boot (and so there is no static
>>>>>>>> reference of it for the compiler), later when a device is hotplugged
>>>>>>>> into the kernel it refers to the map to find the related driver for it
>>>>>>>> and loads it if it isn't already loaded.
>>>>>>>>
>>>>>>>> This has some of it, search for MODULE_DEVICE_TABLE() in it.
>>>>>>>> Documentation/driver-api/usb/hotplug.rst
>>>>>>>
>>>>>>> And you just need to add __maybe_unused to them to suppress the
>>>>>>> warning.
>>>>>>
>>>>>> Wouldn't that cause the compiler to optimize them away if it doesn't
>>>>>> see any users?
>>>>>
>>>>> It looks like they're only unused when !MODULE,
>>>>
>>>> OK
>>>>
>>>>> in which case optimising them away would be the correct thing to do, no?
>>>
>>> It would be good if someone with a little more knowledge could provide
>>> a second opinion though.  I would think (hope) that the compiler would
>>> be smart enough to see when its actually in use.  After all, it is the
>>> compiler that places the information into the device table.
>>>
>> If that is not the case, then the MODULE_DEVICE_TABLE() magic is
>>> broken and will need fixing.
>>
>> I'm not sure why that would be the case?
> 
> Nor me.  In fact, take a look at my latest email.  I think I just
> proved out that it's not broken.  The warning is valid and
> MODULE_DEVICE_TABLE() appears to work just as it should.

I won't claim to be an expert at all, but...

For !MODULE, MODULE_DEVICE_TABLE() expands to nothing, so after 
preprocessing the static variable is literally unreferenced.

Otherwise, MODULE_DEVICE_TABLE() emits an extern declaration of another 
variable which is defined via the "alias" attribute to refer to the 
symbol of the static variable. Thus the compiler presumably has to treat 
it as potentially accessible from other compilation units such that it 
can't be optimised away.

>>> Removing boiler-plate is good, but not at the expense of obfuscation.
>>
>> I'm not following you here to be honest.
> 
> Never mind.  It's no longer important.
> 
>> BTW, I'm wondering if removing the "static" modifier from the
>> definitions of the structures in question makes the warnings you want
>> to get rid of go away.
> 
> I'm sure that it would.  But that just alludes to the fact that the
> tables may be in use elsewhere, which in the case of !MODULE is
> untrue.  That's probably more of a hack than using __maybe_unused.

Right, that just ends up with someone sending another patch changing it 
back to shut up "variable foo was not declared, should it be static?" 
warnings from Sparse ;)

Robin.

WARNING: multiple messages have this Message-ID (diff)
From: Robin Murphy <robin.murphy@arm.com>
To: Lee Jones <lee.jones@linaro.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Cc: Denis Sadykov <denis.m.sadykov@intel.com>,
	Linux PM <linux-pm@vger.kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Dominik Brodowski <linux@brodo.de>
Subject: Re: [PATCH 09/13] cpufreq: acpi-cpufreq: Remove unused ID structs
Date: Wed, 15 Jul 2020 13:30:36 +0100	[thread overview]
Message-ID: <4ba45e6b-7c49-7a7b-ae76-12d912629e4d@arm.com> (raw)
In-Reply-To: <20200715121657.GE3165313@dell>

On 2020-07-15 13:16, Lee Jones wrote:
> On Wed, 15 Jul 2020, Rafael J. Wysocki wrote:
> 
>> On Wed, Jul 15, 2020 at 1:50 PM Lee Jones <lee.jones@linaro.org> wrote:
>>>
>>> On Wed, 15 Jul 2020, Rafael J. Wysocki wrote:
>>>
>>>> On Wed, Jul 15, 2020 at 1:34 PM Lee Jones <lee.jones@linaro.org> wrote:
>>>>>
>>>>> On Wed, 15 Jul 2020, Rafael J. Wysocki wrote:
>>>>>
>>>>>> On Wed, Jul 15, 2020 at 5:27 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>>>>>>>
>>>>>>> On 15-07-20, 08:54, Viresh Kumar wrote:
>>>>>>>> On 14-07-20, 22:03, Lee Jones wrote:
>>>>>>>>> On Tue, 14 Jul 2020, Rafael J. Wysocki wrote:
>>>>>>>>>
>>>>>>>>>> On Tue, Jul 14, 2020 at 4:51 PM Lee Jones <lee.jones@linaro.org> wrote:
>>>>>>>>>>>
>>>>>>>>>>> Can't see them being used anywhere and the compiler doesn't complain
>>>>>>>>>>> that they're missing, so ...
>>>>>>>>>>
>>>>>>>>>> Aren't they needed for automatic module loading in certain configurations?
>>>>>>>>>
>>>>>>>>> Any idea how that works, or where the code is for that?
>>>>>>>>
>>>>>>>> The MODULE_DEVICE_TABLE() thingy creates a map of vendor-id,
>>>>>>>> product-id that the kernel keeps after boot (and so there is no static
>>>>>>>> reference of it for the compiler), later when a device is hotplugged
>>>>>>>> into the kernel it refers to the map to find the related driver for it
>>>>>>>> and loads it if it isn't already loaded.
>>>>>>>>
>>>>>>>> This has some of it, search for MODULE_DEVICE_TABLE() in it.
>>>>>>>> Documentation/driver-api/usb/hotplug.rst
>>>>>>>
>>>>>>> And you just need to add __maybe_unused to them to suppress the
>>>>>>> warning.
>>>>>>
>>>>>> Wouldn't that cause the compiler to optimize them away if it doesn't
>>>>>> see any users?
>>>>>
>>>>> It looks like they're only unused when !MODULE,
>>>>
>>>> OK
>>>>
>>>>> in which case optimising them away would be the correct thing to do, no?
>>>
>>> It would be good if someone with a little more knowledge could provide
>>> a second opinion though.  I would think (hope) that the compiler would
>>> be smart enough to see when its actually in use.  After all, it is the
>>> compiler that places the information into the device table.
>>>
>> If that is not the case, then the MODULE_DEVICE_TABLE() magic is
>>> broken and will need fixing.
>>
>> I'm not sure why that would be the case?
> 
> Nor me.  In fact, take a look at my latest email.  I think I just
> proved out that it's not broken.  The warning is valid and
> MODULE_DEVICE_TABLE() appears to work just as it should.

I won't claim to be an expert at all, but...

For !MODULE, MODULE_DEVICE_TABLE() expands to nothing, so after 
preprocessing the static variable is literally unreferenced.

Otherwise, MODULE_DEVICE_TABLE() emits an extern declaration of another 
variable which is defined via the "alias" attribute to refer to the 
symbol of the static variable. Thus the compiler presumably has to treat 
it as potentially accessible from other compilation units such that it 
can't be optimised away.

>>> Removing boiler-plate is good, but not at the expense of obfuscation.
>>
>> I'm not following you here to be honest.
> 
> Never mind.  It's no longer important.
> 
>> BTW, I'm wondering if removing the "static" modifier from the
>> definitions of the structures in question makes the warnings you want
>> to get rid of go away.
> 
> I'm sure that it would.  But that just alludes to the fact that the
> tables may be in use elsewhere, which in the case of !MODULE is
> untrue.  That's probably more of a hack than using __maybe_unused.

Right, that just ends up with someone sending another patch changing it 
back to shut up "variable foo was not declared, should it be static?" 
warnings from Sparse ;)

Robin.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-07-15 12:30 UTC|newest]

Thread overview: 150+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-14 14:50 [PATCH 00/13] Rid W=1 warnings in CPUFreq Lee Jones
2020-07-14 14:50 ` Lee Jones
2020-07-14 14:50 ` [PATCH 01/13] cpufreq: freq_table: Demote obvious misuse of kerneldoc to standard comment blocks Lee Jones
2020-07-14 14:50   ` Lee Jones
2020-07-15  2:44   ` Viresh Kumar
2020-07-15  2:44     ` Viresh Kumar
2020-07-14 14:50 ` [PATCH 02/13] cpufreq: cpufreq: Demote lots of function headers unworthy of kerneldoc status Lee Jones
2020-07-14 14:50   ` Lee Jones
2020-07-15  2:49   ` Viresh Kumar
2020-07-15  2:49     ` Viresh Kumar
2020-07-15  6:47     ` Lee Jones
2020-07-15  6:47       ` Lee Jones
2020-07-15  7:09       ` Viresh Kumar
2020-07-15  7:09         ` Viresh Kumar
2020-07-14 14:50 ` [PATCH 03/13] cpufreq: cpufreq_governor: Demote store_sampling_rate() header to standard comment block Lee Jones
2020-07-14 14:50   ` Lee Jones
2020-07-15  2:52   ` Viresh Kumar
2020-07-15  2:52     ` Viresh Kumar
2020-07-15  6:45     ` Lee Jones
2020-07-15  6:45       ` Lee Jones
2020-07-15  7:08       ` Viresh Kumar
2020-07-15  7:08         ` Viresh Kumar
2020-07-15  7:31         ` Lee Jones
2020-07-15  7:31           ` Lee Jones
2020-07-15  8:02           ` Viresh Kumar
2020-07-15  8:02             ` Viresh Kumar
2020-07-15  8:15             ` Lee Jones
2020-07-15  8:15               ` Lee Jones
2020-07-14 14:50 ` [PATCH 04/13] cpufreq: sti-cpufreq: Fix some formatting and misspelling issues Lee Jones
2020-07-14 14:50   ` Lee Jones
2020-07-15  2:58   ` Viresh Kumar
2020-07-15  2:58     ` Viresh Kumar
2020-07-14 14:50 ` [PATCH 05/13] cpufreq/arch: powerpc: pasemi: Move prototypes to shared header Lee Jones
2020-07-14 14:50   ` Lee Jones
2020-07-14 14:50   ` Lee Jones
2020-07-15  3:07   ` Viresh Kumar
2020-07-15  3:07     ` Viresh Kumar
2020-07-15  3:07     ` Viresh Kumar
2020-07-15  3:49     ` Olof Johansson
2020-07-15  3:49       ` Olof Johansson
2020-07-15  3:49       ` Olof Johansson
2020-07-15  3:51       ` Viresh Kumar
2020-07-15  3:51         ` Viresh Kumar
2020-07-15  3:51         ` Viresh Kumar
2020-07-15  6:36       ` Lee Jones
2020-07-15  6:36         ` Lee Jones
2020-07-15  6:36         ` Lee Jones
2020-07-15  6:39         ` Viresh Kumar
2020-07-15  6:39           ` Viresh Kumar
2020-07-15  6:39           ` Viresh Kumar
2020-07-15  3:26   ` Olof Johansson
2020-07-15  3:26     ` Olof Johansson
2020-07-15  3:26     ` Olof Johansson
2020-07-15  6:33     ` Lee Jones
2020-07-15  6:33       ` Lee Jones
2020-07-15  6:33       ` Lee Jones
2020-07-15  6:46       ` Olof Johansson
2020-07-15  6:46         ` Olof Johansson
2020-07-15  6:46         ` Olof Johansson
2020-07-15  7:33         ` Lee Jones
2020-07-15  7:33           ` Lee Jones
2020-07-15  7:33           ` Lee Jones
2020-07-14 14:50 ` [PATCH 06/13] cpufreq: powernv-cpufreq: Functions only used in call-backs should be static Lee Jones
2020-07-14 14:50   ` Lee Jones
2020-07-14 14:50   ` Lee Jones
2020-07-15  3:07   ` Viresh Kumar
2020-07-15  3:07     ` Viresh Kumar
2020-07-15  3:07     ` Viresh Kumar
2020-07-14 14:50 ` [PATCH 07/13] cpufreq: powernv-cpufreq: Fix a bunch of kerneldoc related issues Lee Jones
2020-07-14 14:50   ` Lee Jones
2020-07-14 14:50   ` Lee Jones
2020-07-15  3:09   ` Viresh Kumar
2020-07-15  3:09     ` Viresh Kumar
2020-07-15  3:09     ` Viresh Kumar
2020-07-14 14:50 ` [PATCH 08/13] cpufreq: acpi-cpufreq: Take 'dummy' principle one stage further Lee Jones
2020-07-14 14:50   ` Lee Jones
2020-07-14 16:03   ` Rafael J. Wysocki
2020-07-14 16:03     ` Rafael J. Wysocki
2020-07-14 16:20     ` Robin Murphy
2020-07-14 16:20       ` Robin Murphy
2020-07-14 21:00       ` Lee Jones
2020-07-14 21:00         ` Lee Jones
2020-07-14 14:50 ` [PATCH 09/13] cpufreq: acpi-cpufreq: Remove unused ID structs Lee Jones
2020-07-14 14:50   ` Lee Jones
2020-07-14 15:58   ` Rafael J. Wysocki
2020-07-14 15:58     ` Rafael J. Wysocki
2020-07-14 21:03     ` Lee Jones
2020-07-14 21:03       ` Lee Jones
2020-07-15  3:24       ` Viresh Kumar
2020-07-15  3:24         ` Viresh Kumar
2020-07-15  3:27         ` Viresh Kumar
2020-07-15  3:27           ` Viresh Kumar
2020-07-15  6:37           ` Lee Jones
2020-07-15  6:37             ` Lee Jones
2020-07-15 11:27           ` Rafael J. Wysocki
2020-07-15 11:27             ` Rafael J. Wysocki
2020-07-15 11:34             ` Lee Jones
2020-07-15 11:34               ` Lee Jones
2020-07-15 11:44               ` Rafael J. Wysocki
2020-07-15 11:44                 ` Rafael J. Wysocki
2020-07-15 11:50                 ` Lee Jones
2020-07-15 11:50                   ` Lee Jones
2020-07-15 12:07                   ` Lee Jones
2020-07-15 12:07                     ` Lee Jones
2020-07-15 12:11                     ` Rafael J. Wysocki
2020-07-15 12:11                       ` Rafael J. Wysocki
2020-07-15 12:09                   ` Rafael J. Wysocki
2020-07-15 12:09                     ` Rafael J. Wysocki
2020-07-15 12:16                     ` Lee Jones
2020-07-15 12:16                       ` Lee Jones
2020-07-15 12:30                       ` Robin Murphy [this message]
2020-07-15 12:30                         ` Robin Murphy
2020-07-15 12:38                         ` Lee Jones
2020-07-15 12:38                           ` Lee Jones
2020-07-14 14:50 ` [PATCH 10/13] cpufreq: powernow-k8: Make use of known set but not used variables Lee Jones
2020-07-14 14:50   ` Lee Jones
2020-07-14 17:43   ` Rafael J. Wysocki
2020-07-14 17:43     ` Rafael J. Wysocki
2020-07-14 21:01     ` Lee Jones
2020-07-14 21:01       ` Lee Jones
2020-07-14 14:50 ` [PATCH 11/13] cpufreq: pcc-cpufreq: Remove unused ID structs Lee Jones
2020-07-14 14:50   ` Lee Jones
2020-07-14 17:42   ` Rafael J. Wysocki
2020-07-14 17:42     ` Rafael J. Wysocki
2020-07-14 14:50 ` [PATCH 12/13] cpufreq: intel_pstate: Supply struct attribute description for get_aperf_mperf_shift() Lee Jones
2020-07-14 14:50   ` Lee Jones
2020-07-14 16:35   ` Rafael J. Wysocki
2020-07-14 16:35     ` Rafael J. Wysocki
2020-07-14 21:03     ` Lee Jones
2020-07-14 21:03       ` Lee Jones
2020-07-15 12:38       ` Rafael J. Wysocki
2020-07-15 12:38         ` Rafael J. Wysocki
2020-07-14 14:50 ` [PATCH 13/13] cpufreq: amd_freq_sensitivity: Remove unused ID structs Lee Jones
2020-07-14 14:50   ` Lee Jones
2020-07-14 17:15   ` Kim Phillips
2020-07-14 17:15     ` Kim Phillips
2020-07-14 21:02     ` Lee Jones
2020-07-14 21:02       ` Lee Jones
2020-07-14 21:13       ` Kim Phillips
2020-07-14 21:13         ` Kim Phillips
2020-07-15  6:47         ` Lee Jones
2020-07-15  6:47           ` Lee Jones
2020-07-15  3:36 ` [PATCH 00/13] Rid W=1 warnings in CPUFreq Viresh Kumar
2020-07-15  3:36   ` Viresh Kumar
2020-07-15  6:32   ` Lee Jones
2020-07-15  6:32     ` Lee Jones
2020-07-15  6:38     ` Viresh Kumar
2020-07-15  6:38       ` Viresh Kumar
2020-07-15  7:34       ` Lee Jones
2020-07-15  7:34         ` Lee Jones

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=4ba45e6b-7c49-7a7b-ae76-12d912629e4d@arm.com \
    --to=robin.murphy@arm.com \
    --cc=denis.m.sadykov@intel.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@brodo.de \
    --cc=paul.s.diefenbaugh@intel.com \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=viresh.kumar@linaro.org \
    /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.