All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: mpenttil@redhat.com
Cc: dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v15 10/11] lib/test_hmm: add a new testcase for the migrate on fault
Date: Thu, 24 Sep 2026 07:27:57 +0000	[thread overview]
Message-ID: <20260924072757.D48111F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260924065313.899730-11-mpenttil@redhat.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] test_hmm: device page table desync on concurrent MMU invalidation
--

commit fba7f5abd6e7b21ba16a0224adb82cc24650eb6e
Author: Mika Penttilä <mpenttil@redhat.com>

lib/test_hmm: add a new testcase for the migrate on fault

This commit enhances the hmm test driver (lib/test_hmm) by adding a new 
testcase for the migrate on fault scenario.

> diff --git a/lib/test_hmm.c b/lib/test_hmm.c
> index cd88e8177d0ab..31608b6998bb2 100644
> --- a/lib/test_hmm.c
> +++ b/lib/test_hmm.c
[ ... ]
> @@ -1377,6 +1398,127 @@ static int dmirror_migrate_to_device(struct dmirror *dmirror,
[ ... ]
> +static int do_fault_and_migrate(struct dmirror *dmirror, struct hmm_range *range)
> +{
[ ... ]
> +		dmirror_migrate_alloc_and_copy(migrate, dmirror);
> +		migrate_vma_pages(migrate);
> +
> +		mutex_lock(&dmirror->mutex);
> +		if (mmu_interval_read_retry(&dmirror->notifier,
> +					    range->notifier_seq))
> +			ret = -EBUSY;
> +		else
> +			ret = __dmirror_migrate_map_locked(migrate, dmirror);
> +		mutex_unlock(&dmirror->mutex);
> +
> +		migrate_vma_finalize(migrate);

[Severity: Medium]
Will skipping the device page table update here create an inconsistent state
that migrate_vma_finalize() permanently commits?

In do_fault_and_migrate() in lib/test_hmm.c, if a concurrent page unmap (like
page reclaim) invalidates the MMU notifier interval between 
mmu_interval_read_begin() and mmu_interval_read_retry(), the retry check
fails and ret is set to -EBUSY.

However, migrate_vma_pages() has already executed and populated the CPU page
tables. By skipping __dmirror_migrate_map_locked() on retry, the device page
table is left desynchronized. When migrate_vma_finalize() is subsequently
called, the CPU page tables irreversibly commit the migration to device
private memory without the new device mappings.

Could this cause a wasteful ping-pong migration on the subsequent retry loop,
where hmm_range_fault() triggers a fault on these device-private pages, calls
the device's migrate_to_ram handler to bounce the pages back to system RAM,
only to migrate them to the device again?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260924065313.899730-1-mpenttil@redhat.com?part=10

  reply	other threads:[~2026-09-24  7:28 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24  6:53 [PATCH v15 00/11] migrate on fault for device pages mpenttil
2026-09-24  6:53 ` [PATCH v15 01/11] mm/Kconfig: changes for " mpenttil
2026-09-24  7:11   ` sashiko-bot
2026-09-24  6:53 ` [PATCH v15 02/11] mm: add helper to convert HMM pfn to migrate pfn mpenttil
2026-09-24  6:53 ` [PATCH v15 03/11] mm/hmm: preparations for HMM to participate in migration mpenttil
2026-09-24  7:09   ` sashiko-bot
2026-09-24  6:53 ` [PATCH v15 04/11] mm/hmm: do the plumbing " mpenttil
2026-09-24  6:53 ` [PATCH v15 05/11] mm/hmm: migrate collection in HMM pagewalk - pte level mpenttil
2026-09-24  7:10   ` sashiko-bot
2026-09-24  6:53 ` [PATCH v15 06/11] mm/hmm: migrate collection in HMM pagewalk - pmd level mpenttil
2026-09-24  7:09   ` sashiko-bot
2026-09-24  6:53 ` [PATCH v15 07/11] mm/hmm: add lazy MMU mode support for migration in HMM pagewalk mpenttil
2026-09-24  6:53 ` [PATCH v15 08/11] mm/hmm: implement rollback for device page " mpenttil
2026-09-24  7:16   ` sashiko-bot
2026-09-24  6:53 ` [PATCH v15 09/11] mm: enable device page migration from " mpenttil
2026-09-24  6:53 ` [PATCH v15 10/11] lib/test_hmm: add a new testcase for the migrate on fault mpenttil
2026-09-24  7:27   ` sashiko-bot [this message]
2026-09-24  6:53 ` [PATCH v15 11/11] Documentation/mm/hmm: document migration through hmm_range_fault() mpenttil
2026-09-24  7:28 ` ✗ CI.checkpatch: warning for Migrate on fault for device pages (rev7) Patchwork
2026-09-24  7:30 ` ✓ CI.KUnit: success " Patchwork
2026-09-24  7:46 ` ✗ CI.checksparse: warning " Patchwork
2026-09-24  8:09 ` ✓ Xe.CI.BAT: success " Patchwork
2026-09-24 21:10 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-09-25  9:07 ` [PATCH v15 00/11] migrate on fault for device pages Christoph Hellwig
2026-09-25 10:23   ` Mika Penttilä
2026-09-25 12:47     ` Jason Gunthorpe
2026-09-25 13:22       ` Mika Penttilä

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=20260924072757.D48111F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=mpenttil@redhat.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.