Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jonathan Toppins <jtoppins@redhat.com>
To: Joe Perches <joe@perches.com>, netdev@vger.kernel.org
Cc: Jay Vosburgh <j.vosburgh@gmail.com>,
	Veaceslav Falico <vfalico@gmail.com>,
	Andy Gospodarek <andy@greyhouse.net>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 2/2] bonding: combine netlink and console error messages
Date: Sat, 7 Aug 2021 17:54:24 -0400	[thread overview]
Message-ID: <f519f9eb-aefd-4d0a-01ce-4ed37b7930ef@redhat.com> (raw)
In-Reply-To: <37c7bbbb01ede99974fc9ce3c3f5dad4845df9ee.camel@perches.com>

On 8/6/21 11:52 PM, Joe Perches wrote:
> On Fri, 2021-08-06 at 23:30 -0400, Jonathan Toppins wrote:
>> There seems to be no reason to have different error messages between
>> netlink and printk. It also cleans up the function slightly.
> []
>> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> []
>> +#define BOND_NL_ERR(bond_dev, extack, errmsg) do {		\
>> +	NL_SET_ERR_MSG(extack, errmsg);				\
>> +	netdev_err(bond_dev, "Error: " errmsg "\n");		\
>> +} while (0)
>> +
>> +#define SLAVE_NL_ERR(bond_dev, slave_dev, extack, errmsg) do {	\
>> +	NL_SET_ERR_MSG(extack, errmsg);				\
>> +	slave_err(bond_dev, slave_dev, "Error: " errmsg "\n");	\
>> +} while (0)
> 
> If you are doing this, it's probably smaller object code to use
> 	"%s", errmsg
> as the errmsg string can be reused
> 
> #define BOND_NL_ERR(bond_dev, extack, errmsg)			\
> do {								\
> 	NL_SET_ERR_MSG(extack, errmsg);				\
> 	netdev_err(bond_dev, "Error: %s\n", errmsg);		\
> } while (0)
> 
> #define SLAVE_NL_ERR(bond_dev, slave_dev, extack, errmsg)	\
> do {								\
> 	NL_SET_ERR_MSG(extack, errmsg);				\
> 	slave_err(bond_dev, slave_dev, "Error: %s\n", errmsg);	\
> } while (0)
> 
> 

I like the thought and would agree if not for how NL_SET_ERR_MSG is 
coded. Unfortunately it does not appear as though doing the above change 
actually generates smaller object code. Maybe I have incorrectly 
interpreted something?

$ git show
commit 6bb346263b4e9d008744b45af5105df309c35c1a (HEAD -> 
upstream-bonding-cleanup)
Author: Jonathan Toppins <jtoppins@redhat.com>
Date:   Sat Aug 7 17:34:58 2021 -0400

     object code optimization

diff --git a/drivers/net/bonding/bond_main.c 
b/drivers/net/bonding/bond_main.c
index 46b95175690b..e2903ae7cdab 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1714,12 +1714,12 @@ void bond_lower_state_changed(struct slave *slave)

  #define BOND_NL_ERR(bond_dev, extack, errmsg) do {             \
         NL_SET_ERR_MSG(extack, errmsg);                         \
-       netdev_err(bond_dev, "Error: " errmsg "\n");            \
+       netdev_err(bond_dev, "Error: %s\n", errmsg);            \
  } while (0)

  #define SLAVE_NL_ERR(bond_dev, slave_dev, extack, errmsg) do { \
         NL_SET_ERR_MSG(extack, errmsg);                         \
-       slave_err(bond_dev, slave_dev, "Error: " errmsg "\n");  \
+       slave_err(bond_dev, slave_dev, "Error: %s\n", errmsg);  \
  } while (0)

  /* enslave device <slave> to bond device <master> */
$ git log --oneline -3
6bb346263b4e (HEAD -> upstream-bonding-cleanup) object code optimization
a36c7639a139 bonding: combine netlink and console error messages
88916c847e85 bonding: remove extraneous definitions from bonding.h
jtoppins@jtoppins:~/projects/linux-rhel7$ git rebase -i --exec "make 
drivers/net/bonding/bond_main.o; ls -l drivers/net/bonding/bond_main.o" 
HEAD^^
hint: Waiting for your editor to close the file... Error detected while 
processing 
/home/jtoppins/.vim/bundle/cscope_macros.vim/plugin/cscope_macros.vim:
line   42:
E568: duplicate cscope database not added
Press ENTER or type command to continue
Executing: make menuconfig


*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.

Executing: make drivers/net/bonding/bond_main.o; ls -l 
drivers/net/bonding/bond_main.o
   CALL    scripts/checksyscalls.sh
   CALL    scripts/atomic/check-atomics.sh
   DESCEND objtool
   DESCEND bpf/resolve_btfids
   CC [M]  drivers/net/bonding/bond_main.o
-rw-r--r--. 1 jtoppins jtoppins 1777896 Aug  7 17:37 
drivers/net/bonding/bond_main.o
Executing: make drivers/net/bonding/bond_main.o; ls -l 
drivers/net/bonding/bond_main.o
   CALL    scripts/checksyscalls.sh
   CALL    scripts/atomic/check-atomics.sh
   DESCEND objtool
   DESCEND bpf/resolve_btfids
   CC [M]  drivers/net/bonding/bond_main.o
-rw-r--r--. 1 jtoppins jtoppins 1778320 Aug  7 17:37 
drivers/net/bonding/bond_main.o
Successfully rebased and updated refs/heads/upstream-bonding-cleanup.

It appears the change increases bond_main.o by 424 (1778320-1777896) bytes.


  reply	other threads:[~2021-08-07 22:02 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-07  3:30 [PATCH net-next 0/2] bonding: cleanup header file and error msgs Jonathan Toppins
2021-08-07  3:30 ` [PATCH net-next 1/2] bonding: remove extraneous definitions from bonding.h Jonathan Toppins
2021-08-07  3:30 ` [PATCH net-next 2/2] bonding: combine netlink and console error messages Jonathan Toppins
2021-08-07  3:52   ` Joe Perches
2021-08-07 21:54     ` Jonathan Toppins [this message]
2021-08-08 10:02       ` Joe Perches
2021-08-09  2:07         ` Jonathan Toppins
2021-08-09  5:05           ` Joe Perches
2021-08-09 17:17             ` Jonathan Toppins
2021-08-08 10:16   ` Leon Romanovsky
2021-08-09  1:42     ` Jonathan Toppins
2021-08-09  6:03       ` Leon Romanovsky
2021-08-10  6:40   ` [PATCH net-next v2 " Jonathan Toppins
2021-08-10  6:47     ` Leon Romanovsky
2021-08-11  2:53 ` [PATCH net-next v2 0/2] bonding: cleanup header file and error msgs Jonathan Toppins
2021-08-11  2:53   ` [PATCH net-next v2 1/2] bonding: remove extraneous definitions from bonding.h Jonathan Toppins
2021-08-11  2:53   ` [PATCH net-next v2 2/2] bonding: combine netlink and console error messages Jonathan Toppins
2021-08-11  3:27     ` Joe Perches
2021-08-11 12:49       ` Jakub Kicinski
2021-08-11 13:23         ` Joe Perches
2021-08-11 14:31           ` Jonathan Toppins
2021-08-11 22:10   ` [PATCH net-next v2 0/2] bonding: cleanup header file and error msgs patchwork-bot+netdevbpf

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=f519f9eb-aefd-4d0a-01ce-4ed37b7930ef@redhat.com \
    --to=jtoppins@redhat.com \
    --cc=andy@greyhouse.net \
    --cc=davem@davemloft.net \
    --cc=j.vosburgh@gmail.com \
    --cc=joe@perches.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vfalico@gmail.com \
    --subject='Re: [PATCH net-next 2/2] bonding: combine netlink and console error messages' \
    /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

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).