2020-11-16 08:04:56

by Yejune Deng

[permalink] [raw]
Subject: [PATCH] ipvs: replace atomic_add_return()

atomic_inc_return() looks better

Signed-off-by: Yejune Deng <[email protected]>
---
net/netfilter/ipvs/ip_vs_core.c | 2 +-
net/netfilter/ipvs/ip_vs_sync.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index c0b8215..54e086c 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -2137,7 +2137,7 @@ static int ip_vs_in_icmp_v6(struct netns_ipvs *ipvs, struct sk_buff *skb,
if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
pkts = sysctl_sync_threshold(ipvs);
else
- pkts = atomic_add_return(1, &cp->in_pkts);
+ pkts = atomic_inc_return(&cp->in_pkts);

if (ipvs->sync_state & IP_VS_STATE_MASTER)
ip_vs_sync_conn(ipvs, cp, pkts);
diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
index 16b4806..9d43277 100644
--- a/net/netfilter/ipvs/ip_vs_sync.c
+++ b/net/netfilter/ipvs/ip_vs_sync.c
@@ -615,7 +615,7 @@ static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp,
cp = cp->control;
if (cp) {
if (cp->flags & IP_VS_CONN_F_TEMPLATE)
- pkts = atomic_add_return(1, &cp->in_pkts);
+ pkts = atomic_inc_return(&cp->in_pkts);
else
pkts = sysctl_sync_threshold(ipvs);
ip_vs_sync_conn(ipvs, cp, pkts);
@@ -776,7 +776,7 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)
if (!cp)
return;
if (cp->flags & IP_VS_CONN_F_TEMPLATE)
- pkts = atomic_add_return(1, &cp->in_pkts);
+ pkts = atomic_inc_return(&cp->in_pkts);
else
pkts = sysctl_sync_threshold(ipvs);
goto sloop;
--
1.9.1


2020-11-17 21:04:17

by Julian Anastasov

[permalink] [raw]
Subject: Re: [PATCH] ipvs: replace atomic_add_return()


Hello,

On Mon, 16 Nov 2020, Yejune Deng wrote:

> atomic_inc_return() looks better
>
> Signed-off-by: Yejune Deng <[email protected]>

Looks good to me for -next, thanks!

Acked-by: Julian Anastasov <[email protected]>

> ---
> net/netfilter/ipvs/ip_vs_core.c | 2 +-
> net/netfilter/ipvs/ip_vs_sync.c | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
> index c0b8215..54e086c 100644
> --- a/net/netfilter/ipvs/ip_vs_core.c
> +++ b/net/netfilter/ipvs/ip_vs_core.c
> @@ -2137,7 +2137,7 @@ static int ip_vs_in_icmp_v6(struct netns_ipvs *ipvs, struct sk_buff *skb,
> if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
> pkts = sysctl_sync_threshold(ipvs);
> else
> - pkts = atomic_add_return(1, &cp->in_pkts);
> + pkts = atomic_inc_return(&cp->in_pkts);
>
> if (ipvs->sync_state & IP_VS_STATE_MASTER)
> ip_vs_sync_conn(ipvs, cp, pkts);
> diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
> index 16b4806..9d43277 100644
> --- a/net/netfilter/ipvs/ip_vs_sync.c
> +++ b/net/netfilter/ipvs/ip_vs_sync.c
> @@ -615,7 +615,7 @@ static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp,
> cp = cp->control;
> if (cp) {
> if (cp->flags & IP_VS_CONN_F_TEMPLATE)
> - pkts = atomic_add_return(1, &cp->in_pkts);
> + pkts = atomic_inc_return(&cp->in_pkts);
> else
> pkts = sysctl_sync_threshold(ipvs);
> ip_vs_sync_conn(ipvs, cp, pkts);
> @@ -776,7 +776,7 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)
> if (!cp)
> return;
> if (cp->flags & IP_VS_CONN_F_TEMPLATE)
> - pkts = atomic_add_return(1, &cp->in_pkts);
> + pkts = atomic_inc_return(&cp->in_pkts);
> else
> pkts = sysctl_sync_threshold(ipvs);
> goto sloop;
> --
> 1.9.1

Regards

--
Julian Anastasov <[email protected]>

2020-11-22 12:50:23

by Pablo Neira Ayuso

[permalink] [raw]
Subject: Re: [PATCH] ipvs: replace atomic_add_return()

On Tue, Nov 17, 2020 at 10:57:52PM +0200, Julian Anastasov wrote:
>
> Hello,
>
> On Mon, 16 Nov 2020, Yejune Deng wrote:
>
> > atomic_inc_return() looks better
> >
> > Signed-off-by: Yejune Deng <[email protected]>
>
> Looks good to me for -next, thanks!
>
> Acked-by: Julian Anastasov <[email protected]>

Applied, thanks.