Thread (22 messages) flat view 22 messages, 5 authors, 2021-08-11

Re: [PATCH net-next 2/2] bonding: combine netlink and console error messages

From: Jonathan Toppins <hidden>
Date: 2021-08-07 22:02:13
Also in: lkml

On 8/6/21 11:52 PM, Joe Perches wrote:
On Fri, 2021-08-06 at 23:30 -0400, Jonathan Toppins wrote:
quoted
There seems to be no reason to have different error messages between
netlink and printk. It also cleans up the function slightly.
[]
quoted
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
[]
quoted
+#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 [off-list ref]
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help