[PATCH] headers: Add skb_queue_len_lockless()

Hauke Mehrtens <[email protected]>
Newsgroups org.kernel.vger.backports
Message-ID <[email protected]>
This function is copied from the mainline kernel. It was introduced in
commit 86b18aaa2b5b ("skbuff: fix a data race in skb_queue_len()").

This function is now used by ath10k.

Signed-off-by: Hauke Mehrtens <[email protected]>
---
 backport/backport-include/linux/skbuff.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/backport/backport-include/linux/skbuff.h b/backport/backport-include/linux/skbuff.h
index 3286d36c..338f6fdb 100644
--- a/backport/backport-include/linux/skbuff.h
+++ b/backport/backport-include/linux/skbuff.h
@@ -427,4 +427,24 @@ static inline void nf_reset_ct(struct sk_buff *skb)
 	     (skb) = (next_skb), (next_skb) = (skb) ? (skb)->next : NULL)
 #endif
 
+#if LINUX_VERSION_IS_LESS(5,6,0) &&			\
+	!LINUX_VERSION_IN_RANGE(5,4,69, 5,5,0) &&	\
+	!LINUX_VERSION_IN_RANGE(4,19,149, 4,20,0) &&	\
+	!LINUX_VERSION_IN_RANGE(4,14,200, 4,15,0) &&	\
+	!LINUX_VERSION_IN_RANGE(4,9,238, 4,10,0) &&	\
+	!LINUX_VERSION_IN_RANGE(4,4,238, 4,5,0)
+/**
+ *	skb_queue_len_lockless	- get queue length
+ *	@list_: list to measure
+ *
+ *	Return the length of an &sk_buff queue.
+ *	This variant can be used in lockless contexts.
+ */
+#define skb_queue_len_lockless LINUX_BACKPORT(skb_queue_len_lockless)
+static inline __u32 skb_queue_len_lockless(const struct sk_buff_head *list_)
+{
+	return READ_ONCE(list_->qlen);
+}
+#endif /* < 5.6.0 */
+
 #endif /* __BACKPORT_SKBUFF_H */
-- 
2.30.2

--
To unsubscribe from this list: send the line "unsubscribe backports" in
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.