Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp942943ybm; Wed, 27 May 2020 11:46:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaImluaejWzd8SlmkDcYI8gkW1gMmn/y/c7IOe2sDl2YWKokz8nGT1nyu4suOW9inqBwjZ X-Received: by 2002:a50:9b0f:: with SMTP id o15mr26212666edi.325.1590605201144; Wed, 27 May 2020 11:46:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590605201; cv=none; d=google.com; s=arc-20160816; b=qOn72io3HLc79DxURiOg5Zu5a3fmuA+F8n1VXoQTIsz4If9wErCo+AWENB3TL53a5w 63tR4d+jOk5Z1h5GwTuESQlreQ+/LW7JECiLDn+BjwBRFqDl7YzUOTHcsSq7L7QzPswN 2N2JR56BgSXW1YIpEoTA3XZi1mujbe9zob+WKGujV/LQakhDqOakyMhn3qs5qzs5XaBe AEKeBUURjvv2SDu9A5AOPgInV0f8AedmMxY1X7raJkbTeFzEY6UMYDdTdqJfLWnAlgaB K5QnR+PDHp31pNSpbtwc8gvsTIQ9t1pH5TRnBdN8L2UUaB/EVWJiNu9JiEiht1ffO9OK c69g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Mly88rOWldb2hn6ZUpBbudlq0QPli1OI+xak074b4r4=; b=FKoJHNTUYPGvGzFGyfSGvGTGCa7/e7wIcOeu0KioKNxG0W7XJF27MhTQWWAd2gJJ1w HJEzit6sKW/DCpxj/DxWTxJjsKb19YguE4mSXK1Pqf/s1wT7uW417k08sKQvN/boiZ/j //bgF3ipETANDtdpeLIdhKuw6HO3MnJBSPhM4hRdQGVI7SeYFVuyUFZFgz2pIHrBu7xn nsORwZvqS6CWS5/ksk2vrChzkyjQzvGaX3+dqkmIzcSr05dLyIsHvUgzJXQYwVN8wRC7 RHLrFatBR4Usa7FDlLlMkKsPGGVdtcDcYtrEqTupFxNL//doxW1J+o7d25mbznh5U6F+ 9oPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="lAj3+1b/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id g5si2360372edl.566.2020.05.27.11.46.17; Wed, 27 May 2020 11:46:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="lAj3+1b/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2389200AbgE0O0Y (ORCPT + 98 others); Wed, 27 May 2020 10:26:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389036AbgE0O0X (ORCPT ); Wed, 27 May 2020 10:26:23 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AF37C08C5C2 for ; Wed, 27 May 2020 07:26:21 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id j198so2401803wmj.0 for ; Wed, 27 May 2020 07:26:21 -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; bh=Mly88rOWldb2hn6ZUpBbudlq0QPli1OI+xak074b4r4=; b=lAj3+1b/p3m/ElrnylWgfn/5vAM5qlt1rTY6GYJMqKlpy+5swWInxuNIz8ay89ysVX hc8Pzyf7c0E+jRldyVyLLE8rScc7piJOSxcjE8PLU1GH0bXHL0rfcGhfwDFAVn7FKZ94 f3HVHC9HU1SoQHT7yZOoYKcHdZWZL70//b9+xYaGv5rwmkxCyLnRWFHLChSXU3dsBxNV tPNC8prFGFq+u/6YnTni0cBmAkN2MQc5sSCySaBzuOkCenirCZgX4UP9Q0EoxKOd5nzv keB2wPsIVLoFf0Y5FLqgvswggZtbokmEZQP7V5VJJTCJ0soabWSO4axKZgomC8qEW/T1 /lMA== 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; bh=Mly88rOWldb2hn6ZUpBbudlq0QPli1OI+xak074b4r4=; b=HhAwbPfC9fQp2UXgGD19I7u5VqM1id6H1YwEwvZQ2zAGYiYU9aFDbGU0lLClWPi8AZ sAUbjAh1wy39EGVAPRYBZQYtI2LY2ItrmbTG4tvgCMXcVTB1YCkHwXbgK2yf1RQPg4uR fb00JIKU12Ox1rc8s0SR7a0ThcWEdV1OMpS3DNHZwcCQmDxOR4lSnAoywg6KVriE0DCJ 4ECcstW7TJAHZ2Plsm51h2FKrxXp8ssMydwXrkQ1mDPHNtv4tbPvuLt3x8zr0shQGQSF 6+7tostZy9yKiW1UnHTQSgDRtspo0G5gxRmcvz7vPHNy4w+54KTh/lzmvvJXAd4nUaHy 1PEw== X-Gm-Message-State: AOAM533TWdWjo+A9DkO2zpDLpHXBvrR9gE0dUt9yAd7DJDOkpJYyt5ZJ 4Pc6zXwyDiRi0J/GjDqB8QdHpQ== X-Received: by 2002:a1c:f315:: with SMTP id q21mr4299691wmq.114.1590589580237; Wed, 27 May 2020 07:26:20 -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 s2sm2777668wmh.11.2020.05.27.07.26.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 07:26:19 -0700 (PDT) Date: Wed, 27 May 2020 15:26:17 +0100 From: Daniel Thompson To: Sumit Garg Cc: kgdb-bugreport@lists.sourceforge.net, jason.wessel@windriver.com, dianders@chromium.org, pmladek@suse.com, sergey.senozhatsky@gmail.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/4] kdb: Make kdb_printf robust to run in NMI context Message-ID: <20200527142617.t7dzal7ok5i3exra@holly.lan> References: <1590560759-21453-1-git-send-email-sumit.garg@linaro.org> <1590560759-21453-4-git-send-email-sumit.garg@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1590560759-21453-4-git-send-email-sumit.garg@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 27, 2020 at 11:55:58AM +0530, Sumit Garg wrote: > While rounding up CPUs via NMIs, its possible that a rounded up CPU This problem does not just impact NMI roundup (breakpoints, including implicit breakpoint-on-oops can have the same effect). > maybe holding a console port lock leading to kgdb master CPU stuck in > a deadlock during invocation of console write operations. So in order > to avoid such a deadlock, enable oops_in_progress prior to invocation > of console handlers. > > Suggested-by: Petr Mladek > Signed-off-by: Sumit Garg > --- > kernel/debug/kdb/kdb_io.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c > index 349dfcc..f848482 100644 > --- a/kernel/debug/kdb/kdb_io.c > +++ b/kernel/debug/kdb/kdb_io.c > @@ -566,7 +566,17 @@ static void kdb_msg_write(char *msg, int msg_len) > for_each_console(c) { > if (!(c->flags & CON_ENABLED)) > continue; > + /* > + * While rounding up CPUs via NMIs, its possible that Ditto. > + * a rounded up CPU maybe holding a console port lock > + * leading to kgdb master CPU stuck in a deadlock during > + * invocation of console write operations. So in order > + * to avoid such a deadlock, enable oops_in_progress > + * prior to invocation of console handlers. Actually looking at this comment as a whole I think it spends to many words on what and not enough on why (e.g. what the tradeoffs are and why we are not using bust_spinlocks() which would be a more obvious approach). Set oops_in_progress to encourage the console drivers to disregard their internal spin locks: in the current calling context the risk of deadlock is a bigger problem than risks due to re-entering the console driver. We operate directly on oops_in_progress rather than using bust_spinlocks() because the calls bust_spinlocks() makes on exit are not appropriate for this calling context. Daniel. > + */ > + ++oops_in_progress; > c->write(c, msg, msg_len); > + --oops_in_progress; > touch_nmi_watchdog(); > } > } > -- > 2.7.4 >