Commit 6b324dbf authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso

ipvs: optimize the use of flags in ip_vs_bind_dest

	cp->flags is marked volatile but ip_vs_bind_dest
can safely modify the flags, so save some CPU cycles by
using temp variable.
Signed-off-by: default avatarJulian Anastasov <ja@ssi.bg>
Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
parent f73181c8
...@@ -548,6 +548,7 @@ static inline void ...@@ -548,6 +548,7 @@ static inline void
ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest) ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
{ {
unsigned int conn_flags; unsigned int conn_flags;
__u32 flags;
/* if dest is NULL, then return directly */ /* if dest is NULL, then return directly */
if (!dest) if (!dest)
...@@ -559,17 +560,19 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest) ...@@ -559,17 +560,19 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
conn_flags = atomic_read(&dest->conn_flags); conn_flags = atomic_read(&dest->conn_flags);
if (cp->protocol != IPPROTO_UDP) if (cp->protocol != IPPROTO_UDP)
conn_flags &= ~IP_VS_CONN_F_ONE_PACKET; conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
flags = cp->flags;
/* Bind with the destination and its corresponding transmitter */ /* Bind with the destination and its corresponding transmitter */
if (cp->flags & IP_VS_CONN_F_SYNC) { if (flags & IP_VS_CONN_F_SYNC) {
/* if the connection is not template and is created /* if the connection is not template and is created
* by sync, preserve the activity flag. * by sync, preserve the activity flag.
*/ */
if (!(cp->flags & IP_VS_CONN_F_TEMPLATE)) if (!(flags & IP_VS_CONN_F_TEMPLATE))
conn_flags &= ~IP_VS_CONN_F_INACTIVE; conn_flags &= ~IP_VS_CONN_F_INACTIVE;
/* connections inherit forwarding method from dest */ /* connections inherit forwarding method from dest */
cp->flags &= ~(IP_VS_CONN_F_FWD_MASK | IP_VS_CONN_F_NOOUTPUT); flags &= ~(IP_VS_CONN_F_FWD_MASK | IP_VS_CONN_F_NOOUTPUT);
} }
cp->flags |= conn_flags; flags |= conn_flags;
cp->flags = flags;
cp->dest = dest; cp->dest = dest;
IP_VS_DBG_BUF(7, "Bind-dest %s c:%s:%d v:%s:%d " IP_VS_DBG_BUF(7, "Bind-dest %s c:%s:%d v:%s:%d "
...@@ -584,12 +587,12 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest) ...@@ -584,12 +587,12 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
atomic_read(&dest->refcnt)); atomic_read(&dest->refcnt));
/* Update the connection counters */ /* Update the connection counters */
if (!(cp->flags & IP_VS_CONN_F_TEMPLATE)) { if (!(flags & IP_VS_CONN_F_TEMPLATE)) {
/* It is a normal connection, so modify the counters /* It is a normal connection, so modify the counters
* according to the flags, later the protocol can * according to the flags, later the protocol can
* update them on state change * update them on state change
*/ */
if (!(cp->flags & IP_VS_CONN_F_INACTIVE)) if (!(flags & IP_VS_CONN_F_INACTIVE))
atomic_inc(&dest->activeconns); atomic_inc(&dest->activeconns);
else else
atomic_inc(&dest->inactconns); atomic_inc(&dest->inactconns);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment