From patchwork Fri May 4 17:51:42 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: 908938 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 40d0366fqKz9s3G for ; Sat, 5 May 2018 03:52:34 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751845AbeEDRwI (ORCPT ); Fri, 4 May 2018 13:52:08 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:42370 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751558AbeEDRwF (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 1fEes6-0000Yf-C4; Fri, 04 May 2018 19:51:54 +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 Subject: [RFC PATCH 0/2] Introduce assert_in_softirq() Date: Fri, 4 May 2018 19:51:42 +0200 Message-Id: <20180504175144.12179-1-bigeasy@linutronix.de> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org ieee80211_rx_napi() has a check to ensure that it is invoked in softirq context / with BH disabled. It is there because it invokes netif_receive_skb() which has this requirement. On -RT this check does not work as expected so there is always this warning. Tree wide there are two users of this check: ieee80211_rx_napi() and ieee802154_rx(). This approach introduces assert_in_softirq() which does the check if lockdep is enabled. This check could then become a nop on -RT. As an alternative netif_receive_skb() (or ieee80211_rx_napi() could do local_bh_disable() / local_bh_enable() unconditionally. The _disable() part is very cheap. The _enable() part is more expensive because it includes a function call. We could avoid that jump in the likely case when BH was already disabled by something like: static inline void local_bh_enable(void) { if (softirq_count() == SOFTIRQ_DISABLE_OFFSET) __local_bh_enable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET); else preempt_count_sub(SOFTIRQ_DISABLE_OFFSET); } Which would make bh_enable() cheaper for everyone. Sebastian