[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM0EoMnk8KB780U=qpv+aqvvJuQX_yWgdx4ESJ64vzuQRwvmLw@mail.gmail.com>
Date: Thu, 28 Aug 2025 23:28:49 -0400
From: Jamal Hadi Salim <jhs@...atatu.com>
To: Eric Dumazet <edumazet@...gle.com>
Cc: "David S . Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
Cong Wang <xiyou.wangcong@...il.com>, Jiri Pirko <jiri@...nulli.us>, netdev@...r.kernel.org,
eric.dumazet@...il.com
Subject: Re: [PATCH net-next 1/4] net_sched: remove BH blocking in eight actions
On Thu, Aug 28, 2025 at 11:26 PM Jamal Hadi Salim <jhs@...atatu.com> wrote:
>
> On Wed, Aug 27, 2025 at 8:53 AM Eric Dumazet <edumazet@...gle.com> wrote:
> >
> > Followup of f45b45cbfae3 ("Merge branch
> > 'net_sched-act-extend-rcu-use-in-dump-methods'")
> >
> > We never grab tcf_lock from BH context in these modules:
> >
> > act_connmark
> > act_csum
> > act_ct
> > act_ctinfo
> > act_mpls
> > act_nat
> > act_pedit
> > act_skbedit
> >
> > No longer block BH when acquiring tcf_lock from init functions.
> >
>
> Brief glance: isnt the lock still held in BH context for some actions
> like pedit and nat (albeit in corner cases)? Both actions call
> tcf_action_update_bstats in their act callbacks.
> i.e if the action instance was not created with percpu stats,
> tcf_action_update_bstats will grab the lock.
>
Testing with lockdep should illustrate this..
cheers,
jamal
> cheers,
> jamal
>
> > Signed-off-by: Eric Dumazet <edumazet@...gle.com>
> > ---
> > net/sched/act_connmark.c | 4 ++--
> > net/sched/act_csum.c | 4 ++--
> > net/sched/act_ct.c | 4 ++--
> > net/sched/act_ctinfo.c | 4 ++--
> > net/sched/act_mpls.c | 4 ++--
> > net/sched/act_nat.c | 4 ++--
> > net/sched/act_pedit.c | 4 ++--
> > net/sched/act_skbedit.c | 4 ++--
> > 8 files changed, 16 insertions(+), 16 deletions(-)
> >
> > diff --git a/net/sched/act_connmark.c b/net/sched/act_connmark.c
> > index 3e89927d711647d75f31c8d80a3ddd102e3d2e36..bf2d6b6da04223e1acaa7e9f5d29d426db06d705 100644
> > --- a/net/sched/act_connmark.c
> > +++ b/net/sched/act_connmark.c
> > @@ -169,10 +169,10 @@ static int tcf_connmark_init(struct net *net, struct nlattr *nla,
> >
> > nparms->action = parm->action;
> >
> > - spin_lock_bh(&ci->tcf_lock);
> > + spin_lock(&ci->tcf_lock);
> > goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
> > oparms = rcu_replace_pointer(ci->parms, nparms, lockdep_is_held(&ci->tcf_lock));
> > - spin_unlock_bh(&ci->tcf_lock);
> > + spin_unlock(&ci->tcf_lock);
> >
> > if (goto_ch)
> > tcf_chain_put_by_act(goto_ch);
> > diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c
> > index 0939e6b2ba4d1947df0f3dcfc09bfaa339a6ace2..8bad91753615a08d78d99086fd6a7ab6e4c8e857 100644
> > --- a/net/sched/act_csum.c
> > +++ b/net/sched/act_csum.c
> > @@ -101,11 +101,11 @@ static int tcf_csum_init(struct net *net, struct nlattr *nla,
> > params_new->update_flags = parm->update_flags;
> > params_new->action = parm->action;
> >
> > - spin_lock_bh(&p->tcf_lock);
> > + spin_lock(&p->tcf_lock);
> > goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
> > params_new = rcu_replace_pointer(p->params, params_new,
> > lockdep_is_held(&p->tcf_lock));
> > - spin_unlock_bh(&p->tcf_lock);
> > + spin_unlock(&p->tcf_lock);
> >
> > if (goto_ch)
> > tcf_chain_put_by_act(goto_ch);
> > diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
> > index 6749a4a9a9cd0a43897fcd20d228721ce057cb88..6d2355e73b0f55750679b48e562e148d2cd8b7d4 100644
> > --- a/net/sched/act_ct.c
> > +++ b/net/sched/act_ct.c
> > @@ -1410,11 +1410,11 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla,
> > goto cleanup;
> >
> > params->action = parm->action;
> > - spin_lock_bh(&c->tcf_lock);
> > + spin_lock(&c->tcf_lock);
> > goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
> > params = rcu_replace_pointer(c->params, params,
> > lockdep_is_held(&c->tcf_lock));
> > - spin_unlock_bh(&c->tcf_lock);
> > + spin_unlock(&c->tcf_lock);
> >
> > if (goto_ch)
> > tcf_chain_put_by_act(goto_ch);
> > diff --git a/net/sched/act_ctinfo.c b/net/sched/act_ctinfo.c
> > index 71efe04d00b5c6195e43f1ea6dab1548f6f97293..6f79eed9a544a49aed35ac0557250a3d5a9fc576 100644
> > --- a/net/sched/act_ctinfo.c
> > +++ b/net/sched/act_ctinfo.c
> > @@ -258,11 +258,11 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla,
> >
> > cp_new->action = actparm->action;
> >
> > - spin_lock_bh(&ci->tcf_lock);
> > + spin_lock(&ci->tcf_lock);
> > goto_ch = tcf_action_set_ctrlact(*a, actparm->action, goto_ch);
> > cp_new = rcu_replace_pointer(ci->params, cp_new,
> > lockdep_is_held(&ci->tcf_lock));
> > - spin_unlock_bh(&ci->tcf_lock);
> > + spin_unlock(&ci->tcf_lock);
> >
> > if (goto_ch)
> > tcf_chain_put_by_act(goto_ch);
> > diff --git a/net/sched/act_mpls.c b/net/sched/act_mpls.c
> > index 6654011dcd2ba30769b2f52078373a834e259f88..ed7bdaa23f0d80caef6bd5cd5b9787e24ff2d1af 100644
> > --- a/net/sched/act_mpls.c
> > +++ b/net/sched/act_mpls.c
> > @@ -296,10 +296,10 @@ static int tcf_mpls_init(struct net *net, struct nlattr *nla,
> > htons(ETH_P_MPLS_UC));
> > p->action = parm->action;
> >
> > - spin_lock_bh(&m->tcf_lock);
> > + spin_lock(&m->tcf_lock);
> > goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
> > p = rcu_replace_pointer(m->mpls_p, p, lockdep_is_held(&m->tcf_lock));
> > - spin_unlock_bh(&m->tcf_lock);
> > + spin_unlock(&m->tcf_lock);
> >
> > if (goto_ch)
> > tcf_chain_put_by_act(goto_ch);
> > diff --git a/net/sched/act_nat.c b/net/sched/act_nat.c
> > index 26241d80ebe03e74a92e951fb5ae065493b93277..9cc2a1772cf8290a4be7d6e694e2ceccd48c386a 100644
> > --- a/net/sched/act_nat.c
> > +++ b/net/sched/act_nat.c
> > @@ -95,10 +95,10 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est,
> >
> > p = to_tcf_nat(*a);
> >
> > - spin_lock_bh(&p->tcf_lock);
> > + spin_lock(&p->tcf_lock);
> > goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
> > oparm = rcu_replace_pointer(p->parms, nparm, lockdep_is_held(&p->tcf_lock));
> > - spin_unlock_bh(&p->tcf_lock);
> > + spin_unlock(&p->tcf_lock);
> >
> > if (goto_ch)
> > tcf_chain_put_by_act(goto_ch);
> > diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
> > index 4b65901397a88864014f74c53d0fa00b40ac6613..8fc8f577cb7a8362fee60cd79cce263edca32a7a 100644
> > --- a/net/sched/act_pedit.c
> > +++ b/net/sched/act_pedit.c
> > @@ -280,10 +280,10 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
> >
> > p = to_pedit(*a);
> > nparms->action = parm->action;
> > - spin_lock_bh(&p->tcf_lock);
> > + spin_lock(&p->tcf_lock);
> > goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
> > oparms = rcu_replace_pointer(p->parms, nparms, 1);
> > - spin_unlock_bh(&p->tcf_lock);
> > + spin_unlock(&p->tcf_lock);
> >
> > if (oparms)
> > call_rcu(&oparms->rcu, tcf_pedit_cleanup_rcu);
> > diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c
> > index 8c1d1554f6575d3b0feae4d26ef4865d44a63e59..aa6b1744de21c1dca223cb87a919dc3e29841b83 100644
> > --- a/net/sched/act_skbedit.c
> > +++ b/net/sched/act_skbedit.c
> > @@ -261,11 +261,11 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
> > params_new->mask = *mask;
> >
> > params_new->action = parm->action;
> > - spin_lock_bh(&d->tcf_lock);
> > + spin_lock(&d->tcf_lock);
> > goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
> > params_new = rcu_replace_pointer(d->params, params_new,
> > lockdep_is_held(&d->tcf_lock));
> > - spin_unlock_bh(&d->tcf_lock);
> > + spin_unlock(&d->tcf_lock);
> > if (params_new)
> > kfree_rcu(params_new, rcu);
> > if (goto_ch)
> > --
> > 2.51.0.261.g7ce5a0a67e-goog
> >
Powered by blists - more mailing lists