Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8028117ybi; Tue, 9 Jul 2019 08:02:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzRC9Feq7HEVcnUHupgqC67Z0ILEOddzWNkM1PcK/mS3RxO8zpo9iBVggT/BaoWKRXaDVS X-Received: by 2002:a17:90a:17c4:: with SMTP id q62mr617031pja.104.1562684524144; Tue, 09 Jul 2019 08:02:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562684524; cv=none; d=google.com; s=arc-20160816; b=Yzpp82zmhkOJ1rOJfjpL7lBJJ/ot1uYQrXpR0TSNuo1hecsbHKyl4TRV8spZrtfzI4 hEn4hZhrP5ZjiP/XIx1+gzQVoC9+swVRzhJbVkbK38DlYj3L4RvE1KjfwmKgAxBSYHBl vZDXKu8dsy5lldmT8z5TS8IngsMrJerLlJZA7w7KgbkmF3St6XbzuRwToHMoxOdKvhDF fTb/tori/Ix8FYa1jZ6VTr2+lFor+ySpMFKcL8oYZOWrATkEwEwOebnE5XzJmQhRA7pp JlS8oD3s7XNMEx2CnJaPmO4Cr0QwF/gBZ1nHgSM/lNZqofiblUpOl/Sp6fsWHPabx4++ Jn5g== 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=N67Qa6q9CITh5hKRJQifXm/LEYOhI8c6TcpZdYd27zA=; b=FFwex5LEgVoa05QAycD1wICkz0n1TzxBIVC2oG5vik1a9pk70L//GVkti7kOw5fPKj BkrGXctQl/kGeyAZkylbrzJi92FGpKve9juVuiIiKtr1ohqoX1C7RdZE1rhxKwN/uUIB j/Fpxd7kSC2taa1rCMzcgQ+7a/rwYmDGGUzv2X9goJr1vHOraVRZ9ItTTGTtH7e1Zf85 4UwTp9a6VM2YeouQhxc2OCtnYau/uUvMH5OHKEnk800WXwZd3BAexOFfn0se8hX5CvQ5 HwgrPsy4/QKQdVca++fyKHqCovdbGYJ8t3GUGSzsGqpxd62zknbrkmgUUlmO3YDJFhCl tXfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I5PzqdSH; 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 b38si22332831pla.65.2019.07.09.08.01.46; Tue, 09 Jul 2019 08:02:04 -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=I5PzqdSH; 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 S1726403AbfGIO7t (ORCPT + 99 others); Tue, 9 Jul 2019 10:59:49 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:50917 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726055AbfGIO7s (ORCPT ); Tue, 9 Jul 2019 10:59:48 -0400 Received: by mail-wm1-f65.google.com with SMTP id v15so3455240wml.0 for ; Tue, 09 Jul 2019 07:59:47 -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=N67Qa6q9CITh5hKRJQifXm/LEYOhI8c6TcpZdYd27zA=; b=I5PzqdSHsvp5rRiQg3IHSmXPUNbpfzjZCJWETQgBq0gGsY2dpSwITCpqwfNyNu4SQu Nwlk8JtsMvbxgY9Km67zmwGKh+YHkPSZytNXGX7RVmoGPcnIfOJkQrFpCK/MmlaTt9X7 Bb3qZba9bfRr0/BAyZzIsVaZaBTGifOpOdr8mgjoXqZiYnXkZ/bEzzlnN9hgvRd0OSKY OjcCPcO6DyEFUUq5gh6YIEcj9ZOv26RKmAEUBnsXv5kleW+sQfik2d2Q1fnj6V5VomEd CnJfkLzQzLxjCdd1w4u6UhmFu70ZwXTcYNBqe3mWXw3aHXJpp2PNK0GixoX9+JT9sZrp ydkQ== 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=N67Qa6q9CITh5hKRJQifXm/LEYOhI8c6TcpZdYd27zA=; b=CH/mctkEk543piaFOcYcpkXOKif2td/bLSWFNt3+S6BoOyLNxQ5YjBaDQTuuRD+gzi 7ae6oB/LvtYeGrH4BkWVxm1U+KiiOrPy7z4+GLk5M8rIzEokK/bPokX74JVXKigRF/PB kQo+SLN5gu7bM2Bu41hjQyzF4s2TaINu/ZhK1swXudUDCCpZiqtaZKbUU+48N7B+YVmP t/lC4/+8CnZWQExE+wJF3AYINI341mRhcNLUHj6CtQ9aOcI45vs6x+OZhPpWObBgKwlC AyNdbYUyjtkCp3mxT3Ey/ZBgiPxA7sxcxymqzfEuK+GRT72ezhPg8TjnjSh6Iyh9FAAJ yQUA== X-Gm-Message-State: APjAAAWdeN6wu0hcu11qwCkXrPfAsCwkKSx3yiDzgc74kKX8iDnhbndg aVquJDqPl9ycohvio2WwpT2T/g== X-Received: by 2002:a05:600c:da:: with SMTP id u26mr390611wmm.108.1562684386373; Tue, 09 Jul 2019 07:59:46 -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 v4sm2986480wmg.22.2019.07.09.07.59.45 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 09 Jul 2019 07:59:45 -0700 (PDT) Date: Tue, 9 Jul 2019 15:59:43 +0100 From: Daniel Thompson To: Douglas Anderson Cc: Jason Wessel , Andrew Morton , Martin Schwidefsky , Kees Cook , kgdb-bugreport@lists.sourceforge.net, Borislav Petkov , linux-kernel@vger.kernel.org, Thomas Gleixner , Feng Tang , YueHaibing , Sergey Senozhatsky , "Steven Rostedt (VMware)" Subject: Re: [PATCH] kgdb: Don't use a notifier to enter kgdb at panic; call directly Message-ID: <20190709145943.zfwvs7inlngtxwfe@holly.lan> References: <20190703170354.217312-1-dianders@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190703170354.217312-1-dianders@chromium.org> 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, Jul 03, 2019 at 10:03:54AM -0700, Douglas Anderson wrote: > Right now kgdb/kdb hooks up to debug panics by registering for the > panic notifier. This works OK except that it means that kgdb/kdb gets > called _after_ the CPUs in the system are taken offline. That means > that if anything important was happening on those CPUs (like something > that might have contributed to the panic) you can't debug them. > > Specifically I ran into a case where I got a panic because a task was > "blocked for more than 120 seconds" which was detected on CPU 2. I > nicely got shown stack traces in the kernel log for all CPUs including > CPU 0, which was running 'PID: 111 Comm: kworker/0:1H' and was in the > middle of __mmc_switch(). > > I then ended up at the kdb prompt where switched over to kgdb to try > to look at local variables of the process on CPU 0. I found that I > couldn't. Digging more, I found that I had no info on any tasks > running on CPUs other than CPU 2 and that asking kdb for help showed > me "Error: no saved data for this cpu". This was because all the CPUs > were offline. > > Let's move the entry of kdb/kgdb to a direct call from panic() and > stop using the generic notifier. Putting a direct call in allows us > to order things more properly and it also doesn't seem like we're > breaking any abstractions by calling into the debugger from the panic > function. > > Signed-off-by: Douglas Anderson This patch changes the way kdump and kgdb interact with each other. However it would seem rather odd to have both tools simultaneously armed and, even if they were, the user still has the option to use panic_timeout to force a kdump to happen. Thus I think the change of order is acceptable: Reviewed-by: Daniel Thompson Daniel. > diff --git a/kernel/panic.c b/kernel/panic.c > index 4d9f55bf7d38..e2971168b059 100644 > --- a/kernel/panic.c > +++ b/kernel/panic.c > @@ -12,6 +12,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -219,6 +220,13 @@ void panic(const char *fmt, ...) > dump_stack(); > #endif > > + /* > + * If kgdb is enabled, give it a chance to run before we stop all > + * the other CPUs or else we won't be able to debug processes left > + * running on them. > + */ > + kgdb_panic(buf); > + > /* > * If we have crashed and we have a crash kernel loaded let it handle > * everything else. > -- > 2.22.0.410.gd8fdbe21b5-goog >