Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Simon Horman <horms@verge.net.au>

+9 -6
+9 -6
net/netfilter/ipvs/ip_vs_conn.c
··· 548 548 ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest) 549 549 { 550 550 unsigned int conn_flags; 551 + __u32 flags; 551 552 552 553 /* if dest is NULL, then return directly */ 553 554 if (!dest) ··· 560 559 conn_flags = atomic_read(&dest->conn_flags); 561 560 if (cp->protocol != IPPROTO_UDP) 562 561 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET; 562 + flags = cp->flags; 563 563 /* Bind with the destination and its corresponding transmitter */ 564 - if (cp->flags & IP_VS_CONN_F_SYNC) { 564 + if (flags & IP_VS_CONN_F_SYNC) { 565 565 /* if the connection is not template and is created 566 566 * by sync, preserve the activity flag. 567 567 */ 568 - if (!(cp->flags & IP_VS_CONN_F_TEMPLATE)) 568 + if (!(flags & IP_VS_CONN_F_TEMPLATE)) 569 569 conn_flags &= ~IP_VS_CONN_F_INACTIVE; 570 570 /* connections inherit forwarding method from dest */ 571 - cp->flags &= ~(IP_VS_CONN_F_FWD_MASK | IP_VS_CONN_F_NOOUTPUT); 571 + flags &= ~(IP_VS_CONN_F_FWD_MASK | IP_VS_CONN_F_NOOUTPUT); 572 572 } 573 - cp->flags |= conn_flags; 573 + flags |= conn_flags; 574 + cp->flags = flags; 574 575 cp->dest = dest; 575 576 576 577 IP_VS_DBG_BUF(7, "Bind-dest %s c:%s:%d v:%s:%d " ··· 587 584 atomic_read(&dest->refcnt)); 588 585 589 586 /* Update the connection counters */ 590 - if (!(cp->flags & IP_VS_CONN_F_TEMPLATE)) { 587 + if (!(flags & IP_VS_CONN_F_TEMPLATE)) { 591 588 /* It is a normal connection, so modify the counters 592 589 * according to the flags, later the protocol can 593 590 * update them on state change 594 591 */ 595 - if (!(cp->flags & IP_VS_CONN_F_INACTIVE)) 592 + if (!(flags & IP_VS_CONN_F_INACTIVE)) 596 593 atomic_inc(&dest->activeconns); 597 594 else 598 595 atomic_inc(&dest->inactconns);