Received: by 2002:a05:7412:1492:b0:e2:908c:2ebd with SMTP id s18csp507166rdh; Wed, 23 Aug 2023 06:52:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGiCaK/qu1xbmMBPrUYrNPOO5mzo/tqcwzFnBIELzrMjrwyJGeI9v2zQ21X4ezM9Dadz+LW X-Received: by 2002:a17:907:16ac:b0:992:13c7:560 with SMTP id hc44-20020a17090716ac00b0099213c70560mr12823365ejc.38.1692798747845; Wed, 23 Aug 2023 06:52:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692798747; cv=none; d=google.com; s=arc-20160816; b=SUsv4kWAoDWGmLyrUJPZiyUszF+K7pYDHphmBjRfO8wll79A38Q1Bdwbg7tqT6x5TM ha5wCBor3zBJ/iJS21SVN8Sz8mMWvnVeQgrwRkvmKYNI9od0FZzp27a43lKcz/VEpXWI PP4tmIrTr3ioLe25LVR88ZR8w3r+DbGaklRbAAxyPOSAruZRgIzfoRP7fH7GagBDdeNF /DlM5j5Iy2sgiMqbq4eQ4qGZY2xAUocZkYOAjBVEUIjRDE/VojZ8+6sSUHhIJ7e0k6iy VdeuoYsOeD6oBOO8Oh0SMBAUhXI00yQpSVaygX/4oo4NgUhK6KiWuTBRDN/JswLwg6mZ AbeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=8CoIShF4nm+Y+TTq/y1T+mYqaAIRb3s+laDow41BW7Y=; fh=Bi5O9PQpd3w5SwlG8HyzVTXDKD0TrDGXb2fPYXqcu2s=; b=N4J5GbnytgPXN1AA5QoShzuYt2xadYgmXCbtu7pFwG0KytW7FJbJQbiF5fG078kpgx YQqVngc2VoStcHYB1ElwfP6OCKpwwh+9jzvlTutSxvmiF6mPQ0LSXg/XUxWq0JVYCin8 uKq6xc/lAk+G/rapXuxZXRABWWCmLrwpFZQlB3QN5I89iWc9SoxJHTf3OuAqrta/58+V SSKlboTEwNBKYSE1+xeXdY4WHDMJO17VOxLE73sq9Kaa9nYPZcQC9RIhMi//cT8ADfAf q0wrBxE+/T6l0ToupY0BnHccvsAPn7H6/fhdqTWmlGnEbTp7sZ6Ppr3B+XlBmiN6SKJ0 AXsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JprU1KL3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qq18-20020a17090720d200b0098882d02831si9398983ejb.710.2023.08.23.06.52.02; Wed, 23 Aug 2023 06:52:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JprU1KL3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229971AbjHVUV1 (ORCPT + 99 others); Tue, 22 Aug 2023 16:21:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229491AbjHVUV0 (ORCPT ); Tue, 22 Aug 2023 16:21:26 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D50910B for ; Tue, 22 Aug 2023 13:21:25 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-68a41035828so2064292b3a.1 for ; Tue, 22 Aug 2023 13:21:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1692735684; x=1693340484; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=8CoIShF4nm+Y+TTq/y1T+mYqaAIRb3s+laDow41BW7Y=; b=JprU1KL33Lf+lJpoZAp0GtjuJ3ozT/dIA/XZAwT42K9+Rma03OCSu2M5j/mM5wfIQA TiGWUeaJRhgUcAAWaN0bo6JWNAmWoe4Lh6IHpYzcST4eRrQBJTo6NXgsWGD0qCn9YY9J Adskx5+uU+hQW9cDkhg19oXZFcCXjGjZDpPp8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692735684; x=1693340484; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8CoIShF4nm+Y+TTq/y1T+mYqaAIRb3s+laDow41BW7Y=; b=WmGrxyNlyM3My0IJKnwD1Hm/SUXoIAbIT8iZafCX9LWrqjwrftpm5uSqKzbzoeihW+ LJ6op5NnxLyYlWdgv3VG/4LGIB/R7gzYbkXF0P+INqgBlI8s4HhJika7DyhWul/OE9RL 9S35cF5v9TjfzORAQclpgnnzH0Q0QcJRkdtYsaKKmlDzXqkJXYUEIZN2UXDmDMLfV7ax NwFvGPy9IzfbpUt4VxVaE7bWucaHDVlfVMWBEjVsCDP2ppYY+2ch0JwfhQsK3kOny8Ih +RIddCwh1oZMsxllYSB+bYEjoA/BPxLhtyonKZDtV6MP1z+AlhkVTihITuV/hNezxbVZ Yj1w== X-Gm-Message-State: AOJu0Yw437o7hw19CBhoEs6DPMGKVo82xg2Ov7Ro4n1apIoP1XHp/OlY yGoJ3xEI8yW59lv348vwPiYsSg== X-Received: by 2002:a05:6a20:199:b0:130:9638:36d4 with SMTP id 25-20020a056a20019900b00130963836d4mr7946558pzy.33.1692735684540; Tue, 22 Aug 2023 13:21:24 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:83f0:2bc5:38c4:a9de]) by smtp.gmail.com with ESMTPSA id w29-20020a63935d000000b00563df2ba23bsm8254729pgm.50.2023.08.22.13.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Aug 2023 13:21:23 -0700 (PDT) From: Douglas Anderson To: Daniel Thompson Cc: Petr Mladek , Douglas Anderson , Jason Wessel , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH] kgdb: Flush console before entering kgdb on panic Date: Tue, 22 Aug 2023 13:19:46 -0700 Message-ID: <20230822131945.1.I5b460ae8f954e4c4f628a373d6e74713c06dd26f@changeid> X-Mailer: git-send-email 2.42.0.rc1.204.g551eb34607-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When entering kdb/kgdb on a kernel panic, it was be observed that the console isn't flushed before the `kdb` prompt came up. Specifically, when using the buddy lockup detector on arm64 and running: echo HARDLOCKUP > /sys/kernel/debug/provoke-crash/DIRECT I could see: [ 26.161099] lkdtm: Performing direct entry HARDLOCKUP [ 32.499881] watchdog: Watchdog detected hard LOCKUP on cpu 6 [ 32.552865] Sending NMI from CPU 5 to CPUs 6: [ 32.557359] NMI backtrace for cpu 6 ... [backtrace for cpu 6] ... [ 32.558353] NMI backtrace for cpu 5 ... [backtrace for cpu 5] ... [ 32.867471] Sending NMI from CPU 5 to CPUs 0-4,7: [ 32.872321] NMI backtrace forP cpuANC: Hard LOCKUP Entering kdb (current=..., pid 0) on processor 5 due to Keyboard Entry [5]kdb> As you can see, backtraces for the other CPUs start printing and get interleaved with the kdb PANIC print. Let's replicate the commands to flush the console in the kdb panic entry point to avoid this. Signed-off-by: Douglas Anderson --- kernel/debug/debug_core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index d5e9ccde3ab8..3a904d8697c8 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -1006,6 +1006,9 @@ void kgdb_panic(const char *msg) if (panic_timeout) return; + debug_locks_off(); + console_flush_on_panic(CONSOLE_FLUSH_PENDING); + if (dbg_kdb_mode) kdb_printf("PANIC: %s\n", msg); -- 2.42.0.rc1.204.g551eb34607-goog