aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/sch_htb.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2014-03-05 13:14:34 -0500
committerDavid S. Miller <davem@davemloft.net>2014-03-06 17:24:54 -0500
commit6f542efcbc74801eb4bfa0dbba64c2df6811b2d3 (patch)
treede599fdf0df82a87994f7c4c91e11acf3885614d /net/sched/sch_htb.c
parente86800f9201d35b6b2aac1583a9bf9e3a0b0c70d (diff)
net_sched: htb: do not acquire qdisc lock in dump operations
htb_dump() and htb_dump_class() do not strictly need to acquire qdisc lock to fetch qdisc and/or class parameters. We hold RTNL and no changes can occur. This reduces by 50% qdisc lock pressure while doing tc qdisc|class dump operations. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/sch_htb.c')
-rw-r--r--net/sched/sch_htb.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 722e137df244..9f949abcacef 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -1062,12 +1062,13 @@ static int htb_init(struct Qdisc *sch, struct nlattr *opt)
1062 1062
1063static int htb_dump(struct Qdisc *sch, struct sk_buff *skb) 1063static int htb_dump(struct Qdisc *sch, struct sk_buff *skb)
1064{ 1064{
1065 spinlock_t *root_lock = qdisc_root_sleeping_lock(sch);
1066 struct htb_sched *q = qdisc_priv(sch); 1065 struct htb_sched *q = qdisc_priv(sch);
1067 struct nlattr *nest; 1066 struct nlattr *nest;
1068 struct tc_htb_glob gopt; 1067 struct tc_htb_glob gopt;
1069 1068
1070 spin_lock_bh(root_lock); 1069 /* Its safe to not acquire qdisc lock. As we hold RTNL,
1070 * no change can happen on the qdisc parameters.
1071 */
1071 1072
1072 gopt.direct_pkts = q->direct_pkts; 1073 gopt.direct_pkts = q->direct_pkts;
1073 gopt.version = HTB_VER; 1074 gopt.version = HTB_VER;
@@ -1081,13 +1082,10 @@ static int htb_dump(struct Qdisc *sch, struct sk_buff *skb)
1081 if (nla_put(skb, TCA_HTB_INIT, sizeof(gopt), &gopt) || 1082 if (nla_put(skb, TCA_HTB_INIT, sizeof(gopt), &gopt) ||
1082 nla_put_u32(skb, TCA_HTB_DIRECT_QLEN, q->direct_qlen)) 1083 nla_put_u32(skb, TCA_HTB_DIRECT_QLEN, q->direct_qlen))
1083 goto nla_put_failure; 1084 goto nla_put_failure;
1084 nla_nest_end(skb, nest);
1085 1085
1086 spin_unlock_bh(root_lock); 1086 return nla_nest_end(skb, nest);
1087 return skb->len;
1088 1087
1089nla_put_failure: 1088nla_put_failure:
1090 spin_unlock_bh(root_lock);
1091 nla_nest_cancel(skb, nest); 1089 nla_nest_cancel(skb, nest);
1092 return -1; 1090 return -1;
1093} 1091}
@@ -1096,11 +1094,12 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg,
1096 struct sk_buff *skb, struct tcmsg *tcm) 1094 struct sk_buff *skb, struct tcmsg *tcm)
1097{ 1095{
1098 struct htb_class *cl = (struct htb_class *)arg; 1096 struct htb_class *cl = (struct htb_class *)arg;
1099 spinlock_t *root_lock = qdisc_root_sleeping_lock(sch);
1100 struct nlattr *nest; 1097 struct nlattr *nest;
1101 struct tc_htb_opt opt; 1098 struct tc_htb_opt opt;
1102 1099
1103 spin_lock_bh(root_lock); 1100 /* Its safe to not acquire qdisc lock. As we hold RTNL,
1101 * no change can happen on the class parameters.
1102 */
1104 tcm->tcm_parent = cl->parent ? cl->parent->common.classid : TC_H_ROOT; 1103 tcm->tcm_parent = cl->parent ? cl->parent->common.classid : TC_H_ROOT;
1105 tcm->tcm_handle = cl->common.classid; 1104 tcm->tcm_handle = cl->common.classid;
1106 if (!cl->level && cl->un.leaf.q) 1105 if (!cl->level && cl->un.leaf.q)
@@ -1128,12 +1127,9 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg,
1128 nla_put_u64(skb, TCA_HTB_CEIL64, cl->ceil.rate_bytes_ps)) 1127 nla_put_u64(skb, TCA_HTB_CEIL64, cl->ceil.rate_bytes_ps))
1129 goto nla_put_failure; 1128 goto nla_put_failure;
1130 1129
1131 nla_nest_end(skb, nest); 1130 return nla_nest_end(skb, nest);
1132 spin_unlock_bh(root_lock);
1133 return skb->len;
1134 1131
1135nla_put_failure: 1132nla_put_failure:
1136 spin_unlock_bh(root_lock);
1137 nla_nest_cancel(skb, nest); 1133 nla_nest_cancel(skb, nest);
1138 return -1; 1134 return -1;
1139} 1135}