From patchwork Tue Mar 26 19:24:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 10872109 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35C7E15AC for ; Tue, 26 Mar 2019 19:24:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1934328BE7 for ; Tue, 26 Mar 2019 19:24:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0CFE828DB1; Tue, 26 Mar 2019 19:24:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F214628D01 for ; Tue, 26 Mar 2019 19:24:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728314AbfCZTYb (ORCPT ); Tue, 26 Mar 2019 15:24:31 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:42214 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729693AbfCZTYb (ORCPT ); Tue, 26 Mar 2019 15:24:31 -0400 Received: by mail-pl1-f194.google.com with SMTP id cv12so2099533plb.9 for ; Tue, 26 Mar 2019 12:24:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cBJLe6/JGplG+Cy8Q3/cMVi7Shc7ruJGMSA1cWOMVqY=; b=WIyBizMngixWEhCS5V1bN1IbboWlbBa/zzrPjtzcGpBAqm9dDvsYykZKnRKho5FZvm waFLFVy194hEvmK7je9hxoDmUOzvW8fiSsEkt+sz2wr9ghG5955KLCCx49DjcgSR9E3z m0cbfO0jiIvx7ys5FH0c4R6IZ/KvKyvBD6wfc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cBJLe6/JGplG+Cy8Q3/cMVi7Shc7ruJGMSA1cWOMVqY=; b=iXsNU7oQMxL+WL0YSMLuPDX0NkPRZip7NPYTA6qxtmJLKrfq9OC5rrvn+1Yxncw+El tlPAO80yTACrYqL68t/aFRvehZDw/wddoyuP6gIrRs+3sUqNqqkCxv24DrtmNMdQmZrM 5ItJ+hDXE9Zh3whbMB/yPY2JGoxY50BUcuZy5tdDAE8St7Uws++/9S7N937knHKPayCw MDy3h9a6S2plW0ajc7a5sRkpVwyg1Q5BbZBjN/3guEN8XhK6Gzxb2Ui+mU44RqB//hRs 8t7is7b7NwUtzut2a0SsPoDVdre6i82prmTrcIaCeJhHF29UwuyTVL1PBqBTgqePSdL7 dgbQ== X-Gm-Message-State: APjAAAVfaRSgbXnSVDOBr5ELkosDHYZcd9oIeRuh1aGYgJig1gyLp8Sy z5FHc7Pwm/yuovJMS4GLYoxwCw== X-Google-Smtp-Source: APXvYqypEKPXcoQJgDVy5MvfSX2VsoZ1x9Ur4x5YtgQwDWYTEU/kZATCqD9coRmyBcoDdt/Dx7aYRw== X-Received: by 2002:a17:902:20e5:: with SMTP id v34mr33077657plg.319.1553628270382; Tue, 26 Mar 2019 12:24:30 -0700 (PDT) Received: from joelaf.cam.corp.google.com ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id l12sm36761889pgn.83.2019.03.26.12.24.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Mar 2019 12:24:29 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , Steven Rostedt , kernel-team@android.com, rcu@vger.kernel.org, byungchul.park@lge.com, Ingo Molnar , Josh Triplett , Lai Jiangshan , linux-kselftest@vger.kernel.org, Mathieu Desnoyers , "Paul E. McKenney" , Peter Zijlstra , Shuah Khan , Will Deacon Subject: [PATCH v2 1/4] lockdep: Add assertion to check if in an interrupt Date: Tue, 26 Mar 2019 15:24:08 -0400 Message-Id: <20190326192411.198070-1-joel@joelfernandes.org> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In rcu_rrupt_from_idle, we want to check if it is called from within an interrupt, but want to do such checking only for debug builds. lockdep already tracks when we enter an interrupt. Let us expose it as an assertion macro so it can be used to assert this. Suggested-by: Steven Rostedt Cc: kernel-team@android.com Cc: rcu@vger.kernel.org Signed-off-by: Joel Fernandes (Google) --- include/linux/lockdep.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index c5335df2372f..d24f564823d3 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -601,11 +601,18 @@ do { \ "IRQs not disabled as expected\n"); \ } while (0) +#define lockdep_assert_in_irq() do { \ + WARN_ONCE(debug_locks && !current->lockdep_recursion && \ + !current->hardirq_context, \ + "Not in hardirq 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_irq() do { } while (0) #endif #ifdef CONFIG_LOCKDEP