Skip to contentSkip to conversation

net/netlink: optimize seq_puts and seq_printf in af_netlink.c

PATCH In review YU Bo 3 participants 4 messages May 3, 2018

Subsystems (3)
lore
Share & tools
lore

YU Bo

author
#0 lore raw

PATCH v2 1/1 net/netlink: optimize seq_puts and seq_printf in af_netlink.c

Before the patch, the command cat /proc/net/netlink will output like:

https://clbin.com/BojZv

After the patch:

https://clbin.com/lnu4L

The optimization will make convenience for using cat /proc/net/netlink But,The checkpatch will give a warning:

WARNING: quoted string split across lines

---
Changes in v2:
Do not break the indentation of the code line

---
 net/netlink/af_netlink.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
net/netlink/af_netlink.c +3 -3
index 55342c4d5cec..2e2dd88fc79f 100644
@@ -2606,13 +2606,13 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
 {
 	if (v = SEQ_START_TOKEN) {
 		seq_puts(seq,
-			 "sk       Eth Pid    Groups   "
-			 "Rmem     Wmem     Dump     Locks     Drops     Inode\n");
+			 "sk               Eth Pid        Groups   "
+			 "Rmem     Wmem     Dump  Locks    Drops    Inode\n");
 	} else {
 		struct sock *s = v;
 		struct netlink_sock *nlk = nlk_sk(s);
 
-		seq_printf(seq, "%pK %-3d %-6u %08x %-8d %-8d %d %-8d %-8d %-8lu\n",
+		seq_printf(seq, "%pK %-3d %-10u %08x %-8d %-8d %-5d %-8d %-8d %-8lu\n",
 			   s,
 			   s->sk_protocol,
 			   nlk->portid,

--
2.11.0

#1 lore raw
Quoted 4 lines · YU Bo

Before the patch, the command cat /proc/net/netlink will output like:

https://clbin.com/BojZv

Quoted 8 lines

After the patch:

https://clbin.com/lnu4L

The optimization will make convenience for using cat /proc/net/netlink But,The checkpatch will give a warning:

WARNING: quoted string split across lines

The interest of the checkpatch warning is that someone may want to grep for something that has actually been split over two lines. If this is not an issue in your case and if there are good reasons for splitting the string, then you can ignore checkpatch.

julia

Quoted 42 lines

---
Changes in v2:
Do not break the indentation of the code line
---
net/netlink/af_netlink.c | 6 +++---

1 file changed, 3 insertions(+), 3 deletions(-)
net/netlink/af_netlink.c +3 -3
index 55342c4d5cec..2e2dd88fc79f 100644
@@ -2606,13 +2606,13 @@ static int netlink_seq_show(struct seq_file *seq, void
 *v)
 {
 	if (v = SEQ_START_TOKEN) {
 		seq_puts(seq,
-			 "sk       Eth Pid    Groups   "
-			 "Rmem     Wmem     Dump     Locks     Drops
 Inode\n");
+			 "sk               Eth Pid        Groups   "
+			 "Rmem     Wmem     Dump  Locks    Drops    Inode\n");
 	} else {
 		struct sock *s = v;
 		struct netlink_sock *nlk = nlk_sk(s);
 
-		seq_printf(seq, "%pK %-3d %-6u %08x %-8d %-8d %d %-8d %-8d
 %-8lu\n",
+		seq_printf(seq, "%pK %-3d %-10u %08x %-8d %-8d %-5d %-8d %-8d

%-8lu\n",

			   s,
			   s->sk_protocol,
			   nlk->portid,

--
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#2 lore raw

Hello,

Quoted 15 lines · Julia Lawall
Quoted 11 lines · YU Bo

Before the patch, the command cat /proc/net/netlink will output like:

https://clbin.com/BojZv

After the patch:

https://clbin.com/lnu4L

The optimization will make convenience for using cat /proc/net/netlink But,The checkpatch will give a warning:

Quoted 6 lines
Quoted 1 line

WARNING: quoted string split across lines

The interest of the checkpatch warning is that someone may want to grep for something that has actually been split over two lines. If this is not an issue in your case and if there are good reasons for splitting the string, then you can ignore checkpatch.

Yes, the warning will be generated in original af_netlink.c and i dom't think to split it is better.

Thank you!

Quoted 45 lines

julia

Quoted 42 lines

---
Changes in v2:
Do not break the indentation of the code line
---
net/netlink/af_netlink.c | 6 +++---

1 file changed, 3 insertions(+), 3 deletions(-)
net/netlink/af_netlink.c +3 -3
index 55342c4d5cec..2e2dd88fc79f 100644
@@ -2606,13 +2606,13 @@ static int netlink_seq_show(struct seq_file *seq, void
 *v)
 {
 	if (v = SEQ_START_TOKEN) {
 		seq_puts(seq,
-			 "sk       Eth Pid    Groups   "
-			 "Rmem     Wmem     Dump     Locks     Drops
 Inode\n");
+			 "sk               Eth Pid        Groups   "
+			 "Rmem     Wmem     Dump  Locks    Drops    Inode\n");
 	} else {
 		struct sock *s = v;
 		struct netlink_sock *nlk = nlk_sk(s);
 
-		seq_printf(seq, "%pK %-3d %-6u %08x %-8d %-8d %d %-8d %-8d
 %-8lu\n",
+		seq_printf(seq, "%pK %-3d %-10u %08x %-8d %-8d %-5d %-8d %-8d

%-8lu\n",

			   s,
			   s->sk_protocol,
			   nlk->portid,

--
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#3 lore raw
In reply to YU Bo

From: YU Bo <[email protected]>
Date: Thu, 3 May 2018 05:09:04 -0400

Quoted 9 lines

Before the patch, the command cat /proc/net/netlink will output like:

https://clbin.com/BojZv

After the patch:

https://clbin.com/lnu4L

Quoted 7 lines

The optimization will make convenience for using cat /proc/net/netlink
But,The checkpatch will give a warning:

WARNING: quoted string split across lines

Please do not reference external web sites for text which explains the change in your commit message.

Simply show the /proc/net/netlink headers and then one line of the output, before and after, in diff style.

Then it will be clear to the reader that you are not "optimizing" anything. This is not an optimization.

You are just making sure the headers line up properly with the actual value output.

Thank you.