From: sashiko-bot@kernel.org
To: "Armas Spann" <zappel@simple-co.de>, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH v1 6/9] drm/amdkfd: keep eviction and restore consistent when MES fails
Date: Tue, 24 Nov 2026 16:30:58 +0000 [thread overview]
Message-ID: <sashiko-outbox-231572@kernel.org> (raw)
In-Reply-To: <20261124143433.49736-7-zappel@simple-co.de>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] drm/amdkfd: partial failure in restore_process_queues_cpsch()
breaks eviction
- [High] drm/amdkfd: kfd_process_evict_queues() overwrites -EIO across
multiple PDDs
- [Medium] drm/amdkfd: restore_process_queues_cpsch() misses GFX11
oversubscription work
--
commit 96e422e9089ef50f901d8f75facedb9f1a4d5c7f
Author: Armas Spann <zappel@simple-co.de>
drm/amdkfd: keep eviction and restore consistent when MES fails
This commit continues evicting remaining process queues when
remove_queue_mes() fails and returns -EIO, and defers marking queues active
in restore_process_queues_cpsch() until add_queue_mes() succeeds while
skipping already-active queues on retry.
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> index 0d40053b34c88..dbbc6c0794ed3 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> @@ -1900,11 +1900,24 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm,
> decrement_queue_count(dqm, qpd, q);
>
> if (dqm->dev->kfd->shared_resources.enable_mes) {
> - retval = remove_queue_mes(dqm, q, qpd);
> - if (retval) {
> - dev_err(dev, "Failed to evict queue %d\n",
> - q->properties.queue_id);
> - goto out;
> + int r = remove_queue_mes(dqm, q, qpd);
> +
> + if (r) {
> + /*
> + * -EIO means a GPU reset is under way or MES
> + * is fenced off, both reported already.
> + */
> + if (r != -EIO)
> + dev_err(dev, "Failed to evict queue %d\n",
> + q->properties.queue_id);
> + /*
> + * Keep going so that every queue ends up in
> + * the evicted state. The caller treats -EIO
> + * as evicted, not to be added back. MES may
> + * still use this MQD, so it stays pinned.
> + */
> + retval = -EIO;
> + continue;
> }
> }
[Severity: High]
Can kfd_process_evict_queues() lose this -EIO return value when a process
spans multiple PDDs?
In kfd_process_evict_queues(), a single variable r is overwritten on each
PDD iteration:
drivers/gpu/drm/amd/amdkfd/kfd_process.c:kfd_process_evict_queues() {
...
for (i = 0; i < p->n_pdds; i++) {
...
r = pdd->dev->dqm->ops.evict_process_queues(pdd->dev->dqm,
&pdd->qpd);
if (r && r != -EIO) {
dev_err(dev, "Failed to evict process queues\n");
goto fail;
}
n_evicted++;
}
return r;
}
When remove_queue_mes() fails on an earlier PDD and returns -EIO, the loop
continues and a later PDD that succeeds overwrites r with 0.
evict_process_worker() then sees a successful return, signals the eviction
fence while the unremoved queue on the earlier PDD may still be active in
MES, and schedules p->restore_work.
> @@ -2114,13 +2127,15 @@ static int restore_process_queues_cpsch(struct device_queue_manager *dqm,
> if (!QUEUE_IS_ACTIVE(q->properties))
> continue;
>
> - q->properties.is_active = true;
> - increment_queue_count(dqm, &pdd->qpd, q);
> + /* Restored by an earlier attempt that failed further down */
> + if (q->properties.is_active)
> + continue;
>
> retval = dqm_repin_mqd_bo(dqm, q);
> if (retval) {
> dev_err(dev, "Failed to repin MQD for queue %d\n",
> q->properties.queue_id);
> + q->properties.is_evicted = true;
> goto out;
> }
>
> @@ -2129,9 +2144,14 @@ static int restore_process_queues_cpsch(struct device_queue_manager *dqm,
> if (retval) {
> dev_err(dev, "Failed to restore queue %d\n",
> q->properties.queue_id);
> + q->properties.is_evicted = true;
> goto out;
> }
> }
> +
> + /* Count the queue as active only once MES has taken it */
> + q->properties.is_active = true;
> + increment_queue_count(dqm, &pdd->qpd, q);
> }
> if (!dqm->dev->kfd->shared_resources.enable_mes)
> retval = execute_queues_cpsch(dqm,
[Severity: High]
If dqm_repin_mqd_bo() or add_queue_mes() fails after earlier queues in
qpd->queues_list have already been restored, does jumping to out with
qpd->evicted still set to 1 prevent those active queues from being evicted?
The queues restored before the failure are now running in MES with
is_active = true and is_evicted = false. Because qpd->evicted remains 1, a
subsequent evict_process_queues_cpsch() hits "if (qpd->evicted++ > 0) goto
out;" and returns 0 without removing the running queues from MES or flushing
the TLB. With qpd->evicted now bumped to 2, the next
restore_process_queues_cpsch() retry only decrements qpd->evicted back to 1
and exits without restoring the remaining queues.
[Severity: Medium]
Does moving increment_queue_count() after add_queue_mes() skip scheduling
dqm->notify_unmap_work on GFX11 when the restored queue is the one that
crosses the oversubscription threshold?
add_queue_mes() checks dqm->active_cp_queue_count > get_cp_queues_num(dqm)
before returning. Because increment_queue_count() has not been called yet,
the final restored compute queue that brings active_cp_queue_count to
get_cp_queues_num(dqm) + 1 is not counted during that check, leaving
dqm->notify_unmap_work unscheduled.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124143433.49736-1-zappel@simple-co.de?part=6
next prev parent reply other threads:[~2026-11-24 16:31 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 14:34 [PATCH v1 0/9] drm/amdgpu/amdkfd: fix MES queue lifecycle on multi-GPU Armas Spann
2026-11-24 14:34 ` [PATCH v1 1/9] drm/amdgpu/mes: distinguish rejected from timed out commands Armas Spann
2026-11-24 16:19 ` sashiko-bot
2026-11-24 14:34 ` [PATCH v1 2/9] drm/amdkfd: factor out freeing of per-queue MES resources Armas Spann
2026-11-24 16:09 ` sashiko-bot
2026-11-24 14:34 ` [PATCH v1 3/9] drm/amdkfd: track whether MES knows each queue Armas Spann
2026-11-24 16:30 ` sashiko-bot
2026-11-24 14:34 ` [PATCH v1 4/9] drm/amdkfd: add a quarantine for queues MES has not retired Armas Spann
2026-11-24 16:29 ` sashiko-bot
2026-11-24 14:34 ` [PATCH v1 5/9] drm/amdkfd: keep queue storage until MES confirmed retirement Armas Spann
2026-11-24 16:29 ` sashiko-bot
2026-11-24 14:34 ` [PATCH v1 6/9] drm/amdkfd: keep eviction and restore consistent when MES fails Armas Spann
2026-11-24 16:30 ` sashiko-bot [this message]
2026-11-24 14:34 ` [PATCH v1 7/9] drm/amdkfd: apply queue property updates only after unmap Armas Spann
2026-11-24 16:42 ` sashiko-bot
2026-11-24 14:34 ` [PATCH v1 8/9] drm/amdkfd: reconcile queue state with MES after a restart Armas Spann
2026-11-24 16:53 ` sashiko-bot
2026-11-24 14:34 ` [PATCH v1 9/9] drm/amdkfd: force CWSR on with more than one MES GPU Armas Spann
2026-11-25 14:15 ` [PATCH v1 0/9] drm/amdgpu/amdkfd: fix MES queue lifecycle on multi-GPU Armas Spann
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=sashiko-outbox-231572@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=amd-gfx@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zappel@simple-co.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.