mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] net/ipv6: Remove unnecessary pr_debug() logs
@ 2024-01-08 19:12 Breno Leitao
  2024-01-08 19:12 ` [PATCH net-next 2/2] net/ipv6: resolve warning in ip6_fib.c Breno Leitao
  2024-01-08 19:20 ` [PATCH net-next 1/2] net/ipv6: Remove unnecessary pr_debug() logs David Ahern
  0 siblings, 2 replies; 3+ messages in thread
From: Breno Leitao @ 2024-01-08 19:12 UTC (permalink / raw)
  To: dsahern, weiwan, kuba, David S. Miller, Eric Dumazet, Paolo Abeni
  Cc: leit, open list:NETWORKING [IPv4/IPv6], open list

In the ipv6 system, we have some logs basically dumping the name of the
function that is being called. This is not ideal, since ftrace give it
to us "for free". Moreover, checkpatch is not happy when touching that
code:

	WARNING: Unnecessary ftrace-like logging - prefer using ftrace

Remove debug functions that only print the current function name.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 net/ipv6/ip6_fib.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 4fc2cae0d116..fb41bec6b4b5 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -751,8 +751,6 @@ static struct fib6_node *fib6_add_1(struct net *net,
 	int	bit;
 	__be32	dir = 0;
 
-	RT6_TRACE("fib6_add_1\n");
-
 	/* insert node in tree */
 
 	fn = root;
@@ -1905,8 +1903,6 @@ static void fib6_del_route(struct fib6_table *table, struct fib6_node *fn,
 	struct net *net = info->nl_net;
 	bool notify_del = false;
 
-	RT6_TRACE("fib6_del_route\n");
-
 	/* If the deleted route is the first in the node and it is not part of
 	 * a multipath route, then we need to replace it with the next route
 	 * in the node, if exists.
-- 
2.39.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH net-next 2/2] net/ipv6: resolve warning in ip6_fib.c
  2024-01-08 19:12 [PATCH net-next 1/2] net/ipv6: Remove unnecessary pr_debug() logs Breno Leitao
@ 2024-01-08 19:12 ` Breno Leitao
  2024-01-08 19:20 ` [PATCH net-next 1/2] net/ipv6: Remove unnecessary pr_debug() logs David Ahern
  1 sibling, 0 replies; 3+ messages in thread
From: Breno Leitao @ 2024-01-08 19:12 UTC (permalink / raw)
  To: dsahern, weiwan, kuba, David S. Miller, Eric Dumazet, Paolo Abeni
  Cc: leit, open list:NETWORKING [IPv4/IPv6], open list

In some configurations, the 'iter' variable in function
fib6_repair_tree() is unused, resulting the following warning when
compiled with W=1.

    net/ipv6/ip6_fib.c:1781:6: warning: variable 'iter' set but not used [-Wunused-but-set-variable]
     1781 |         int iter = 0;
	  |             ^

It is unclear what is the advantage of this RT6_TRACE() macro[1], since
users can control pr_debug() in runtime, which is better than at
compilation time. Moreover, pr_debug() has no overhead when disabled.

Remove the RT6_TRACE() in favor of simple pr_debug() helpers.

[1] Link: https://lore.kernel.org/all/ZZwSEJv2HgI0cD4J@gmail.com/
Signed-off-by: Breno Leitao <leitao@debian.org>
---
 include/net/ip6_fib.h |  6 ------
 net/ipv6/ip6_fib.c    | 15 +++++++++------
 net/ipv6/route.c      |  8 ++++----
 3 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 9ba6413fd2e3..360b12e61850 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -30,12 +30,6 @@
 
 #define RT6_DEBUG 2
 
-#if RT6_DEBUG >= 3
-#define RT6_TRACE(x...) pr_debug(x)
-#else
-#define RT6_TRACE(x...) do { ; } while (0)
-#endif
-
 struct rt6_info;
 struct fib6_info;
 
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index fb41bec6b4b5..38a0348b1d17 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -1801,7 +1801,7 @@ static struct fib6_node *fib6_repair_tree(struct net *net,
 					    lockdep_is_held(&table->tb6_lock));
 		struct fib6_info *new_fn_leaf;
 
-		RT6_TRACE("fixing tree: plen=%d iter=%d\n", fn->fn_bit, iter);
+		pr_debug("fixing tree: plen=%d iter=%d\n", fn->fn_bit, iter);
 		iter++;
 
 		WARN_ON(fn->fn_flags & RTN_RTINFO);
@@ -1864,7 +1864,8 @@ static struct fib6_node *fib6_repair_tree(struct net *net,
 		FOR_WALKERS(net, w) {
 			if (!child) {
 				if (w->node == fn) {
-					RT6_TRACE("W %p adjusted by delnode 1, s=%d/%d\n", w, w->state, nstate);
+					pr_debug("W %p adjusted by delnode 1, s=%d/%d\n",
+						 w, w->state, nstate);
 					w->node = pn;
 					w->state = nstate;
 				}
@@ -1872,10 +1873,12 @@ static struct fib6_node *fib6_repair_tree(struct net *net,
 				if (w->node == fn) {
 					w->node = child;
 					if (children&2) {
-						RT6_TRACE("W %p adjusted by delnode 2, s=%d\n", w, w->state);
+						pr_debug("W %p adjusted by delnode 2, s=%d\n",
+							 w, w->state);
 						w->state = w->state >= FWS_R ? FWS_U : FWS_INIT;
 					} else {
-						RT6_TRACE("W %p adjusted by delnode 2, s=%d\n", w, w->state);
+						pr_debug("W %p adjusted by delnode 2, s=%d\n",
+							 w, w->state);
 						w->state = w->state >= FWS_C ? FWS_U : FWS_INIT;
 					}
 				}
@@ -1951,7 +1954,7 @@ static void fib6_del_route(struct fib6_table *table, struct fib6_node *fn,
 	read_lock(&net->ipv6.fib6_walker_lock);
 	FOR_WALKERS(net, w) {
 		if (w->state == FWS_C && w->leaf == rt) {
-			RT6_TRACE("walker %p adjusted by delroute\n", w);
+			pr_debug("walker %p adjusted by delroute\n", w);
 			w->leaf = rcu_dereference_protected(rt->fib6_next,
 					    lockdep_is_held(&table->tb6_lock));
 			if (!w->leaf)
@@ -2289,7 +2292,7 @@ static int fib6_age(struct fib6_info *rt, void *arg)
 
 	if (rt->fib6_flags & RTF_EXPIRES && rt->expires) {
 		if (time_after(now, rt->expires)) {
-			RT6_TRACE("expiring %p\n", rt);
+			pr_debug("expiring %p\n", rt);
 			return -1;
 		}
 		gc_args->more++;
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index ea1dec8448fc..63b4c6056582 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2085,12 +2085,12 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
 	 */
 	if (!(rt->rt6i_flags & RTF_EXPIRES)) {
 		if (time_after_eq(now, rt->dst.lastuse + gc_args->timeout)) {
-			RT6_TRACE("aging clone %p\n", rt);
+			pr_debug("aging clone %p\n", rt);
 			rt6_remove_exception(bucket, rt6_ex);
 			return;
 		}
 	} else if (time_after(jiffies, rt->dst.expires)) {
-		RT6_TRACE("purging expired route %p\n", rt);
+		pr_debug("purging expired route %p\n", rt);
 		rt6_remove_exception(bucket, rt6_ex);
 		return;
 	}
@@ -2101,8 +2101,8 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
 		neigh = __ipv6_neigh_lookup_noref(rt->dst.dev, &rt->rt6i_gateway);
 
 		if (!(neigh && (neigh->flags & NTF_ROUTER))) {
-			RT6_TRACE("purging route %p via non-router but gateway\n",
-				  rt);
+			pr_debug("purging route %p via non-router but gateway\n",
+				 rt);
 			rt6_remove_exception(bucket, rt6_ex);
 			return;
 		}
-- 
2.39.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next 1/2] net/ipv6: Remove unnecessary pr_debug() logs
  2024-01-08 19:12 [PATCH net-next 1/2] net/ipv6: Remove unnecessary pr_debug() logs Breno Leitao
  2024-01-08 19:12 ` [PATCH net-next 2/2] net/ipv6: resolve warning in ip6_fib.c Breno Leitao
@ 2024-01-08 19:20 ` David Ahern
  1 sibling, 0 replies; 3+ messages in thread
From: David Ahern @ 2024-01-08 19:20 UTC (permalink / raw)
  To: Breno Leitao, weiwan, kuba, David S. Miller, Eric Dumazet, Paolo Abeni
  Cc: leit, open list:NETWORKING [IPv4/IPv6], open list

On 1/8/24 12:12 PM, Breno Leitao wrote:
> In the ipv6 system, we have some logs basically dumping the name of the
> function that is being called. This is not ideal, since ftrace give it
> to us "for free". Moreover, checkpatch is not happy when touching that
> code:
> 
> 	WARNING: Unnecessary ftrace-like logging - prefer using ftrace
> 
> Remove debug functions that only print the current function name.
> 
> Signed-off-by: Breno Leitao <leitao@debian.org>
> ---
>  net/ipv6/ip6_fib.c | 4 ----
>  1 file changed, 4 deletions(-)
> 

net-next is currently closed; repost in 2 weeks once it is re-opened.
You can add this to both patches:

Reviewed-by: David Ahern <dsahern@kernel.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-01-08 19:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-08 19:12 [PATCH net-next 1/2] net/ipv6: Remove unnecessary pr_debug() logs Breno Leitao
2024-01-08 19:12 ` [PATCH net-next 2/2] net/ipv6: resolve warning in ip6_fib.c Breno Leitao
2024-01-08 19:20 ` [PATCH net-next 1/2] net/ipv6: Remove unnecessary pr_debug() logs David Ahern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®