* [PATCH] iwlwifi: pcie: make array 'prop' static, shrinks object size
@ 2018-08-21 10:21 Colin King
2018-09-04 6:07 ` Luciano Coelho
0 siblings, 1 reply; 6+ messages in thread
From: Colin King @ 2018-08-21 10:21 UTC (permalink / raw)
To: Johannes Berg, Emmanuel Grumbach, Luca Coelho,
Intel Linux Wireless, Kalle Valo, David S . Miller,
linux-wireless, netdev
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Don't populate the array prop on the stack but instead make it static.
Makes the object code smaller by 30 bytes:
Before:
text data bss dec hex filename
80138 15382 576 96096 17760 drivers/net/wireless/intel/iwlwifi/pcie/trans.o
After:
text data bss dec hex filename
79948 15542 576 96066 17742 drivers/net/wireless/intel/iwlwifi/pcie/trans.o
(gcc version 8.2.0 x86_64)
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index 7d319b6863fe..c7daf666ee21 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -1947,7 +1947,7 @@ static void iwl_trans_pcie_removal_wk(struct work_struct *wk)
struct iwl_trans_pcie_removal *removal =
container_of(wk, struct iwl_trans_pcie_removal, work);
struct pci_dev *pdev = removal->pdev;
- char *prop[] = {"EVENT=INACCESSIBLE", NULL};
+ static char *prop[] = {"EVENT=INACCESSIBLE", NULL};
dev_err(&pdev->dev, "Device gone - attempting removal\n");
kobject_uevent_env(&pdev->dev.kobj, KOBJ_CHANGE, prop);
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] iwlwifi: pcie: make array 'prop' static, shrinks object size
2018-08-21 10:21 [PATCH] iwlwifi: pcie: make array 'prop' static, shrinks object size Colin King
@ 2018-09-04 6:07 ` Luciano Coelho
0 siblings, 0 replies; 6+ messages in thread
From: Luciano Coelho @ 2018-09-04 6:07 UTC (permalink / raw)
To: Colin King, Johannes Berg, Emmanuel Grumbach,
Intel Linux Wireless, Kalle Valo, David S . Miller,
linux-wireless, netdev
Cc: kernel-janitors, linux-kernel
On Tue, 2018-08-21 at 11:21 +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Don't populate the array prop on the stack but instead make it static.
> Makes the object code smaller by 30 bytes:
>
> Before:
> text data bss dec hex filename
> 80138 15382 576 96096 17760 drivers/net/wireless/intel/iwlwifi/pcie/trans.o
>
> After:
> text data bss dec hex filename
> 79948 15542 576 96066 17742 drivers/net/wireless/intel/iwlwifi/pcie/trans.o
>
> (gcc version 8.2.0 x86_64)
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
> index 7d319b6863fe..c7daf666ee21 100644
> --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
> +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
> @@ -1947,7 +1947,7 @@ static void iwl_trans_pcie_removal_wk(struct work_struct *wk)
> struct iwl_trans_pcie_removal *removal =
> container_of(wk, struct iwl_trans_pcie_removal, work);
> struct pci_dev *pdev = removal->pdev;
> - char *prop[] = {"EVENT=INACCESSIBLE", NULL};
> + static char *prop[] = {"EVENT=INACCESSIBLE", NULL};
>
> dev_err(&pdev->dev, "Device gone - attempting removal\n");
> kobject_uevent_env(&pdev->dev.kobj, KOBJ_CHANGE, prop);
Thanks! I pushed this to our internal tree and it will reach upstream
following our normal process.
--
Luca.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iwlwifi: pcie: make array prop static, shrinks object size
2018-06-11 20:45 ` Greg Kroah-Hartman
@ 2018-06-14 14:36 ` Kalle Valo
0 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2018-06-14 14:36 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Joe Perches, Colin King, Johannes Berg, Emmanuel Grumbach,
Luca Coelho, Intel Linux Wireless, David S . Miller,
linux-wireless, netdev, kernel-janitors, linux-kernel
Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:
> On Mon, Jun 11, 2018 at 12:40:55PM -0700, Joe Perches wrote:
>> (adding Greg KH)
>>
>> Now what is happening is that prop is being reloaded
>> each invocation with the constant addresses of the strings.
>>
>> It seems the prototype and function for kobject_uevent_env
>> should change as well to avoid this.
>>
>> Perhaps this should become:
>> ---
>> drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 2 +-
>> include/linux/kobject.h | 2 +-
>> lib/kobject_uevent.c | 2 +-
>> 3 files changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
>> index 7229991ae70d..6668a8aad22e 100644
>> --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
>> +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
>> @@ -1946,7 +1946,7 @@ static void iwl_trans_pcie_removal_wk(struct work_struct *wk)
>> struct iwl_trans_pcie_removal *removal =
>> container_of(wk, struct iwl_trans_pcie_removal, work);
>> struct pci_dev *pdev = removal->pdev;
>> - char *prop[] = {"EVENT=INACCESSIBLE", NULL};
>> + static const char * const prop[] = {"EVENT=INACCESSIBLE", NULL};
>>
>> dev_err(&pdev->dev, "Device gone - attempting removal\n");
>> kobject_uevent_env(&pdev->dev.kobj, KOBJ_CHANGE, prop);
>> diff --git a/include/linux/kobject.h b/include/linux/kobject.h
>> index 7f6f93c3df9c..9f5cf553dd1e 100644
>> --- a/include/linux/kobject.h
>> +++ b/include/linux/kobject.h
>> @@ -217,7 +217,7 @@ extern struct kobject *firmware_kobj;
>>
>> int kobject_uevent(struct kobject *kobj, enum kobject_action action);
>> int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
>> - char *envp[]);
>> + const char * const envp[]);
>> int kobject_synth_uevent(struct kobject *kobj, const char *buf, size_t count);
>>
>> __printf(2, 3)
>> diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
>> index 63d0816ab23b..9107989a0cc8 100644
>> --- a/lib/kobject_uevent.c
>> +++ b/lib/kobject_uevent.c
>> @@ -452,7 +452,7 @@ static void zap_modalias_env(struct kobj_uevent_env *env)
>> * corresponding error when it fails.
>> */
>> int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
>> - char *envp_ext[])
>> + const char * const envp_ext[])
>> {
>> struct kobj_uevent_env *env;
>> const char *action_string = kobject_actions[action];
>
> No objection from me, care to make it a real patch so that I can apply
> it after 4.18-rc1 is out?
For the wireless part:
Acked-by: Kalle Valo <kvalo@codeaurora.org>
--
Kalle Valo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iwlwifi: pcie: make array prop static, shrinks object size
2018-06-11 19:40 ` Joe Perches
@ 2018-06-11 20:45 ` Greg Kroah-Hartman
2018-06-14 14:36 ` Kalle Valo
0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2018-06-11 20:45 UTC (permalink / raw)
To: Joe Perches
Cc: Colin King, Johannes Berg, Emmanuel Grumbach, Luca Coelho,
Intel Linux Wireless, Kalle Valo, David S . Miller,
linux-wireless, netdev, kernel-janitors, linux-kernel
On Mon, Jun 11, 2018 at 12:40:55PM -0700, Joe Perches wrote:
> (adding Greg KH)
>
> On Mon, 2018-06-11 at 18:15 +0100, Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > Don't populate the read-only array 'prop' on the stack but
> > instead make it static. Makes the object code smaller by 20 bytes:
> >
> > Before:
> > text data bss dec hex filename
> > 71659 14614 576 86849 15341 trans.o
> >
> > After:
> > text data bss dec hex filename
> > 71479 14774 576 86829 1532d trans.o
> >
> > (gcc version 7.3.0 x86_64)
> >
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
> > index 7229991ae70d..c4626ebe5da1 100644
> > --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
> > +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
> > @@ -1946,7 +1946,7 @@ static void iwl_trans_pcie_removal_wk(struct work_struct *wk)
> > struct iwl_trans_pcie_removal *removal =
> > container_of(wk, struct iwl_trans_pcie_removal, work);
> > struct pci_dev *pdev = removal->pdev;
> > - char *prop[] = {"EVENT=INACCESSIBLE", NULL};
> > + static char *prop[] = {"EVENT=INACCESSIBLE", NULL};
> >
> > dev_err(&pdev->dev, "Device gone - attempting removal\n");
> > kobject_uevent_env(&pdev->dev.kobj, KOBJ_CHANGE, prop);
>
> Now what is happening is that prop is being reloaded
> each invocation with the constant addresses of the strings.
>
> It seems the prototype and function for kobject_uevent_env
> should change as well to avoid this.
>
> Perhaps this should become:
> ---
> drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 2 +-
> include/linux/kobject.h | 2 +-
> lib/kobject_uevent.c | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
> index 7229991ae70d..6668a8aad22e 100644
> --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
> +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
> @@ -1946,7 +1946,7 @@ static void iwl_trans_pcie_removal_wk(struct work_struct *wk)
> struct iwl_trans_pcie_removal *removal =
> container_of(wk, struct iwl_trans_pcie_removal, work);
> struct pci_dev *pdev = removal->pdev;
> - char *prop[] = {"EVENT=INACCESSIBLE", NULL};
> + static const char * const prop[] = {"EVENT=INACCESSIBLE", NULL};
>
> dev_err(&pdev->dev, "Device gone - attempting removal\n");
> kobject_uevent_env(&pdev->dev.kobj, KOBJ_CHANGE, prop);
> diff --git a/include/linux/kobject.h b/include/linux/kobject.h
> index 7f6f93c3df9c..9f5cf553dd1e 100644
> --- a/include/linux/kobject.h
> +++ b/include/linux/kobject.h
> @@ -217,7 +217,7 @@ extern struct kobject *firmware_kobj;
>
> int kobject_uevent(struct kobject *kobj, enum kobject_action action);
> int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
> - char *envp[]);
> + const char * const envp[]);
> int kobject_synth_uevent(struct kobject *kobj, const char *buf, size_t count);
>
> __printf(2, 3)
> diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
> index 63d0816ab23b..9107989a0cc8 100644
> --- a/lib/kobject_uevent.c
> +++ b/lib/kobject_uevent.c
> @@ -452,7 +452,7 @@ static void zap_modalias_env(struct kobj_uevent_env *env)
> * corresponding error when it fails.
> */
> int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
> - char *envp_ext[])
> + const char * const envp_ext[])
> {
> struct kobj_uevent_env *env;
> const char *action_string = kobject_actions[action];
No objection from me, care to make it a real patch so that I can apply
it after 4.18-rc1 is out?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iwlwifi: pcie: make array prop static, shrinks object size
2018-06-11 17:15 [PATCH] iwlwifi: pcie: make array prop " Colin King
@ 2018-06-11 19:40 ` Joe Perches
2018-06-11 20:45 ` Greg Kroah-Hartman
0 siblings, 1 reply; 6+ messages in thread
From: Joe Perches @ 2018-06-11 19:40 UTC (permalink / raw)
To: Colin King, Greg Kroah-Hartman, Johannes Berg, Emmanuel Grumbach,
Luca Coelho, Intel Linux Wireless, Kalle Valo, David S . Miller,
linux-wireless, netdev
Cc: kernel-janitors, linux-kernel
(adding Greg KH)
On Mon, 2018-06-11 at 18:15 +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Don't populate the read-only array 'prop' on the stack but
> instead make it static. Makes the object code smaller by 20 bytes:
>
> Before:
> text data bss dec hex filename
> 71659 14614 576 86849 15341 trans.o
>
> After:
> text data bss dec hex filename
> 71479 14774 576 86829 1532d trans.o
>
> (gcc version 7.3.0 x86_64)
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
> index 7229991ae70d..c4626ebe5da1 100644
> --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
> +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
> @@ -1946,7 +1946,7 @@ static void iwl_trans_pcie_removal_wk(struct work_struct *wk)
> struct iwl_trans_pcie_removal *removal =
> container_of(wk, struct iwl_trans_pcie_removal, work);
> struct pci_dev *pdev = removal->pdev;
> - char *prop[] = {"EVENT=INACCESSIBLE", NULL};
> + static char *prop[] = {"EVENT=INACCESSIBLE", NULL};
>
> dev_err(&pdev->dev, "Device gone - attempting removal\n");
> kobject_uevent_env(&pdev->dev.kobj, KOBJ_CHANGE, prop);
Now what is happening is that prop is being reloaded
each invocation with the constant addresses of the strings.
It seems the prototype and function for kobject_uevent_env
should change as well to avoid this.
Perhaps this should become:
---
drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 2 +-
include/linux/kobject.h | 2 +-
lib/kobject_uevent.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index 7229991ae70d..6668a8aad22e 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -1946,7 +1946,7 @@ static void iwl_trans_pcie_removal_wk(struct work_struct *wk)
struct iwl_trans_pcie_removal *removal =
container_of(wk, struct iwl_trans_pcie_removal, work);
struct pci_dev *pdev = removal->pdev;
- char *prop[] = {"EVENT=INACCESSIBLE", NULL};
+ static const char * const prop[] = {"EVENT=INACCESSIBLE", NULL};
dev_err(&pdev->dev, "Device gone - attempting removal\n");
kobject_uevent_env(&pdev->dev.kobj, KOBJ_CHANGE, prop);
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 7f6f93c3df9c..9f5cf553dd1e 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -217,7 +217,7 @@ extern struct kobject *firmware_kobj;
int kobject_uevent(struct kobject *kobj, enum kobject_action action);
int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
- char *envp[]);
+ const char * const envp[]);
int kobject_synth_uevent(struct kobject *kobj, const char *buf, size_t count);
__printf(2, 3)
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 63d0816ab23b..9107989a0cc8 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -452,7 +452,7 @@ static void zap_modalias_env(struct kobj_uevent_env *env)
* corresponding error when it fails.
*/
int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
- char *envp_ext[])
+ const char * const envp_ext[])
{
struct kobj_uevent_env *env;
const char *action_string = kobject_actions[action];
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] iwlwifi: pcie: make array prop static, shrinks object size
@ 2018-06-11 17:15 Colin King
2018-06-11 19:40 ` Joe Perches
0 siblings, 1 reply; 6+ messages in thread
From: Colin King @ 2018-06-11 17:15 UTC (permalink / raw)
To: Johannes Berg, Emmanuel Grumbach, Luca Coelho,
Intel Linux Wireless, Kalle Valo, David S . Miller,
linux-wireless, netdev
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Don't populate the read-only array 'prop' on the stack but
instead make it static. Makes the object code smaller by 20 bytes:
Before:
text data bss dec hex filename
71659 14614 576 86849 15341 trans.o
After:
text data bss dec hex filename
71479 14774 576 86829 1532d trans.o
(gcc version 7.3.0 x86_64)
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index 7229991ae70d..c4626ebe5da1 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -1946,7 +1946,7 @@ static void iwl_trans_pcie_removal_wk(struct work_struct *wk)
struct iwl_trans_pcie_removal *removal =
container_of(wk, struct iwl_trans_pcie_removal, work);
struct pci_dev *pdev = removal->pdev;
- char *prop[] = {"EVENT=INACCESSIBLE", NULL};
+ static char *prop[] = {"EVENT=INACCESSIBLE", NULL};
dev_err(&pdev->dev, "Device gone - attempting removal\n");
kobject_uevent_env(&pdev->dev.kobj, KOBJ_CHANGE, prop);
--
2.17.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-09-04 6:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-21 10:21 [PATCH] iwlwifi: pcie: make array 'prop' static, shrinks object size Colin King
2018-09-04 6:07 ` Luciano Coelho
-- strict thread matches above, loose matches on Subject: below --
2018-06-11 17:15 [PATCH] iwlwifi: pcie: make array prop " Colin King
2018-06-11 19:40 ` Joe Perches
2018-06-11 20:45 ` Greg Kroah-Hartman
2018-06-14 14:36 ` Kalle Valo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).