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

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.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents b5094a3b 6454eca8
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -594,6 +594,16 @@ do { \
		      this_cpu_read(hardirqs_enabled)));		\
} 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
# define might_lock(lock) do { } while (0)
# define might_lock_read(lock) do { } while (0)
@@ -605,6 +615,7 @@ do { \

# define lockdep_assert_preemption_enabled() do { } while (0)
# define lockdep_assert_preemption_disabled() do { } while (0)
# define lockdep_assert_in_softirq() do { } while (0)
#endif

#ifdef CONFIG_PROVE_RAW_LOCK_NESTING
+2 −0
Original line number Diff line number Diff line
@@ -902,6 +902,8 @@ void napi_consume_skb(struct sk_buff *skb, int budget)
		return;
	}

	lockdep_assert_in_softirq();

	if (!skb_unref(skb))
		return;