diff mbox

[net-next] core: remove old parameter for __dst_destroy_metrics_generic

Message ID 1388136405-25019-1-git-send-email-roy.qing.li@gmail.com
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

Li RongQing Dec. 27, 2013, 9:26 a.m. UTC
From: Li RongQing <roy.qing.li@gmail.com>

when call __dst_destroy_metrics_generic, we always know who old is, so
do not need to pass it.

Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
---
 include/net/dst.h |    7 +++----
 net/core/dst.c    |    5 +++--
 2 files changed, 6 insertions(+), 6 deletions(-)

Comments

David Miller Dec. 27, 2013, 5:08 p.m. UTC | #1
From: roy.qing.li@gmail.com
Date: Fri, 27 Dec 2013 17:26:45 +0800

> From: Li RongQing <roy.qing.li@gmail.com>
> 
> when call __dst_destroy_metrics_generic, we always know who old is, so
> do not need to pass it.
> 
> Signed-off-by: Li RongQing <roy.qing.li@gmail.com>

It's a parameter so that we pass it in a register, rather than having the
caller and the function both have to perform a memory operation and load
the value.

It's an optimization.

I'm not applying this, sorry.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/net/dst.h b/include/net/dst.h
index 77eb53f..7c86f3e 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -119,13 +119,12 @@  static inline bool dst_metrics_read_only(const struct dst_entry *dst)
 	return dst->_metrics & DST_METRICS_READ_ONLY;
 }
 
-void __dst_destroy_metrics_generic(struct dst_entry *dst, unsigned long old);
+void __dst_destroy_metrics_generic(struct dst_entry *dst);
 
 static inline void dst_destroy_metrics_generic(struct dst_entry *dst)
 {
-	unsigned long val = dst->_metrics;
-	if (!(val & DST_METRICS_READ_ONLY))
-		__dst_destroy_metrics_generic(dst, val);
+	if (!dst_metrics_read_only(dst))
+		__dst_destroy_metrics_generic(dst);
 }
 
 static inline u32 *dst_metrics_write_ptr(struct dst_entry *dst)
diff --git a/net/core/dst.c b/net/core/dst.c
index ca4231e..f1875ee 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -308,10 +308,11 @@  u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old)
 EXPORT_SYMBOL(dst_cow_metrics_generic);
 
 /* Caller asserts that dst_metrics_read_only(dst) is false.  */
-void __dst_destroy_metrics_generic(struct dst_entry *dst, unsigned long old)
+void __dst_destroy_metrics_generic(struct dst_entry *dst)
 {
-	unsigned long prev, new;
+	unsigned long prev, new, old;
 
+	old = dst->_metrics;
 	new = ((unsigned long) dst_default_metrics) | DST_METRICS_READ_ONLY;
 	prev = cmpxchg(&dst->_metrics, old, new);
 	if (prev == old)