Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp6329381imd; Wed, 31 Oct 2018 10:04:01 -0700 (PDT) X-Google-Smtp-Source: AJdET5fNfsc37wU0HugRFsr3RernvsB0uveP4ET7q0U30uecfN3bOB59pkKsVABFp/95HW4aA7dy X-Received: by 2002:a17:902:9a44:: with SMTP id x4-v6mr4149441plv.121.1541005441119; Wed, 31 Oct 2018 10:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541005441; cv=none; d=google.com; s=arc-20160816; b=Bh3PMolr16lDZ9nM2pvHLa15oA8kfVmKm+Or2TRISOTVfgNMc0b6NXjI9CakB7qh2Y vRO63cRDLkTzEq88K7yY014rGIqgh6O0eJu+2+89KelAV7SBsKo3S4/fSFI4oppKVpgg REPSaaoXYUWGMNYrjTwJacQGTOsRHimfFHuEIgW9MUZ+thzJu48peK749fWZAhajWSCW JQOwFWDyslMrP3QDNbdHwo2fK0aGBk53HAOpmjPhTL/L5bchTxWHHzWOVVop8UTjKxEC kEYllQv00Pm58UOClX2eqIjY9pR1sGnaErrPHwptdjmBbYVcSM6BAz7rSv0t7Emmfnnr 5kZw== 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=w7PRsslQ+AmlGw6ESJEAEIN3Ju+lMTMOAAXzG79p0Hk=; b=bDcBnJN2OtoLSGTiUryW0eH+LvbKtp6BuRAKxbGx5un0emw0uaD5PydTY1QyLoZVhL tFn0d/ctcIrCoyzLtOPZo+O0HsOiHn9drc7XijYogjabKsj8Krv/w5e4m0g0LcV3d7ZB DBdKptgMPXzNADrpVExHUu+3JVvLcidj9tlStk/vmpK/QNUbS9M/LY1uaU86+DMzLgPW xQoBwqiFo3b8PaOyFXaQeSO81ZBkUVGDS6XMr3IPYbMzEvnXE22wzBhroMY+hJ5dvAuE maIYC2lMFtOlVWLaj0NXem9mpJ+uLlY0k0FIt54/nJzurPnXrdwso30SE8W6Q2EKa1+7 4+Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LcTmkgLa; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x2-v6si27187105plo.259.2018.10.31.10.03.44; Wed, 31 Oct 2018 10:04:01 -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=@linaro.org header.s=google header.b=LcTmkgLa; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729754AbeKACAe (ORCPT + 99 others); Wed, 31 Oct 2018 22:00:34 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:45907 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729408AbeKACAd (ORCPT ); Wed, 31 Oct 2018 22:00:33 -0400 Received: by mail-wr1-f67.google.com with SMTP id n5-v6so17277207wrw.12 for ; Wed, 31 Oct 2018 10:01:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=w7PRsslQ+AmlGw6ESJEAEIN3Ju+lMTMOAAXzG79p0Hk=; b=LcTmkgLaTJl5aqBKxMqvydqj6P3/DffuXvVPbAUygeibeDLzwTIQqXfR4uds2rIZYM XhmMGb7KngDWan146d22FCM9UQ9Ko/QDf54C0Fdt16LXoigKyLTLkNkKnhAaTuALlKv5 25xBM+L683GMsxPWlmbZaDfh6fxO/3dRfQFIc= 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=w7PRsslQ+AmlGw6ESJEAEIN3Ju+lMTMOAAXzG79p0Hk=; b=o/6enO7Z6F+wj+HEpqgMFLv8SdUHXyDc3wxpKlzIFAYK+/nQ/npgcv9QYpRahGX3om zVcW1v0jdIx7/9syDtVCtBvBe0qRFrnJ0hQx47Tf5eDBdpvd3hR2WjE3cqfRs8VZfesd sbvK4YEHhJCrn+8QRw+bxTd35UD1cvlRN0JCMinIfdwT+WwpRrrKiUIa5qdeda8T4DTa l++wpX/iGZZHVVFRC7NF++OKyn14BLwLju8QPpK0f1uv1Ge8U+vzJNZ/LDFOvBQXsdkh P4u9NVc928RHLbKW2FpzAOxBBkx3sn+IsopvusDiuqE8dvHh/5UN2oWV9r6tT8dgCB/6 DBOQ== X-Gm-Message-State: AGRZ1gJvOa6XBBsmYoku7Ztd8bJ1qM0w3GubdXKfGC75EnNirB3neblj J44QM72+se8caj2S5qEP8dNL9w== X-Received: by 2002:adf:aa05:: with SMTP id p5-v6mr3828856wrd.56.1541005300354; Wed, 31 Oct 2018 10:01:40 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id t77-v6sm39633264wme.18.2018.10.31.10.01.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Oct 2018 10:01:39 -0700 (PDT) Date: Wed, 31 Oct 2018 17:01:36 +0000 From: Daniel Thompson To: Peter Zijlstra Cc: Douglas Anderson , Jason Wessel , kgdb-bugreport@lists.sourceforge.net, linux-mips@linux-mips.org, linux-sh@vger.kernel.org, Greg Kroah-Hartman , Catalin Marinas , James Hogan , linux-hexagon@vger.kernel.org, Vineet Gupta , Thomas Gleixner , Philippe Ombredanne , Kate Stewart , Rich Felker , Ralf Baechle , linux-snps-arc@lists.infradead.org, Yoshinori Sato , Benjamin Herrenschmidt , Will Deacon , Paul Mackerras , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Michael Ellerman , Paul Burton , linux-kernel@vger.kernel.org, Richard Kuo , linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH v2 2/2] kgdb: Fix kgdb_roundup_cpus() for arches who used smp_call_function() Message-ID: <20181031170136.s3ids6tm4rxxlpma@holly.lan> References: <20181030221843.121254-1-dianders@chromium.org> <20181030221843.121254-3-dianders@chromium.org> <20181031134926.GB13237@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181031134926.GB13237@hirez.programming.kicks-ass.net> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 31, 2018 at 02:49:26PM +0100, Peter Zijlstra wrote: > On Tue, Oct 30, 2018 at 03:18:43PM -0700, Douglas Anderson wrote: > > Looking closely at it, it seems like a really bad idea to be calling > > local_irq_enable() in kgdb_roundup_cpus(). If nothing else that seems > > like it could violate spinlock semantics and cause a deadlock. > > > > Instead, let's use a private csd alongside > > smp_call_function_single_async() to round up the other CPUs. Using > > smp_call_function_single_async() doesn't require interrupts to be > > enabled so we can remove the offending bit of code. > > You might want to mention that the only reason this isn't a deadlock > itself is because there is a timeout on waiting for the slaves to > check-in. dbg_master_lock must be owned to call kgdb_roundup_cpus() so the calls to smp_call_function_single_async() should never deadlock the calling CPU unless there has been a previous failure to round up (e.g. cores that cannot react to the round up signal). When there is a failure to round up when we resume, there is a window (before whatever locks that prevented the IPI being serviced are released) during which the system will deadlock if the debugger is re entered. I don't think there is any point trying to round up a CPU that did not previously respond... it should still have an IPI pending. The deadlock can be eliminated by getting the round up code to avoid CPUs whose csd->flags are non-zero either by checking the flag in the kgdb code or adding something like smp_trycall_function_single_async(). Daniel.