Commit 0e1f1cc8 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'add-an-assert-in-napi_consume_skb'

Yunsheng Lin says:

====================
Add an assert in napi_consume_skb()

This patch introduces a lockdep_assert_in_softirq() interface and
uses it to assert the case when napi_consume_skb() is not called in
the softirq context.
====================

Link: https://lore.kernel.org/r/1606214969-97849-1-git-send-email-linyunsheng@huawei.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents b5094a3b 6454eca8
...@@ -594,6 +594,16 @@ do { \ ...@@ -594,6 +594,16 @@ do { \
this_cpu_read(hardirqs_enabled))); \ this_cpu_read(hardirqs_enabled))); \
} while (0) } while (0)
/*
* Acceptable for protecting per-CPU resources accessed from BH.
* Much like in_softirq() - semantics are ambiguous, use carefully.
*/
#define lockdep_assert_in_softirq() \
do { \
WARN_ON_ONCE(__lockdep_enabled && \
(!in_softirq() || in_irq() || in_nmi())); \
} while (0)
#else #else
# define might_lock(lock) do { } while (0) # define might_lock(lock) do { } while (0)
# define might_lock_read(lock) do { } while (0) # define might_lock_read(lock) do { } while (0)
...@@ -605,6 +615,7 @@ do { \ ...@@ -605,6 +615,7 @@ do { \
# define lockdep_assert_preemption_enabled() do { } while (0) # define lockdep_assert_preemption_enabled() do { } while (0)
# define lockdep_assert_preemption_disabled() do { } while (0) # define lockdep_assert_preemption_disabled() do { } while (0)
# define lockdep_assert_in_softirq() do { } while (0)
#endif #endif
#ifdef CONFIG_PROVE_RAW_LOCK_NESTING #ifdef CONFIG_PROVE_RAW_LOCK_NESTING
......
...@@ -902,6 +902,8 @@ void napi_consume_skb(struct sk_buff *skb, int budget) ...@@ -902,6 +902,8 @@ void napi_consume_skb(struct sk_buff *skb, int budget)
return; return;
} }
lockdep_assert_in_softirq();
if (!skb_unref(skb)) if (!skb_unref(skb))
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment