Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2025692imm; Thu, 21 Jun 2018 06:09:56 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL4LcsuUHesJMRwplpcLA6j39W1JQGREyIBnJOZXYghjfdKbxxWtuPKRS/LUlc2jzrzd7p1 X-Received: by 2002:a65:4809:: with SMTP id h9-v6mr22669074pgs.258.1529586596601; Thu, 21 Jun 2018 06:09:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529586596; cv=none; d=google.com; s=arc-20160816; b=kJAQ7MLHPlro73+ytxouVIsvqflzyFwhnZfxVEF/rJ6q/0H0LjnRHz6WTMKChZbYlm w5qTrotFri6HXpLJ/8iTNSsSu2xPmu+E9OHMi9MP8A8JRL7mU8NF7Id4/ZwmfZnmYw6T NXpFDuaV2lKPGMLxG0a4TdUo707YqMMgIWRF9cJA1hxKn7WSsfSVoXTamedUS2SOD6po 3KHqVyyO1cocDg16mrcZs1kgBfVrF9ZPzMCKvgoqLsXE1RkAa3Y9JKAoMsx2qQNwJSUs OdxYUyJGVLL2vIkH8V6296lDyqRXy04r/idTr7NSdi5DWIesBMAzli9I4uupDaTQAeYs fNAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=h3N8LJ5u+IdTdU+rle7Rsl7xxJ1ANrV4sMdmkC3Wul0=; b=iH60nZ/tkcMfBX8qn/qVBbgHYCkkBioS+oiGmrS6G0ZFp6Hs2KG/m6FDEH8NoVGpDX PUKopyipeT+Ctf53yxgnMMVPE+xddMNx0ofPK/CZVNn1UE3ILYEcjutx7U0djqVVuexE HcPr3H/758dL+UjqEi1mwgQReBU75UWYtEQ72zpSHsxItU4pihKNXymLcTr01B3+e9Ae vrteBQuzO9o77uOLBHvUx5gtlXvjPMkG0kk/6P5xfxXEUdchsQtAhNFOyiEKoHSG6phV pQFVz6a7KBX28Tf6jT4usl88NJjJ5COo9ubfDkwaT4uZ6rAB2CyFwz+N+h2t/plnf7FL UuXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=th8Fmccc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n15-v6si3800101pgc.273.2018.06.21.06.09.42; Thu, 21 Jun 2018 06:09:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=th8Fmccc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933329AbeFUNIz (ORCPT + 99 others); Thu, 21 Jun 2018 09:08:55 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:39116 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933110AbeFUNIx (ORCPT ); Thu, 21 Jun 2018 09:08:53 -0400 Received: by mail-wr0-f194.google.com with SMTP id w7-v6so3137154wrn.6; Thu, 21 Jun 2018 06:08:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=h3N8LJ5u+IdTdU+rle7Rsl7xxJ1ANrV4sMdmkC3Wul0=; b=th8Fmccc+Ebcu7YjGQJJR0rthkVTXJbluxS8oGBxMknHZF0SGU/YdaftfxbQBmxdFC H8FTvuISmVA08FrDw6wMv2RXur+c36jduyxeEnvsl5kXPIMdxu2JPrKNY4BKZ3WNoCUD p5tbJeNG+LgZ6rXgreA6NMdZdG1C5nHkdGjL+iC21tNmK7Vrrkm+1iqiFTEeP30zCQyC g+HOrwOzXYTuWOMSoI5LZxvVtmawf9Ekdj7wdmXcog9olRn7AmByW/Irb2zk1p0BJEle UK+xdMv45WIzYam5c+jfhGUeOAOupheDHcNJ59L9yLtc/F+80T9ibBZUvSSSzlqWpF6+ vHTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=h3N8LJ5u+IdTdU+rle7Rsl7xxJ1ANrV4sMdmkC3Wul0=; b=h6oB+CC5OD7ntMy4ikta+ib+FCErG7Jl2c8y+ifF+a6r8cPpOTNHGhhTW6wD4AcmyM GjKrS3Ft7QiCbeAwm83JFUrW5MxydABP0nQYf+3exzUko2sapgffy1FyxOumsQqpCL7M Oj9mpX+7JLFsg1OMs4qoQmck8phb+F/i893IoAMj4zmCNC85mTd2egsiYLXb4UqrJOZp R1pDwQJ2Fs4YwVHivK49E2vIbIYhPRGd9eMlbjk4DWea4aNHSSYo1BtoezlfT9tBVXtf tn8TS2HggompQeL/CD9/kePsmPO0boABaWxK9RVLq7IwpQwiKebGfRolvrDHu0fGcBbM Wn0w== X-Gm-Message-State: APt69E3Ot39dCthrvINn6V6xk7iluna9HUsI/76dulDt573JlTupJ68j kYgOyS9a23+PAeOkC4eOsmE= X-Received: by 2002:adf:8142:: with SMTP id 60-v6mr20916575wrm.192.1529586531788; Thu, 21 Jun 2018 06:08:51 -0700 (PDT) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id 84-v6sm6195131wme.16.2018.06.21.06.08.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Jun 2018 06:08:50 -0700 (PDT) Date: Thu, 21 Jun 2018 15:08:48 +0200 From: Ingo Molnar To: Joel Fernandes , Steven Rostedt Cc: linux-kernel@vger.kernel.org, "Joel Fernandes (Google)" , Steven Rostedt , Peter Zijlstra , Ingo Molnar , Linus Torvalds , Mathieu Desnoyers , Tom Zanussi , Namhyung Kim , Thomas Glexiner , Boqun Feng , Paul McKenney , Masami Hiramatsu , Todd Kjos , Erick Reyes , Julia Cartwright , Byungchul Park , stable@vger.kernel.org Subject: Re: [PATCH RESEND] softirq: reorder trace_softirqs_on to prevent lockdep splat Message-ID: <20180621130848.GA10037@gmail.com> References: <20180607201143.247775-1-joel@joelfernandes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180607201143.247775-1-joel@joelfernandes.org> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Joel Fernandes wrote: > From: "Joel Fernandes (Google)" > > I'm able to reproduce a lockdep splat with config options: > CONFIG_PROVE_LOCKING=y, > CONFIG_DEBUG_LOCK_ALLOC=y and > CONFIG_PREEMPTIRQ_EVENTS=y > > $ echo 1 > /d/tracing/events/preemptirq/preempt_enable/enable > > [ 26.112609] DEBUG_LOCKS_WARN_ON(current->softirqs_enabled) > [ 26.112636] WARNING: CPU: 0 PID: 118 at kernel/locking/lockdep.c:3854 > [...] > [ 26.144229] Call Trace: > [ 26.144926] > [ 26.145506] lock_acquire+0x55/0x1b0 > [ 26.146499] ? __do_softirq+0x46f/0x4d9 > [ 26.147571] ? __do_softirq+0x46f/0x4d9 > [ 26.148646] trace_preempt_on+0x8f/0x240 > [ 26.149744] ? trace_preempt_on+0x4d/0x240 > [ 26.150862] ? __do_softirq+0x46f/0x4d9 > [ 26.151930] preempt_count_sub+0x18a/0x1a0 > [ 26.152985] __do_softirq+0x46f/0x4d9 > [ 26.153937] irq_exit+0x68/0xe0 > [ 26.154755] smp_apic_timer_interrupt+0x271/0x280 > [ 26.156056] apic_timer_interrupt+0xf/0x20 > [ 26.157105] > > The issue was this: > > preempt_count = 1 << SOFTIRQ_SHIFT > > __local_bh_enable(cnt = 1 << SOFTIRQ_SHIFT) { > if (softirq_count() == (cnt && SOFTIRQ_MASK)) { > trace_softirqs_on() { > current->softirqs_enabled = 1; > } > } > preempt_count_sub(cnt) { > trace_preempt_on() { > tracepoint() { > rcu_read_lock_sched() { > // jumps into lockdep > > Where preempt_count still has softirqs disabled, but > current->softirqs_enabled is true, and we get a splat. > > Cc: Steven Rostedt > Cc: Peter Zijlstra > Cc: Ingo Molnar > Cc: Linus Torvalds > Cc: Mathieu Desnoyers > Cc: Tom Zanussi > Cc: Namhyung Kim > Cc: Thomas Glexiner > Cc: Boqun Feng > Cc: Paul McKenney > Cc: Masami Hiramatsu > Cc: Todd Kjos > Cc: Erick Reyes > Cc: Julia Cartwright > Cc: Byungchul Park > Cc: stable@vger.kernel.org > Reviewed-by: Steven Rostedt (VMware) > Fixes: d59158162e032 ("tracing: Add support for preempt and irq enable/disable events") > Signed-off-by: Joel Fernandes (Google) > --- > kernel/softirq.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/kernel/softirq.c b/kernel/softirq.c > index 177de3640c78..8a040bcaa033 100644 > --- a/kernel/softirq.c > +++ b/kernel/softirq.c > @@ -139,9 +139,13 @@ static void __local_bh_enable(unsigned int cnt) > { > lockdep_assert_irqs_disabled(); > > + if (preempt_count() == cnt) > + trace_preempt_on(CALLER_ADDR0, get_lock_parent_ip()); > + > if (softirq_count() == (cnt & SOFTIRQ_MASK)) > trace_softirqs_on(_RET_IP_); > - preempt_count_sub(cnt); > + > + __preempt_count_sub(cnt); > } Acked-by: Ingo Molnar Steve, wanna queue this up? Splat should only occur with tracing AFAICT. Thanks, Ingo