* [PATCH net-next v3] net: sched: act_gact: use acquire/release for tcfg_ptype
@ 2026-09-02 7:16 Jinjie Ruan
2026-09-02 14:19 ` Jamal Hadi Salim
2026-09-05 20:42 ` Jakub Kicinski
0 siblings, 2 replies; 3+ messages in thread
From: Jinjie Ruan @ 2026-09-02 7:16 UTC (permalink / raw)
To: jhs, jiri, davem, edumazet, kuba, pabeni, horms, netdev, linux-kernel
Cc: ruanjinjie
Replace the smp_wmb()/smp_rmb() barrier pair with
smp_store_release()/smp_load_acquire() on gact->tcfg_ptype.
tcf_gact_init() publishes tcfg_ptype via release after writing
tcfg_pval/tcfg_paction; tcf_gact_act() acquires it before
dispatching to gact_net_rand()/gact_determ(), ensuring the probability
parameters are visible.
No functional change intended.
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>
Assisted-by: DeepSeek:DeepSeek-V3
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
v3:
- Split out from following patch set as Kuniyuki suggested.
Link: https://lore.kernel.org/all/20260901024234.135119-1-ruanjinjie@huawei.com/
---
net/sched/act_gact.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c
index 565860cccba6..d4f39f98e2cf 100644
--- a/net/sched/act_gact.c
+++ b/net/sched/act_gact.c
@@ -25,7 +25,6 @@ static struct tc_action_ops act_gact_ops;
#ifdef CONFIG_GACT_PROB
static int gact_net_rand(struct tcf_gact *gact)
{
- smp_rmb(); /* coupled with smp_wmb() in tcf_gact_init() */
if (get_random_u32_below(gact->tcfg_pval))
return gact->tcf_action;
return gact->tcfg_paction;
@@ -35,7 +34,6 @@ static int gact_determ(struct tcf_gact *gact)
{
u32 pack = atomic_inc_return(&gact->packets);
- smp_rmb(); /* coupled with smp_wmb() in tcf_gact_init() */
if (pack % gact->tcfg_pval)
return gact->tcf_action;
return gact->tcfg_paction;
@@ -133,11 +131,8 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla,
if (p_parm) {
gact->tcfg_paction = p_parm->paction;
gact->tcfg_pval = max_t(u16, 1, p_parm->pval);
- /* Make sure tcfg_pval is written before tcfg_ptype
- * coupled with smp_rmb() in gact_net_rand() & gact_determ()
- */
- smp_wmb();
- gact->tcfg_ptype = p_parm->ptype;
+ /* Pairs with smp_load_acquire() in tcf_gact_act(). */
+ smp_store_release(&gact->tcfg_ptype, p_parm->ptype);
}
#endif
spin_unlock_bh(&gact->tcf_lock);
@@ -160,7 +155,8 @@ TC_INDIRECT_SCOPE int tcf_gact_act(struct sk_buff *skb,
#ifdef CONFIG_GACT_PROB
{
- u32 ptype = READ_ONCE(gact->tcfg_ptype);
+ /* Pairs with smp_store_release() in tcf_gact_init() */
+ u32 ptype = smp_load_acquire(&gact->tcfg_ptype);
if (ptype)
action = gact_rand[ptype](gact);
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next v3] net: sched: act_gact: use acquire/release for tcfg_ptype
2026-09-02 7:16 [PATCH net-next v3] net: sched: act_gact: use acquire/release for tcfg_ptype Jinjie Ruan
@ 2026-09-02 14:19 ` Jamal Hadi Salim
2026-09-05 20:42 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Jamal Hadi Salim @ 2026-09-02 14:19 UTC (permalink / raw)
To: Jinjie Ruan
Cc: jiri, davem, edumazet, kuba, pabeni, horms, netdev, linux-kernel
On Wed, Sep 2, 2026 at 3:16 AM Jinjie Ruan <ruanjinjie@huawei.com> wrote:
>
> Replace the smp_wmb()/smp_rmb() barrier pair with
> smp_store_release()/smp_load_acquire() on gact->tcfg_ptype.
> tcf_gact_init() publishes tcfg_ptype via release after writing
> tcfg_pval/tcfg_paction; tcf_gact_act() acquires it before
> dispatching to gact_net_rand()/gact_determ(), ensuring the probability
> parameters are visible.
>
> No functional change intended.
>
> Cc: Jamal Hadi Salim <jhs@mojatatu.com>
> Cc: Jiri Pirko <jiri@resnulli.us>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Simon Horman <horms@kernel.org>
> Assisted-by: DeepSeek:DeepSeek-V3
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
cheers,
jamal
> ---
> v3:
> - Split out from following patch set as Kuniyuki suggested.
> Link: https://lore.kernel.org/all/20260901024234.135119-1-ruanjinjie@huawei.com/
> ---
> net/sched/act_gact.c | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c
> index 565860cccba6..d4f39f98e2cf 100644
> --- a/net/sched/act_gact.c
> +++ b/net/sched/act_gact.c
> @@ -25,7 +25,6 @@ static struct tc_action_ops act_gact_ops;
> #ifdef CONFIG_GACT_PROB
> static int gact_net_rand(struct tcf_gact *gact)
> {
> - smp_rmb(); /* coupled with smp_wmb() in tcf_gact_init() */
> if (get_random_u32_below(gact->tcfg_pval))
> return gact->tcf_action;
> return gact->tcfg_paction;
> @@ -35,7 +34,6 @@ static int gact_determ(struct tcf_gact *gact)
> {
> u32 pack = atomic_inc_return(&gact->packets);
>
> - smp_rmb(); /* coupled with smp_wmb() in tcf_gact_init() */
> if (pack % gact->tcfg_pval)
> return gact->tcf_action;
> return gact->tcfg_paction;
> @@ -133,11 +131,8 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla,
> if (p_parm) {
> gact->tcfg_paction = p_parm->paction;
> gact->tcfg_pval = max_t(u16, 1, p_parm->pval);
> - /* Make sure tcfg_pval is written before tcfg_ptype
> - * coupled with smp_rmb() in gact_net_rand() & gact_determ()
> - */
> - smp_wmb();
> - gact->tcfg_ptype = p_parm->ptype;
> + /* Pairs with smp_load_acquire() in tcf_gact_act(). */
> + smp_store_release(&gact->tcfg_ptype, p_parm->ptype);
> }
> #endif
> spin_unlock_bh(&gact->tcf_lock);
> @@ -160,7 +155,8 @@ TC_INDIRECT_SCOPE int tcf_gact_act(struct sk_buff *skb,
>
> #ifdef CONFIG_GACT_PROB
> {
> - u32 ptype = READ_ONCE(gact->tcfg_ptype);
> + /* Pairs with smp_store_release() in tcf_gact_init() */
> + u32 ptype = smp_load_acquire(&gact->tcfg_ptype);
>
> if (ptype)
> action = gact_rand[ptype](gact);
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next v3] net: sched: act_gact: use acquire/release for tcfg_ptype
2026-09-02 7:16 [PATCH net-next v3] net: sched: act_gact: use acquire/release for tcfg_ptype Jinjie Ruan
2026-09-02 14:19 ` Jamal Hadi Salim
@ 2026-09-05 20:42 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2026-09-05 20:42 UTC (permalink / raw)
To: Jinjie Ruan
Cc: jhs, jiri, davem, edumazet, pabeni, horms, netdev, linux-kernel
On Wed, 2 Sep 2026 15:16:59 +0800 Jinjie Ruan wrote:
> @@ -160,7 +155,8 @@ TC_INDIRECT_SCOPE int tcf_gact_act(struct sk_buff *skb,
>
> #ifdef CONFIG_GACT_PROB
> {
> - u32 ptype = READ_ONCE(gact->tcfg_ptype);
> + /* Pairs with smp_store_release() in tcf_gact_init() */
> + u32 ptype = smp_load_acquire(&gact->tcfg_ptype);
>
> if (ptype)
> action = gact_rand[ptype](gact);
Clashiko points out that you are turning what used to be a conditional
barrier into one that's always obeyed, even if ptype is 0.
--
pw-bot: cr
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-05 20:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-02 7:16 [PATCH net-next v3] net: sched: act_gact: use acquire/release for tcfg_ptype Jinjie Ruan
2026-09-02 14:19 ` Jamal Hadi Salim
2026-09-05 20:42 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®