From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796155984; b=nKlHliqx/jAfFxTefQp7vcqukGd3IAfHf0YmFKEJdLReiJqBMixJ/wEflF1r82zp8QyZ d+zkXRvg5t1qy4nAXK0Xvw891k7NWMSgJKiapoY5YRZtjLMQbowV5Swc4PbytgwsIYxGj j2GkorqXaJubccOWOONcRsM5zKs5d9CzXo1ioAZYF3pl8hv4YOxkGQNQvdw8S2m6MtrH3 SCWh4I14BbSnqPtTXmk8t4NpVvHYCaqVlv2Wg/7ebf2Iur2UzJKHCD7QUMLjRegw6AhHV jhS29bnv0PIZ/apPbsWCukmn+oU97AUT11PiJirHS0iZARG2/u21GlmJ8fwXi5mmUGw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796155984; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=83hwlCUwHkAgR6ePTQvVuZFBbZCIDaWLcguBdOEDzxY=; b=RoYnLtFeT5Z6RLNkonRjXRxvwhEXogZOSjnzpjNVGuHFOwQ05nk6d7bB1Iq7d2u5fgVi hExPD1CikqC1WrhdI7yNwwev2rJ3tX4Wlm2T0MiJTe+bN2FYqg3P5byapl59N/1jfMRQa tesdtDhAZS+AgIznhW/P1iZZ7+rBrUCUIUWalFlg9oDA1YYbF3H4/BsCui2u1FmOqxjv8 7uxSfDCu0pq8gZfTpDF20YdeD9TTzhFhrb9x1ciGUeXXtT0oWTola8wdNS2Vijee25B6h IOz2gwoppIJPgUv3WdVAxQo5bsNd8Rget3/wbZALd603ScUcUxEUqFWd3+GEoYxH9SA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=QQaP5RG3; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05398606A31A for ; Tue, 1 Dec 2026 20:13:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=QQaP5RG3 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D46E1F00897; Tue, 1 Dec 2026 20:13:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796155983; bh=83hwlCUwHkAgR6ePTQvVuZFBbZCIDaWLcguBdOEDzxY=; h=Date:To:From:In-Reply-To:References:Subject; b=QQaP5RG38oWVQdjZ/5fP55rtz3xQ3NjOD4bSu+/TOL4gfH9MkypahvLDwzXaz2llF GL/uRbMFFk6GST7h87GPoAQJVAuOo/motRmN1+PXzp/yq0zT9ufm6RHpcZ5DvwCKcA 7l1MBZ3qLXtDjEssT2SWlPEL/Wl+hT2bqQ/Ckt1A= Date: Tue, 01 Dec 2026 12:13:02 -0800 To: mm-commits@vger.kernel.org,thomas.hellstrom@linux.intel.com, skinsburskii@gmail.com,matthew.brost@intel.com,leon@kernel.org, jgg@nvidia.com,nitin.r.gote@intel.com,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20261201130627.3544416-2-nitin.r.gote@intel.com> References: <20261201130627.3544416-2-nitin.r.gote@intel.com> Subject: + mm-hmm-fix-premature-ebusy-in-hmm_range_fault_unlocked_timeout.patch added to mm-new branch Message-Id: <20261201201303.3D46E1F00897@smtp.kernel.org> X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The patch titled Subject: mm/hmm: fix premature -EBUSY in hmm_range_fault_unlocked_timeout() has been added to the -mm mm-new branch. Its filename is mm-hmm-fix-premature-ebusy-in-hmm_range_fault_unlocked_timeout.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-hmm-fix-premature-ebusy-in-hmm_range_fault_unlocked_timeout.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Nitin Gote Subject: mm/hmm: fix premature -EBUSY in hmm_range_fault_unlocked_timeout() Date: Tue, 1 Dec 2026 18:36:28 +0530 hmm_range_fault_unlocked_timeout() starts its retry deadline before mmu_interval_read_begin() and mmap_read_lock_killable(), and checks it before calling hmm_range_fault_locked(). Both calls can sleep for a long time if another thread is invalidating or holds mmap_lock for write. Today, if that sleep is longer than the timeout, we return -EBUSY without even trying the fault, although nothing invalidated our range. This is seen with igt@xe_exec_threads@threads-hang-*userptr-invalidate*: one thread's mmap(MAP_FIXED) holds mmap_lock for write while the xe notifier waits for a hung job to time out. Another thread repinning its own userptr waits behind it for more than HMM_RANGE_DEFAULT_TIMEOUT, and DRM_IOCTL_XE_EXEC fails with -EBUSY: xe/xe_ioctl-CRITICAL: Failed assertion: __xe_exec(fd, exec) == 0 xe/xe_ioctl-CRITICAL: error: -16 != 0 Time spent waiting in mmu_interval_read_begin() and mmap_read_lock_killable() still counts toward the deadline, but only check for expiry after hmm_range_fault_locked() returns -EBUSY with mmap_lock still held, i.e. after an actual invalidation collision. A long wait therefore no longer fails on its own; the fault is always attempted at least once. The deadline is still reset when a fault drops mmap_lock. For drm_gpusvm_get_pages() this restores the behaviour of the open-coded loop the helper replaced, which only checked the deadline after hmm_range_fault() returned -EBUSY. Link: https://patch.msgid.link/20261201130627.3544416-2-nitin.r.gote@intel.com Fixes: 121170831228 ("mm/hmm: add hmm_range_fault_unlocked_timeout() for mmap lock-drop support") Signed-off-by: Nitin Gote Signed-off-by: Andrew Morton Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/work_items/9096 Reviewed-by: Stanislav Kinsburskii Reviewed-by: Jason Gunthorpe Cc: Leon Romanovsky Cc: Matthew Brost Cc: Thomas Hellstrom mm/hmm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/mm/hmm.c~mm-hmm-fix-premature-ebusy-in-hmm_range_fault_unlocked_timeout +++ a/mm/hmm.c @@ -823,15 +823,15 @@ int hmm_range_fault_unlocked_timeout(str return -EFAULT; } - if (timeout && time_after(jiffies, deadline)) { - mmap_read_unlock(mm); - return -EBUSY; - } - locked = true; ret = hmm_range_fault_locked(range, &locked); - if (locked) + if (locked) { mmap_read_unlock(mm); + /* Only act on an expired deadline after an invalidation collision */ + if (ret == -EBUSY && timeout && + time_after(jiffies, deadline)) + return -EBUSY; + } } while (ret == -EBUSY); return ret; _ Patches currently in -mm which might be from nitin.r.gote@intel.com are mm-hmm-fix-premature-ebusy-in-hmm_range_fault_unlocked_timeout.patch