From patchwork Fri May 4 17:51:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 908939 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linutronix.de Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40d03950GNz9s3Z for ; Sat, 5 May 2018 03:52:37 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751933AbeEDRwd (ORCPT ); Fri, 4 May 2018 13:52:33 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:42374 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751814AbeEDRwI (ORCPT ); Fri, 4 May 2018 13:52:08 -0400 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1fEes6-0000Yf-Us; Fri, 04 May 2018 19:51:55 +0200 From: Sebastian Andrzej Siewior To: linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, Peter Zijlstra , Ingo Molnar , "David S. Miller" , Johannes Berg , Alexander Aring , Stefan Schmidt , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-wpan@vger.kernel.org, Anna-Maria Gleixner , Sebastian Andrzej Siewior Subject: [RFC PATCH 1/2] lockdep: Add a assert_in_softirq() Date: Fri, 4 May 2018 19:51:43 +0200 Message-Id: <20180504175144.12179-2-bigeasy@linutronix.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504175144.12179-1-bigeasy@linutronix.de> References: <20180504175144.12179-1-bigeasy@linutronix.de> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Anna-Maria Gleixner Instead of directly warn on wrong context, check if softirq context is set. This check could be a nop on RT. Signed-off-by: Anna-Maria Gleixner Signed-off-by: Sebastian Andrzej Siewior --- include/linux/lockdep.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 6fc77d4dbdcd..59363c3047c6 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -608,11 +608,17 @@ do { \ "IRQs not disabled as expected\n"); \ } while (0) +#define lockdep_assert_in_softirq() do { \ + WARN_ONCE(debug_locks && !current->lockdep_recursion && \ + !current->softirq_context, \ + "Not in softirq context as expected\n"); \ + } while (0) #else # define might_lock(lock) do { } while (0) # define might_lock_read(lock) do { } while (0) # define lockdep_assert_irqs_enabled() do { } while (0) # define lockdep_assert_irqs_disabled() do { } while (0) +# define lockdep_assert_in_softirq() do { } while (0) #endif #ifdef CONFIG_LOCKDEP From patchwork Fri May 4 17:51:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 908940 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linutronix.de Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40d03p5q1vz9s3G for ; Sat, 5 May 2018 03:53:10 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751809AbeEDRwH (ORCPT ); Fri, 4 May 2018 13:52:07 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:42369 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751492AbeEDRwF (ORCPT ); Fri, 4 May 2018 13:52:05 -0400 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1fEes7-0000Yf-GU; Fri, 04 May 2018 19:51:55 +0200 From: Sebastian Andrzej Siewior To: linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, Peter Zijlstra , Ingo Molnar , "David S. Miller" , Johannes Berg , Alexander Aring , Stefan Schmidt , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-wpan@vger.kernel.org, Anna-Maria Gleixner , Sebastian Andrzej Siewior Subject: [RFC PATCH 2/2] net: mac808211: mac802154: use lockdep_assert_in_softirq() instead own warning Date: Fri, 4 May 2018 19:51:44 +0200 Message-Id: <20180504175144.12179-3-bigeasy@linutronix.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504175144.12179-1-bigeasy@linutronix.de> References: <20180504175144.12179-1-bigeasy@linutronix.de> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Anna-Maria Gleixner The warning in ieee802154_rx() and ieee80211_rx_napi() is there to ensure the softirq context for the subsequent netif_receive_skb() call. The check could be moved into the netif_receive_skb() function to prevent all calling functions implement the checks on their own. Use the lockdep variant for softirq context check. While at it, add a lockdep based check for irq enabled as mentioned in the comment above netif_receive_skb(). Signed-off-by: Anna-Maria Gleixner Signed-off-by: Sebastian Andrzej Siewior --- net/core/dev.c | 3 +++ net/mac80211/rx.c | 2 -- net/mac802154/rx.c | 2 -- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index af0558b00c6c..7b4b8611cc21 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4750,6 +4750,9 @@ static int netif_receive_skb_internal(struct sk_buff *skb) */ int netif_receive_skb(struct sk_buff *skb) { + lockdep_assert_irqs_enabled(); + lockdep_assert_in_softirq(); + trace_netif_receive_skb_entry(skb); return netif_receive_skb_internal(skb); diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 03102aff0953..653332d81c17 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -4324,8 +4324,6 @@ void ieee80211_rx_napi(struct ieee80211_hw *hw, struct ieee80211_sta *pubsta, struct ieee80211_supported_band *sband; struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); - WARN_ON_ONCE(softirq_count() == 0); - if (WARN_ON(status->band >= NUM_NL80211_BANDS)) goto drop; diff --git a/net/mac802154/rx.c b/net/mac802154/rx.c index 4dcf6e18563a..66916c270efc 100644 --- a/net/mac802154/rx.c +++ b/net/mac802154/rx.c @@ -258,8 +258,6 @@ void ieee802154_rx(struct ieee802154_local *local, struct sk_buff *skb) { u16 crc; - WARN_ON_ONCE(softirq_count() == 0); - if (local->suspended) goto drop;