From patchwork Mon Jun 11 19:40:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 10458727 X-Patchwork-Delegate: luca@coelho.fi Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AE27B60467 for ; Mon, 11 Jun 2018 19:41:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E8AF2856E for ; Mon, 11 Jun 2018 19:41:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9339E2859F; Mon, 11 Jun 2018 19:41:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30DF52856E for ; Mon, 11 Jun 2018 19:41:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934282AbeFKTlC (ORCPT ); Mon, 11 Jun 2018 15:41:02 -0400 Received: from smtprelay0228.hostedemail.com ([216.40.44.228]:33274 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934043AbeFKTlA (ORCPT ); Mon, 11 Jun 2018 15:41:00 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay04.hostedemail.com (Postfix) with ESMTP id 6D116180A8CA0; Mon, 11 Jun 2018 19:40:59 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: skate82_8574120f0109 X-Filterd-Recvd-Size: 4877 Received: from XPS-9350.home (unknown [47.151.150.235]) (Authenticated sender: joe@perches.com) by omf12.hostedemail.com (Postfix) with ESMTPA; Mon, 11 Jun 2018 19:40:57 +0000 (UTC) Message-ID: <7f508dccf95cff7fb8e083666b8939c58f65f894.camel@perches.com> Subject: Re: [PATCH] iwlwifi: pcie: make array prop static, shrinks object size From: Joe Perches To: Colin King , Greg Kroah-Hartman , Johannes Berg , Emmanuel Grumbach , Luca Coelho , Intel Linux Wireless , Kalle Valo , "David S . Miller" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 11 Jun 2018 12:40:55 -0700 In-Reply-To: <20180611171537.14597-1-colin.king@canonical.com> References: <20180611171537.14597-1-colin.king@canonical.com> X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP (adding Greg KH) On Mon, 2018-06-11 at 18:15 +0100, Colin King wrote: > From: Colin Ian King > > 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 > --- > 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: Acked-by: Kalle Valo --- 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];