On Thu, 23 Jul 2026 10:36:32 -0700 Stanislav Kinsburskii 
<[email protected]> wrote:

> This series extends the HMM framework to support userfaultfd-backed memory
> by allowing the mmap read lock to be dropped during hmm_range_fault().
> 

Thanks, I've updated mm.git to this version.

AI review suggests there may be some problems.  Sorry, I don't recall if
these were considered in previous versions of the patchset:

        
https://sashiko.dev/#/patchset/[email protected]

> 
> Changes in v11:
>   - Reject unstable address spaces in hmm_range_fault_unlocked_timeout()
>     after taking mmap_lock and before walking page tables.
>   - Compute the remaining HMM timeout budget before the time_after_eq()
>     check in drm_gpusvm_get_pages() to make sure it can't result in zero
>     and lead to infinite HMM range faulting loop.

Here's how v11 altered mm.git:


 drivers/gpu/drm/drm_gpusvm.c |    4 ++--
 mm/hmm.c                     |    6 ++++++
 2 files changed, 8 insertions(+), 2 deletions(-)

--- a/drivers/gpu/drm/drm_gpusvm.c~b
+++ a/drivers/gpu/drm/drm_gpusvm.c
@@ -1422,11 +1422,11 @@ int drm_gpusvm_get_pages(struct drm_gpus
        struct dma_iova_state *state = &svm_pages->state;
 
 retry:
+       remaining = timeout - jiffies;
+
        if (time_after_eq(jiffies, timeout))
                return -EBUSY;
 
-       remaining = timeout - jiffies;
-
        hmm_range.notifier_seq = mmu_interval_read_begin(notifier);
        if (drm_gpusvm_pages_valid_unlocked(gpusvm, svm_pages))
                goto set_seqno;
--- a/mm/hmm.c~b
+++ a/mm/hmm.c
@@ -17,6 +17,7 @@
 #include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/mmzone.h>
+#include <linux/oom.h>
 #include <linux/pagemap.h>
 #include <linux/leafops.h>
 #include <linux/hugetlb.h>
@@ -806,6 +807,11 @@ int hmm_range_fault_unlocked_timeout(str
                if (ret)
                        return ret;
 
+               if (check_stable_address_space(mm)) {
+                       mmap_read_unlock(mm);
+                       return -EFAULT;
+               }
+
                if (timeout && time_after(jiffies, deadline)) {
                        mmap_read_unlock(mm);
                        return -EBUSY;
_


Reply via email to