Skip to contentSkip to conversation

netdevice: optimise netdev_intersect_features slightly

PATCH In review [email protected] 2 participants 2 messages Dec 19, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netdevice: optimise netdev_intersect_features slightly

From: Li RongQing <[email protected]>

Since f1 and f2 always have NETIF_F_GEN_CSUM when doing Bitwise OR assignment, it is unnecessory to clear NETIF_F_GEN_CSUM from the added data

Cc Michal Kubecek <[email protected]>
---
 include/linux/netdevice.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/netdevice.h +2 -2
index c31f74d..b8facf9 100644
@@ -3542,9 +3542,9 @@ static inline netdev_features_t netdev_intersect_features(netdev_features_t f1,
 							  netdev_features_t f2)
 {
 	if (f1 & NETIF_F_GEN_CSUM)
-		f1 |= (NETIF_F_ALL_CSUM & ~NETIF_F_GEN_CSUM);
+		f1 |= NETIF_F_ALL_CSUM;
 	if (f2 & NETIF_F_GEN_CSUM)
-		f2 |= (NETIF_F_ALL_CSUM & ~NETIF_F_GEN_CSUM);
+		f2 |= NETIF_F_ALL_CSUM;
 	f1 &= f2;
 	if (f1 & NETIF_F_GEN_CSUM)
 		f1 &= ~(NETIF_F_ALL_CSUM & ~NETIF_F_GEN_CSUM);
Signature · 1 line
2.1.0
#1 lore raw
Quoted 17 lines · On Fri, Dec 19, 2014 at 01:21:27PM +0800, [email protected] wrote:

From: Li RongQing <[email protected]>

Since f1 and f2 always have NETIF_F_GEN_CSUM when doing Bitwise OR assignment, it is unnecessory to clear NETIF_F_GEN_CSUM from the added data

Cc Michal Kubecek <[email protected]>
---
 include/linux/netdevice.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/netdevice.h +0 -0
index c31f74d..b8facf9 100644
@@ -3542,9 +3542,9 @@ static inline netdev_features_t netdev_intersect_features(netdev_features_t f1,
 							  netdev_features_t f2)

include/linux/netdevice.h static inline netdev_features_t netdev_intersect_features(netdev_features_t f1, · line 3550

Quoted 10 lines
include/linux/netdevice.h +2 -2
 {
 	if (f1 & NETIF_F_GEN_CSUM)
-		f1 |= (NETIF_F_ALL_CSUM & ~NETIF_F_GEN_CSUM);
+		f1 |= NETIF_F_ALL_CSUM;
 	if (f2 & NETIF_F_GEN_CSUM)
-		f2 |= (NETIF_F_ALL_CSUM & ~NETIF_F_GEN_CSUM);
+		f2 |= NETIF_F_ALL_CSUM;
 	f1 &= f2;
 	if (f1 & NETIF_F_GEN_CSUM)
 		f1 &= ~(NETIF_F_ALL_CSUM & ~NETIF_F_GEN_CSUM);

This is not an optimization in the sense of resulting code as the expression right of "|=" is a constant so the patch just replaces or with one constant by an or with a different one. But the source looks nicer so it may make sense anyway.

However, I will have to take a look at both versions of the resulting code first as we are using the same expression (or its bitwise inverse) later so that current version might be actually slightly more efficient.

Michal Kubecek