summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVlad Buslov <vladbu@mellanox.com>2018-09-24 19:22:52 +0300
committerDavid S. Miller <davem@davemloft.net>2018-09-26 06:17:35 +0300
commit9d7e82cec35c027756ec97e274f878251f271181 (patch)
treefb145dfeb6ebfe3f7053d25dfa5134eb915298a7 /include
parent3a7d0d07a386716b459b00783b11a8211cefcc0f (diff)
downloadlinux-9d7e82cec35c027756ec97e274f878251f271181.tar.xz
net: sched: add helper function to take reference to Qdisc
Implement function to take reference to Qdisc that relies on rcu read lock instead of rtnl mutex. Function only takes reference to Qdisc if reference counter isn't zero. Intended to be used by unlocked cls API. 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')
-rw-r--r--include/net/sch_generic.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 091b40c198ff..43b17f82d8ee 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -115,6 +115,19 @@ static inline void qdisc_refcount_inc(struct Qdisc *qdisc)
refcount_inc(&qdisc->refcnt);
}
+/* Intended to be used by unlocked users, when concurrent qdisc release is
+ * possible.
+ */
+
+static inline struct Qdisc *qdisc_refcount_inc_nz(struct Qdisc *qdisc)
+{
+ if (qdisc->flags & TCQ_F_BUILTIN)
+ return qdisc;
+ if (refcount_inc_not_zero(&qdisc->refcnt))
+ return qdisc;
+ return NULL;
+}
+
static inline bool qdisc_is_running(struct Qdisc *qdisc)
{
if (qdisc->flags & TCQ_F_NOLOCK)