Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2388705ybd; Thu, 27 Jun 2019 11:29:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4R6WuCHTYNMrSZI/lya3RPAAoSylvUxHqdabRadyHIorJZIyNsuudNzOEjtI351iguKlB X-Received: by 2002:a17:902:b7c1:: with SMTP id v1mr6216694plz.85.1561660164013; Thu, 27 Jun 2019 11:29:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561660164; cv=none; d=google.com; s=arc-20160816; b=YUB3EnELaA9Rb5igo8f4nKUSEGRC/r/k7QVEbfyhmtOu841RZC1BznAz+F5x+j7TVT F1j2hpR1+cZwfiFBNVtp0cShXmtyEtdVNiwNhEy+SVzp96dNHN+Fpy7uINqcnbx+8HWm otd/Q6/OAIOIlwQO3hKAydIsY9lqYVRUiMH7wOow0Q57TLGz2wfE04UvTj+3bfOwDJMg x5f0pVGwezytjdwkv5hjIFZrvcX/D1CCF8z2ynedKpCfU5M4tQjB0dAs9qv109rm4iPq 2xdxxHxLsALFBtR4J0FbWAG3G0zjypWTs3OOrh2APDDivj2ujZo5PcR8JWIcSOlgsnHA tVdQ== 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; bh=/tPbgIhiysm/d1Ywl3wGAgxq8Xdcczm220C0nQC/hxg=; b=SDAQSvMw2GcPqGsjBdRWicuyLVDjcakleZ7JTFmZ/ZbbSq+X3xYaiR7qdZQW7HrABw ebI5tqzlDigHzDpmnqJ0AF+RwwN0PpZ5n/rFYojTTishA3ySdbBD3845rrhoCDNoWfT0 UYFGfD3cUbo1/oa0KLyNOpxwtF6QhSsjpskV54SJd74kP8O+SaqZbdCt3Pgsz9cfQFUr X+Sce23PK67Zk3BGhdbTd0urvuthAowQ9CM04u/r+Nc6eNr7zBXZL28OyVy6J9RLKyl6 2jWEdygOmI4Q0l3oPpxJmUgwnm9bBcPVdofvkO8CgjEuamzf8jbSEP6l7nJ3d0rTx3Tv ciQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=NxVM7YBW; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q1si2622227pgp.301.2019.06.27.11.29.07; Thu, 27 Jun 2019 11:29:23 -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=pass header.i=@joelfernandes.org header.s=google header.b=NxVM7YBW; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726675AbfF0S10 (ORCPT + 99 others); Thu, 27 Jun 2019 14:27:26 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:46740 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726524AbfF0S10 (ORCPT ); Thu, 27 Jun 2019 14:27:26 -0400 Received: by mail-pg1-f194.google.com with SMTP id v9so1377614pgr.13 for ; Thu, 27 Jun 2019 11:27:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=/tPbgIhiysm/d1Ywl3wGAgxq8Xdcczm220C0nQC/hxg=; b=NxVM7YBW6DUZF3CRwC4AgQoieWxrwha0CvcCn86d+8q8TVHlk4Y6Iztj3J90a+ohcU Mk/79AGiO/wkUaln5fK8DfsUi8axlzA9IWjfIz29/f/CWCZub3NM34wVtwvSPWydnuzM 1HU1nMNufa35eUXgSl9GOOeY6ZIx8D5+ApZmk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=/tPbgIhiysm/d1Ywl3wGAgxq8Xdcczm220C0nQC/hxg=; b=cgpkeuaqn8vMHnklR2RldlJD9ipxE7JzQy0FALbr3VsVvuF9AYuEI04lHOzQsgsCu1 Yf3pJGRmp3MTAa2zT66UV/fxVcj5riW6JqI0WkuEaB3e402yrdZFsGDMwAwyJcXbIrqc d9rjJNEPgwkhqYgLAOEZBss8glfcz0UWVr+Ivn3mhhhbCcQLbESQv8/ldFPAfq4Gyd3k +NdZ7WbqVVsas11sIP+VKSnj8XvTz09lMv5qm7F+tkt974gC01wJZvfDU2S87M2b5fyM kH2+2X6cQX9OK/PFZH4PK5l4OSXk7SypaoAo8nTpROaUF5uVAHjOdIoM42olMXkjL94l 67dA== X-Gm-Message-State: APjAAAWrO+49Ekgc28pa79XM769fc/xGvGTrLu1vWe/On7vzPP1Bnxra sWxpMIBCXLk1MgMsGc4ViOwRdw== X-Received: by 2002:a65:510c:: with SMTP id f12mr4905772pgq.92.1561660045043; Thu, 27 Jun 2019 11:27:25 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id e16sm4770647pga.11.2019.06.27.11.27.23 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 11:27:24 -0700 (PDT) Date: Thu, 27 Jun 2019 14:27:22 -0400 From: Joel Fernandes To: "Paul E. McKenney" Cc: Sebastian Andrzej Siewior , Steven Rostedt , rcu , LKML , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Josh Triplett , Mathieu Desnoyers , Lai Jiangshan Subject: Re: [RFC] Deadlock via recursive wakeup via RCU with threadirqs Message-ID: <20190627182722.GA216610@google.com> References: <20190626135447.y24mvfuid5fifwjc@linutronix.de> <20190626162558.GY26519@linux.ibm.com> <20190627142436.GD215968@google.com> <20190627103455.01014276@gandalf.local.home> <20190627153031.GA249127@google.com> <20190627154011.vbje64x6auaknhx4@linutronix.de> <20190627181112.GY26519@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190627181112.GY26519@linux.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 27, 2019 at 11:11:12AM -0700, Paul E. McKenney wrote: > On Thu, Jun 27, 2019 at 01:46:27PM -0400, Joel Fernandes wrote: > > On Thu, Jun 27, 2019 at 1:43 PM Joel Fernandes wrote: > > > > > > On Thu, Jun 27, 2019 at 11:40 AM Sebastian Andrzej Siewior > > > wrote: > > > > > > > > On 2019-06-27 11:37:10 [-0400], Joel Fernandes wrote: > > > > > Sebastian it would be nice if possible to trace where the > > > > > t->rcu_read_unlock_special is set for this scenario of calling > > > > > rcu_read_unlock_special, to give a clear idea about whether it was > > > > > really because of an IPI. I guess we could also add additional RCU > > > > > debug fields to task_struct (just for debugging) to see where there > > > > > unlock_special is set. > > > > > > > > > > Is there a test to reproduce this, or do I just boot an intel x86_64 > > > > > machine with "threadirqs" and run into it? > > > > > > > > Do you want to send me a patch or should I send you my kvm image which > > > > triggers the bug on boot? > > > > > > I could reproduce this as well just booting Linus tree with threadirqs > > > command line and running rcutorture. In 15 seconds or so it locks > > > up... gdb backtrace shows the recursive lock: > > > > Sorry that got badly wrapped, so I pasted it here: > > https://hastebin.com/ajivofomik.shell > > Which rcutorture scenario would that be? TREE03 is thus far refusing > to fail for me when run this way: > > $ tools/testing/selftests/rcutorture/bin/kvm.sh --cpus 8 --duration 5 --trust-make --configs "TREE03" --bootargs "threadirqs" I built x86_64_defconfig with CONFIG_PREEMPT enabled, then I ran it with following boot params: rcutorture.shutdown_secs=60 rcutorture.n_barrier_cbs=4 rcutree.kthread_prio=2 and also "threadirqs" This was not a TREE config, but just my simple RCU test using qemu. I will try this diff and let you know. > If it had failed, I would have tried the patch shown below. I know that > Sebastian has some concerns about the bug happening anyway, but we have > to start somewhere! ;-) > > ------------------------------------------------------------------------ > > diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h > index 82c925df1d92..be7bafc2c0a0 100644 > --- a/kernel/rcu/tree_plugin.h > +++ b/kernel/rcu/tree_plugin.h > @@ -624,25 +624,16 @@ static void rcu_read_unlock_special(struct task_struct *t) > (rdp->grpmask & rnp->expmask) || > tick_nohz_full_cpu(rdp->cpu); > // Need to defer quiescent state until everything is enabled. > - if ((exp || in_irq()) && irqs_were_disabled && use_softirq && > - (in_irq() || !t->rcu_read_unlock_special.b.deferred_qs)) { > - // Using softirq, safe to awaken, and we get > - // no help from enabling irqs, unlike bh/preempt. > - raise_softirq_irqoff(RCU_SOFTIRQ); > - } else { > - // Enabling BH or preempt does reschedule, so... > - // Also if no expediting or NO_HZ_FULL, slow is OK. > - set_tsk_need_resched(current); > - set_preempt_need_resched(); > - if (IS_ENABLED(CONFIG_IRQ_WORK) && irqs_were_disabled && > - !rdp->defer_qs_iw_pending && exp) { > - // Get scheduler to re-evaluate and call hooks. > - // If !IRQ_WORK, FQS scan will eventually IPI. > - init_irq_work(&rdp->defer_qs_iw, > - rcu_preempt_deferred_qs_handler); > - rdp->defer_qs_iw_pending = true; > - irq_work_queue_on(&rdp->defer_qs_iw, rdp->cpu); > - } > + set_tsk_need_resched(current); > + set_preempt_need_resched(); > + if (IS_ENABLED(CONFIG_IRQ_WORK) && irqs_were_disabled && > + !rdp->defer_qs_iw_pending && exp) { > + // Get scheduler to re-evaluate and call hooks. > + // If !IRQ_WORK, FQS scan will eventually IPI. > + init_irq_work(&rdp->defer_qs_iw, > + rcu_preempt_deferred_qs_handler); > + rdp->defer_qs_iw_pending = true; > + irq_work_queue_on(&rdp->defer_qs_iw, rdp->cpu); Nice to see the code here got simplified ;-)