summaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorVlad Buslov <vladbu@mellanox.com>2019-10-30 16:09:04 +0200
committerDavid S. Miller <davem@davemloft.net>2019-10-30 18:07:50 -0700
commit5e174d5e73dfbfb2c4bc4804f58f2f2aa34c9281 (patch)
tree2d4d59cc6776d57a2253be73813889229709dd71 /include/net
parentef816f3c49c1c404ababc50e10d4cbe5109da678 (diff)
downloadlinux-stable-5e174d5e73dfbfb2c4bc4804f58f2f2aa34c9281.tar.gz
linux-stable-5e174d5e73dfbfb2c4bc4804f58f2f2aa34c9281.tar.bz2
linux-stable-5e174d5e73dfbfb2c4bc4804f58f2f2aa34c9281.zip
net: sched: modify stats helper functions to support regular stats
Modify stats update helper functions introduced in previous patches in this series to fallback to regular tc_action->tcfa_{b|q}stats if cpu stats are not allocated for the action argument. If regular non-percpu allocated counters are in use, then obtain action tcfa_lock while modifying them. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/act_api.h30
1 files changed, 21 insertions, 9 deletions
diff --git a/include/net/act_api.h b/include/net/act_api.h
index 8d6861ce205b..a56477051dae 100644
--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -190,23 +190,35 @@ int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int);
static inline void tcf_action_update_bstats(struct tc_action *a,
struct sk_buff *skb)
{
- bstats_cpu_update(this_cpu_ptr(a->cpu_bstats), skb);
-}
-
-static inline struct gnet_stats_queue *
-tcf_action_get_qstats(struct tc_action *a)
-{
- return this_cpu_ptr(a->cpu_qstats);
+ if (likely(a->cpu_bstats)) {
+ bstats_cpu_update(this_cpu_ptr(a->cpu_bstats), skb);
+ return;
+ }
+ spin_lock(&a->tcfa_lock);
+ bstats_update(&a->tcfa_bstats, skb);
+ spin_unlock(&a->tcfa_lock);
}
static inline void tcf_action_inc_drop_qstats(struct tc_action *a)
{
- qstats_drop_inc(this_cpu_ptr(a->cpu_qstats));
+ if (likely(a->cpu_qstats)) {
+ qstats_drop_inc(this_cpu_ptr(a->cpu_qstats));
+ return;
+ }
+ spin_lock(&a->tcfa_lock);
+ qstats_drop_inc(&a->tcfa_qstats);
+ spin_unlock(&a->tcfa_lock);
}
static inline void tcf_action_inc_overlimit_qstats(struct tc_action *a)
{
- qstats_overlimit_inc(this_cpu_ptr(a->cpu_qstats));
+ if (likely(a->cpu_qstats)) {
+ qstats_overlimit_inc(this_cpu_ptr(a->cpu_qstats));
+ return;
+ }
+ spin_lock(&a->tcfa_lock);
+ qstats_overlimit_inc(&a->tcfa_qstats);
+ spin_unlock(&a->tcfa_lock);
}
void tcf_action_update_stats(struct tc_action *a, u64 bytes, u32 packets,