From: Matt Turner <mattst88@gmail.com>
To: "Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Sunil Khatri" <sunil.khatri@amd.com>,
"Trigger Huang" <Trigger.Huang@amd.com>
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, Matt Turner <mattst88@gmail.com>,
Gregoire Pean <gpean@netflix.com>
Subject: [PATCH 11/14] drm/amdgpu: report dropped devcoredumps
Date: Wed, 02 Dec 2026 17:36:17 -0500 [thread overview]
Message-ID: <20261202-amdgpu-devcoredump-v1-11-3dfa0e033b97@gmail.com> (raw)
In-Reply-To: <20261202-amdgpu-devcoredump-v1-0-3dfa0e033b97@gmail.com>
amdgpu_coredump() silently returns when the worker is still formatting
the previous dump or when allocating the dump fails, and the worker
silently frees the dump when allocating the formatted output fails.
Someone looking at a dump, or waiting for one, has no way to tell that
hangs were missed.
Warn when amdgpu drops a dump, count the dropped dumps, and print the
count in the header of each dump. It is a running total rather than the
count since the previous dump: dev_coredumpm() discards a new dump
while an earlier one for the device has not been read yet, without
telling the driver, and a count carried in the discarded dump would be
lost. Those discarded dumps are not counted, for the same reason.
Suggested-by: Gregoire Pean <gpean@netflix.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 28 ++++++++++++++++++++----
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h | 1 +
3 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index c8ca96ce5bdc..f40b5f062fd9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -930,6 +930,8 @@ struct amdgpu_device {
#ifdef CONFIG_DEV_COREDUMP
struct amdgpu_coredump_info *coredump;
struct work_struct coredump_work;
+ /* coredumps dropped since the device was initialized */
+ atomic_t coredump_dropped;
/* the IP state was dumped for the next coredump */
bool coredump_ip_state_valid;
/* the last VM fault when the IP state was dumped */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
index 3cb1927b0f47..19e3a47ded79 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
@@ -672,6 +672,8 @@ amdgpu_devcoredump_format(char *buffer, size_t count, struct amdgpu_coredump_inf
drm_printf(&p, "kernel: %s\n", init_utsname()->release);
drm_printf(&p, "module: " KBUILD_MODNAME "\n");
drm_printf(&p, "time: %ptSp\n", &coredump->reset_time);
+ if (coredump->dropped)
+ drm_printf(&p, "dropped coredumps: %u\n", coredump->dropped);
drm_printf(&p, "pasid: %u\n", coredump->pasid);
drm_printf(&p, "vmid: %u\n", coredump->vmid);
@@ -869,8 +871,13 @@ static void amdgpu_devcoredump_deferred_work(struct work_struct *work)
*/
coredump->formatted_size = amdgpu_devcoredump_format(
NULL, AMDGPU_CORE_DUMP_SIZE_MAX, coredump);
- coredump->formatted = kvzalloc(coredump->formatted_size, GFP_KERNEL);
+ coredump->formatted = kvzalloc(coredump->formatted_size,
+ GFP_KERNEL | __GFP_NOWARN);
if (!coredump->formatted) {
+ atomic_inc(&adev->coredump_dropped);
+ drm_warn(adev_to_drm(adev),
+ "failed to allocate %zd bytes for coredump\n",
+ coredump->formatted_size);
amdgpu_devcoredump_free(coredump);
goto end;
}
@@ -943,15 +950,28 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,
adev->coredump_ip_state_valid = false;
/* No need to generate a new coredump if there's one in progress already. */
- if (work_busy(&adev->coredump_work))
+ if (work_busy(&adev->coredump_work)) {
+ atomic_inc(&adev->coredump_dropped);
+ drm_warn_ratelimited(dev,
+ "previous coredump still being processed, dropping this one\n");
return;
+ }
if (job && job->pasid)
size += sizeof(struct amdgpu_coredump_ib_info) * job->num_ibs;
- coredump = kvzalloc(size, GFP_NOWAIT);
- if (!coredump)
+ coredump = kvzalloc(size, GFP_NOWAIT | __GFP_NOWARN);
+ if (!coredump) {
+ atomic_inc(&adev->coredump_dropped);
+ drm_warn_ratelimited(dev, "failed to allocate coredump\n");
return;
+ }
+
+ /*
+ * A running total rather than the count since the previous dump, which
+ * would be lost if dev_coredumpm() discards this dump.
+ */
+ coredump->dropped = atomic_read(&adev->coredump_dropped);
coredump->skip_vram_check = skip_vram_check;
coredump->reset_vram_lost = vram_lost;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
index 6a51fbe357dc..97d5fbe8320e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
@@ -94,6 +94,7 @@ struct amdgpu_coredump_info {
ssize_t formatted_size;
char *formatted;
+ unsigned int dropped;
unsigned int pasid;
unsigned int vmid;
pid_t submit_tgid;
--
2.56.1
next prev parent reply other threads:[~2026-12-02 22:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 22:36 [PATCH 00/14] drm/amdgpu: capture more of the hang state in the devcoredump Matt Turner
2026-12-02 22:36 ` [PATCH 01/14] drm/amdgpu: dump the IP state of each device in an XGMI hive Matt Turner
2026-12-02 22:36 ` [PATCH 02/14] drm/amdgpu: only give the hung job to its own device's coredump Matt Turner
2026-12-02 22:36 ` [PATCH 03/14] drm/amdgpu: don't overwrite the IP state while a coredump is formatted Matt Turner
2026-12-02 22:36 ` [PATCH 04/14] drm/amdgpu: take a coredump before resets done by a reset handler Matt Turner
2026-12-02 22:36 ` [PATCH 05/14] drm/amdgpu: copy the VM fault info when the hang is detected Matt Turner
2026-12-02 22:36 ` [PATCH 06/14] drm/amdgpu/gfx10-12: dump CP_STAT and the IB2 state of each gfx queue Matt Turner
2026-12-02 22:36 ` [PATCH 07/14] drm/amdgpu: copy the IB contents before formatting the devcoredump Matt Turner
2026-12-02 22:36 ` [PATCH 08/14] drm/amdgpu: copy the IB contents when the hang is detected Matt Turner
2026-12-02 22:36 ` [PATCH 09/14] drm/amdgpu: record the submitting thread of the hung job in the coredump Matt Turner
2026-12-02 22:36 ` [PATCH 10/14] drm/amdgpu: dump the unsignaled fences of each ring " Matt Turner
2026-12-02 22:36 ` Matt Turner [this message]
2026-12-02 22:36 ` [PATCH 12/14] drm/amdgpu: list the VM mappings of the hung job " Matt Turner
2026-12-02 22:36 ` [PATCH 13/14] drm/amdgpu: add AMDGPU_VM_PAGE_DUMP to include BOs " Matt Turner
2026-12-02 22:36 ` [PATCH 14/14] drm/amdgpu: bump the devcoredump version Matt Turner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202-amdgpu-devcoredump-v1-11-3dfa0e033b97@gmail.com \
--to=mattst88@gmail.com \
--cc=Trigger.Huang@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gpean@netflix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=sunil.khatri@amd.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox