Skip to content

Commit 9b0d444

Browse files
jpirkodavem330
authored andcommitted
net: sched: avoid atomic swap in tcf_exts_change
tcf_exts_change is always called on newly created exts, which are not used on fastpath. Therefore, simple struct copy is enough. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 705c709 commit 9b0d444

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

include/net/pkt_cls.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,7 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp,
201201
struct nlattr **tb, struct nlattr *rate_tlv,
202202
struct tcf_exts *exts, bool ovr);
203203
void tcf_exts_destroy(struct tcf_exts *exts);
204-
void tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst,
205-
struct tcf_exts *src);
204+
void tcf_exts_change(struct tcf_exts *dst, struct tcf_exts *src);
206205
int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts);
207206
int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts);
208207
int tcf_exts_get_dev(struct net_device *dev, struct tcf_exts *exts,

net/sched/cls_api.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -883,18 +883,12 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb,
883883
}
884884
EXPORT_SYMBOL(tcf_exts_validate);
885885

886-
void tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst,
887-
struct tcf_exts *src)
886+
void tcf_exts_change(struct tcf_exts *dst, struct tcf_exts *src)
888887
{
889888
#ifdef CONFIG_NET_CLS_ACT
890889
struct tcf_exts old = *dst;
891890

892-
tcf_tree_lock(tp);
893-
dst->nr_actions = src->nr_actions;
894-
dst->actions = src->actions;
895-
dst->type = src->type;
896-
tcf_tree_unlock(tp);
897-
891+
*dst = *src;
898892
tcf_exts_destroy(&old);
899893
#endif
900894
}

net/sched/cls_rsvp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ static int rsvp_change(struct net *net, struct sk_buff *in_skb,
518518
tcf_bind_filter(tp, &n->res, base);
519519
}
520520

521-
tcf_exts_change(tp, &n->exts, &e);
521+
tcf_exts_change(&n->exts, &e);
522522
rsvp_replace(tp, n, handle);
523523
return 0;
524524
}
@@ -591,7 +591,7 @@ static int rsvp_change(struct net *net, struct sk_buff *in_skb,
591591
if (f->tunnelhdr == 0)
592592
tcf_bind_filter(tp, &f->res, base);
593593

594-
tcf_exts_change(tp, &f->exts, &e);
594+
tcf_exts_change(&f->exts, &e);
595595

596596
fp = &s->ht[h2];
597597
for (nfp = rtnl_dereference(*fp); nfp;

net/sched/cls_tcindex.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,9 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
419419
}
420420

421421
if (old_r)
422-
tcf_exts_change(tp, &r->exts, &e);
422+
tcf_exts_change(&r->exts, &e);
423423
else
424-
tcf_exts_change(tp, &cr.exts, &e);
424+
tcf_exts_change(&cr.exts, &e);
425425

426426
if (old_r && old_r != r) {
427427
err = tcindex_filter_result_init(old_r);
@@ -439,7 +439,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
439439
struct tcindex_filter *nfp;
440440
struct tcindex_filter __rcu **fp;
441441

442-
tcf_exts_change(tp, &f->result.exts, &r->exts);
442+
tcf_exts_change(&f->result.exts, &r->exts);
443443

444444
fp = cp->h + (handle % cp->hash);
445445
for (nfp = rtnl_dereference(*fp);

0 commit comments

Comments
 (0)