Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: "David Hildenbrand (Arm)" <david@kernel.org>,
	Matthew Auld <matthew.auld@intel.com>,
	linux-mm@kvack.org
Cc: dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Mika Penttilä" <mpenttil@redhat.com>,
	"Leon Romanovsky" <leon@kernel.org>,
	"Jason Gunthorpe" <jgg@ziepe.ca>
Subject: Re: [PATCH] mm/hmm: skip NUMA balancing on protnone faults
Date: Fri, 13 Nov 2026 21:34:43 +0100	[thread overview]
Message-ID: <1993e931e6a4b0cda5c04e72b1a8d5fb924f950a.camel@linux.intel.com> (raw)
In-Reply-To: <b32fb02a-68b4-4db9-83dd-254147dbf215@kernel.org>

Hi, David

On Fri, 2026-11-13 at 19:27 +0100, David Hildenbrand (Arm) wrote:
> On 11/13/26 17:25, Matthew Auld wrote:
> > When automatic NUMA balancing marks a PTE or PMD as protnone
> > (PAGE_NONE), hmm_pte_need_fault() requests a fault to restore
> > access
> > permissions, including _PAGE_RW when write access is needed.
> > 
> > Calling handle_mm_fault() from hmm_do_fault() currently triggers
> > NUMA
> > balancing in do_numa_page() and do_huge_pmd_numa_page(). When
> > hmm_range_fault() runs from a device driver or kworker context
> > (such as
> > a GPU SVM or userptr rebind worker), folios get migrated toward the
> > CPU
> > node executing the remote fault.
> > 
> > Also, each folio migration invokes try_to_migrate_one() ->
> > mmu_notifier_invalidate_range_start(), which invalidates the
> > caller's mmu_interval_notifier while holding mmap_lock. That causes
> > hmm_range_fault() to abort with -EBUSY after every 2 MiB PMD and
> > exhaust
> > its retry timeout on large buffers, which has been observed with
> > large
> > imported Xe userptr buffers.
> > 
> > Add FAULT_FLAG_NO_NUMA and set it in hmm_do_fault() so protnone
> > entries
> > restore PTE/PMD permissions in-place without performing NUMA
> > balancing,
> > matching GUP's default !FOLL_HONOR_NUMA_FAULT behaviour.
> 
> Ehm, that's not how it works.
> 
> GUP will not trigger a "special" fault and will try not triggering a
> fault and
> not restore permissions.
> 
> It will try continuing, leaving the protnone pte as it is.
> 
> See gup_can_follow_protnone().
> 
> For read-only access that should always work.
> 
> For write-access we always trigger an ordinary fault and do NUMA
> migration etc.
> 
> 
> So FAULT_FLAG_NO_NUMA is doing something completely different and I
> don't agree
> with it.
> 

There are two major problems with the current behaviour.

1) The work item executing hmm_range_fault() might have no affinity at
all to the GPU about to access the memory.

2) If migration happens, then hmm_range_fault() will stop and retry
leading to excessive execution time.

While perhaps Matt's commit message doesn't correctly describe the GUP
behaviour, do you have any alternative suggestion than to avoid
migration in this case? I think it's a reasonable idea given the
problems with the current code?

Thanks,
Thomas
 



  reply	other threads:[~2026-11-13 20:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 16:25 [PATCH] mm/hmm: skip NUMA balancing on protnone faults Matthew Auld
2026-11-13 18:27 ` David Hildenbrand (Arm)
2026-11-13 20:34   ` Thomas Hellström [this message]
2026-11-13 20:43     ` David Hildenbrand (Arm)
2026-11-13 20:53       ` Gregory Price (Meta)
2026-11-13 20:56       ` Thomas Hellström
2026-11-13 21:19         ` David Hildenbrand (Arm)

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=1993e931e6a4b0cda5c04e72b1a8d5fb924f950a.camel@linux.intel.com \
    --to=thomas.hellstrom@linux.intel.com \
    --cc=david@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=matthew.auld@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=mpenttil@redhat.com \
    /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