Skip to content

Commit 9b6d539

Browse files
JoePerchesdavem330
authored andcommitted
rxrpc: Use pr_<level> and pr_fmt, reduce object size a few KB
Use the more common kernel logging style and reduce object size. The logging message prefix changes from a mixture of "RxRPC:" and "RXRPC:" to "af_rxrpc: ". $ size net/rxrpc/built-in.o* text data bss dec hex filename 64172 1972 8304 74448 122d0 net/rxrpc/built-in.o.new 67512 1972 8304 77788 12fdc net/rxrpc/built-in.o.old Miscellanea: o Consolidate the ASSERT macros to use a single pr_err call with decimal and hexadecimal output and a stringified #OP argument Signed-off-by: Joe Perches <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent cb2911f commit 9b6d539

16 files changed

+56
-34
lines changed

net/rxrpc/af_rxrpc.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* 2 of the License, or (at your option) any later version.
1010
*/
1111

12+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13+
1214
#include <linux/module.h>
1315
#include <linux/kernel.h>
1416
#include <linux/net.h>
@@ -796,49 +798,49 @@ static int __init af_rxrpc_init(void)
796798
"rxrpc_call_jar", sizeof(struct rxrpc_call), 0,
797799
SLAB_HWCACHE_ALIGN, NULL);
798800
if (!rxrpc_call_jar) {
799-
printk(KERN_NOTICE "RxRPC: Failed to allocate call jar\n");
801+
pr_notice("Failed to allocate call jar\n");
800802
goto error_call_jar;
801803
}
802804

803805
rxrpc_workqueue = alloc_workqueue("krxrpcd", 0, 1);
804806
if (!rxrpc_workqueue) {
805-
printk(KERN_NOTICE "RxRPC: Failed to allocate work queue\n");
807+
pr_notice("Failed to allocate work queue\n");
806808
goto error_work_queue;
807809
}
808810

809811
ret = rxrpc_init_security();
810812
if (ret < 0) {
811-
printk(KERN_CRIT "RxRPC: Cannot initialise security\n");
813+
pr_crit("Cannot initialise security\n");
812814
goto error_security;
813815
}
814816

815817
ret = proto_register(&rxrpc_proto, 1);
816818
if (ret < 0) {
817-
printk(KERN_CRIT "RxRPC: Cannot register protocol\n");
819+
pr_crit("Cannot register protocol\n");
818820
goto error_proto;
819821
}
820822

821823
ret = sock_register(&rxrpc_family_ops);
822824
if (ret < 0) {
823-
printk(KERN_CRIT "RxRPC: Cannot register socket family\n");
825+
pr_crit("Cannot register socket family\n");
824826
goto error_sock;
825827
}
826828

827829
ret = register_key_type(&key_type_rxrpc);
828830
if (ret < 0) {
829-
printk(KERN_CRIT "RxRPC: Cannot register client key type\n");
831+
pr_crit("Cannot register client key type\n");
830832
goto error_key_type;
831833
}
832834

833835
ret = register_key_type(&key_type_rxrpc_s);
834836
if (ret < 0) {
835-
printk(KERN_CRIT "RxRPC: Cannot register server key type\n");
837+
pr_crit("Cannot register server key type\n");
836838
goto error_key_type_s;
837839
}
838840

839841
ret = rxrpc_sysctl_init();
840842
if (ret < 0) {
841-
printk(KERN_CRIT "RxRPC: Cannot register sysctls\n");
843+
pr_crit("Cannot register sysctls\n");
842844
goto error_sysctls;
843845
}
844846

net/rxrpc/ar-accept.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* 2 of the License, or (at your option) any later version.
1010
*/
1111

12+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13+
1214
#include <linux/module.h>
1315
#include <linux/net.h>
1416
#include <linux/skbuff.h>

net/rxrpc/ar-ack.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* 2 of the License, or (at your option) any later version.
1010
*/
1111

12+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13+
1214
#include <linux/module.h>
1315
#include <linux/circ_buf.h>
1416
#include <linux/net.h>

net/rxrpc/ar-call.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* 2 of the License, or (at your option) any later version.
1010
*/
1111

12+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13+
1214
#include <linux/slab.h>
1315
#include <linux/module.h>
1416
#include <linux/circ_buf.h>
@@ -669,8 +671,7 @@ void rxrpc_release_call(struct rxrpc_call *call)
669671
conn->channels[3] == NULL);
670672
break;
671673
default:
672-
printk(KERN_ERR "RxRPC: conn->avail_calls=%d\n",
673-
conn->avail_calls);
674+
pr_err("conn->avail_calls=%d\n", conn->avail_calls);
674675
BUG();
675676
}
676677
}
@@ -935,16 +936,15 @@ void __exit rxrpc_destroy_all_calls(void)
935936
if (call->state != RXRPC_CALL_DEAD)
936937
break;
937938
default:
938-
printk(KERN_ERR "RXRPC:"
939-
" Call %p still in use (%d,%d,%s,%lx,%lx)!\n",
939+
pr_err("Call %p still in use (%d,%d,%s,%lx,%lx)!\n",
940940
call, atomic_read(&call->usage),
941941
atomic_read(&call->ackr_not_idle),
942942
rxrpc_call_states[call->state],
943943
call->flags, call->events);
944944
if (!skb_queue_empty(&call->rx_queue))
945-
printk(KERN_ERR"RXRPC: Rx queue occupied\n");
945+
pr_err("Rx queue occupied\n");
946946
if (!skb_queue_empty(&call->rx_oos_queue))
947-
printk(KERN_ERR"RXRPC: OOS queue occupied\n");
947+
pr_err("OOS queue occupied\n");
948948
break;
949949
}
950950

net/rxrpc/ar-connection.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* 2 of the License, or (at your option) any later version.
1010
*/
1111

12+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13+
1214
#include <linux/module.h>
1315
#include <linux/slab.h>
1416
#include <linux/net.h>

net/rxrpc/ar-connevent.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* 2 of the License, or (at your option) any later version.
1010
*/
1111

12+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13+
1214
#include <linux/module.h>
1315
#include <linux/net.h>
1416
#include <linux/skbuff.h>

net/rxrpc/ar-input.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* 2 of the License, or (at your option) any later version.
1010
*/
1111

12+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13+
1214
#include <linux/module.h>
1315
#include <linux/net.h>
1416
#include <linux/skbuff.h>

net/rxrpc/ar-internal.h

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -744,43 +744,37 @@ do { \
744744
#define ASSERT(X) \
745745
do { \
746746
if (unlikely(!(X))) { \
747-
printk(KERN_ERR "\n"); \
748-
printk(KERN_ERR "RxRPC: Assertion failed\n"); \
747+
pr_err("Assertion failed\n"); \
749748
BUG(); \
750749
} \
751750
} while (0)
752751

753752
#define ASSERTCMP(X, OP, Y) \
754753
do { \
755-
if (unlikely(!((X) OP (Y)))) { \
756-
printk(KERN_ERR "\n"); \
757-
printk(KERN_ERR "RxRPC: Assertion failed\n"); \
758-
printk(KERN_ERR "%lu " #OP " %lu is false\n", \
759-
(unsigned long)(X), (unsigned long)(Y)); \
760-
printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \
761-
(unsigned long)(X), (unsigned long)(Y)); \
754+
unsigned long _x = (unsigned long)(X); \
755+
unsigned long _y = (unsigned long)(Y); \
756+
if (unlikely(!(_x OP _y))) { \
757+
pr_err("Assertion failed - %lu(0x%lx) %s %lu(0x%lx) is false\n", \
758+
_x, _x, #OP, _y, _y); \
762759
BUG(); \
763760
} \
764761
} while (0)
765762

766763
#define ASSERTIF(C, X) \
767764
do { \
768765
if (unlikely((C) && !(X))) { \
769-
printk(KERN_ERR "\n"); \
770-
printk(KERN_ERR "RxRPC: Assertion failed\n"); \
766+
pr_err("Assertion failed\n"); \
771767
BUG(); \
772768
} \
773769
} while (0)
774770

775771
#define ASSERTIFCMP(C, X, OP, Y) \
776772
do { \
777-
if (unlikely((C) && !((X) OP (Y)))) { \
778-
printk(KERN_ERR "\n"); \
779-
printk(KERN_ERR "RxRPC: Assertion failed\n"); \
780-
printk(KERN_ERR "%lu " #OP " %lu is false\n", \
781-
(unsigned long)(X), (unsigned long)(Y)); \
782-
printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \
783-
(unsigned long)(X), (unsigned long)(Y)); \
773+
unsigned long _x = (unsigned long)(X); \
774+
unsigned long _y = (unsigned long)(Y); \
775+
if (unlikely((C) && !(_x OP _y))) { \
776+
pr_err("Assertion failed - %lu(0x%lx) %s %lu(0x%lx) is false\n", \
777+
_x, _x, #OP, _y, _y); \
784778
BUG(); \
785779
} \
786780
} while (0)

net/rxrpc/ar-key.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
1313
*/
1414

15+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
16+
1517
#include <crypto/skcipher.h>
1618
#include <linux/module.h>
1719
#include <linux/net.h>
@@ -800,7 +802,7 @@ static void rxrpc_free_token_list(struct rxrpc_key_token *token)
800802
rxrpc_rxk5_free(token->k5);
801803
break;
802804
default:
803-
printk(KERN_ERR "Unknown token type %x on rxrpc key\n",
805+
pr_err("Unknown token type %x on rxrpc key\n",
804806
token->security_index);
805807
BUG();
806808
}

net/rxrpc/ar-local.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* 2 of the License, or (at your option) any later version.
1010
*/
1111

12+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13+
1214
#include <linux/module.h>
1315
#include <linux/net.h>
1416
#include <linux/skbuff.h>

net/rxrpc/ar-output.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* 2 of the License, or (at your option) any later version.
1010
*/
1111

12+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13+
1214
#include <linux/net.h>
1315
#include <linux/gfp.h>
1416
#include <linux/skbuff.h>

net/rxrpc/ar-peer.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* 2 of the License, or (at your option) any later version.
1010
*/
1111

12+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13+
1214
#include <linux/module.h>
1315
#include <linux/net.h>
1416
#include <linux/skbuff.h>

net/rxrpc/ar-recvmsg.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* 2 of the License, or (at your option) any later version.
1010
*/
1111

12+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13+
1214
#include <linux/net.h>
1315
#include <linux/skbuff.h>
1416
#include <linux/export.h>
@@ -307,7 +309,7 @@ int rxrpc_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
307309
&abort_code);
308310
break;
309311
default:
310-
pr_err("RxRPC: Unknown packet mark %u\n", skb->mark);
312+
pr_err("Unknown packet mark %u\n", skb->mark);
311313
BUG();
312314
break;
313315
}

net/rxrpc/ar-skbuff.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* 2 of the License, or (at your option) any later version.
1010
*/
1111

12+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13+
1214
#include <linux/module.h>
1315
#include <linux/net.h>
1416
#include <linux/skbuff.h>

net/rxrpc/ar-transport.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* 2 of the License, or (at your option) any later version.
1010
*/
1111

12+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13+
1214
#include <linux/module.h>
1315
#include <linux/net.h>
1416
#include <linux/skbuff.h>

net/rxrpc/rxkad.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* 2 of the License, or (at your option) any later version.
1010
*/
1111

12+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13+
1214
#include <crypto/skcipher.h>
1315
#include <linux/module.h>
1416
#include <linux/net.h>

0 commit comments

Comments
 (0)