From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EC868834 for ; Fri, 10 Jul 2026 18:03:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783706596; cv=none; b=dc0rYbg1N6NUlUDzFBmkxAXBXZAaC4jPfXvyVANCRWKQp9vmn8v8bIKly5oFNfZpzH3oXJUKdd/KwvEdqA2NNH1ZafnZJis4UnJOC8EKPHzfSNQPr1LP2+YJo9HWBI/trRnRip8Qin0YRLc79hYMgw5u7ROclvZLTr8alPHhyLA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783706596; c=relaxed/simple; bh=JK0Z967O7a8Bl55D2zvwLZqTqZpUiSqVWqaZiixu9aY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DyYLlmjAaBDrKu08alk1IUO6un6ucG0FHcCtAJjoylW54+fimuUjbUa0DK942xhbkAd7F4DwblbOIKwqspiWurBtJTJZyIwLN3Nsz14E/2SjNQ8/H41SMS199azMp+pjFYgB0dgViBTz2f1OVVhx0+gkFu1PwYz45hvT6JDe3SM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=XwYTQHDC; arc=none smtp.client-ip=209.85.160.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="XwYTQHDC" Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-51c2a449c57so7106881cf.1 for ; Fri, 10 Jul 2026 11:03:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1783706594; x=1784311394; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=pchhQjIZYIsHA+IyTP+kMOXOCiYK49mahPv3eolm7bw=; b=XwYTQHDCXEb07KED5ajRKK6taRPykEMNgPlbxgCoJ4mfSIU0+sBiMJHRZvdL3kDHT8 WQDYq82uKGVSKALSD9uEckizEuWQ2DNoYU63JJ+9rkYmF4JV6xkEWtvhkBJBR7bOI8Ve hdLqNf/imepRfwD/zhfXO415m1vIlJmlKR/Q8WaW2vExCXpBIfva58QADaj8xAfogDMx Nmes74qpwPyzJV1r7mdIV8ROCQq1aSF4UabkGgEs/994EN5u8W9eaU4JK49IMLDDM9Hd JAnfM7tOFwVTmMx0vJEgkpnMbRCPvl8dHdpcEhdItpTA+2L8Ss1sw4xDaMYfAX6TCA09 Bg/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783706594; x=1784311394; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=pchhQjIZYIsHA+IyTP+kMOXOCiYK49mahPv3eolm7bw=; b=hoyEurP4p8hWLsYe5I9B0Y/cbGO0EWq8Ok5uXUM9+I0pM4m2ghyLDLJLbAuQPk1DaA V9aLnb1IFA6IU6FFCV9nDUbd8nJj70G++NPcrIZwqZ6YTu1xcD7+7NNOSCK+qI23Nm4X u7nFmyYJXKNvlXrlhaaEcVaGaPLnz/JJebML4FeCRL7VDb2UwDzKesEv395jteZtk9fX xR0IqvhfIfSf8SU2UEohn9wIBF2K56qQmF9IOyfkXIc/TW0Qj0p/MVvqQWNnsOTLl7pU DLqqcKk9mVY+JcigZFQ3hw4je8FK0NNT/K2MATmswbxrcui+8UGKLrUYKloZj2N+4M02 revw== X-Forwarded-Encrypted: i=1; AHgh+RqJ+l0rvAo0aHvUL5hVYeGJwiqyL6eg6z03k08gk3YZoOUWrTLCdh+M8wY5amDT67zhIEmvs3ubLlwNZUQ=@vger.kernel.org X-Gm-Message-State: AOJu0YygWa221DAWcn0hAWDJKEyVnMUVBZkx4FWNSjKHjf8Lqfz7yUkU 4BcTy0f28cRP56IRJNcX3CEoZUP9vWNUqeYuGcAwWREWJ5OdGuUecDvq4sQ0cTH8n9g= X-Gm-Gg: AfdE7cmxHmmwlEjwUv6AHDeKgwckqPNgQ5lCB8szJaJdR3C/P4ziuxt23zAM0b5CLuy sZuuwLc74L4pKHGxc2JFQUY+Sfk1W1Q/YACjFMNABqowRQWA+Leq4pcMtOGeyY0WGAQZhQmhK4b /3+JPNAWaKhebsMqAs1f77tPY8rlrNQfx7B1Y8ccNyET3RlGfRPGHZeDSL0Oe0Tk8L+pNOQohGR 7KJRTysz/cvXJvKeAYLJGJVAmYhrX4O7XVFhQ9kpHmSH7oja4p53gddKIFeYKXIeTieiXiHm/Dc s7q0chkmQrnMRqqaj6StJ3pCdrprg0mUVR1rcYg3YH0y3PbQ8C/0Miz9H+Qxdb7nF/eLlzmkClC MI3GclVmqdD8Q/Fjtz9GZrALjZrw6I03xoKkxaGCFq/QwyTMhwSsG4HsacLRb X-Received: by 2002:ac8:7e8c:0:b0:51c:7b13:62fa with SMTP id d75a77b69052e-51c8b438c0dmr129494461cf.80.1783706594020; Fri, 10 Jul 2026 11:03:14 -0700 (PDT) Received: from ziepe.ca ([159.2.72.92]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8ffd7c1fd2bsm47060696d6.27.2026.07.10.11.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2026 11:03:13 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1wiFZA-00000007fhc-13JV; Fri, 10 Jul 2026 15:03:12 -0300 Date: Fri, 10 Jul 2026 15:03:12 -0300 From: Jason Gunthorpe To: Stanislav Kinsburskii Cc: airlied@gmail.com, akhilesh@ee.iitb.ac.in, akpm@linux-foundation.org, corbet@lwn.net, dakr@kernel.org, david@kernel.org, decui@microsoft.com, haiyangz@microsoft.com, kees@kernel.org, kys@microsoft.com, leon@kernel.org, liam@infradead.org, lizhi.hou@amd.com, ljs@kernel.org, longli@microsoft.com, lyude@redhat.com, maarten.lankhorst@linux.intel.com, mamin506@gmail.com, mhocko@suse.com, mripard@kernel.org, nouveau@lists.freedesktop.org, ogabbay@kernel.org, oleg@redhat.com, rppt@kernel.org, shuah@kernel.org, simona@ffwll.ch, skhan@linuxfoundation.org, surenb@google.com, tzimmermann@suse.de, vbabka@kernel.org, wei.liu@kernel.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-rdma@vger.kernel.org Subject: Re: [PATCH v7 2/8] mm/hmm: add hmm_range_fault_unlocked_timeout() for mmap lock-drop support Message-ID: <20260710180312.GD1803712@ziepe.ca> References: <178345345668.660027.2952911919681614557.stgit@skinsburskii> <178345362182.660027.12809852179204464964.stgit@skinsburskii> <20260710162749.GP118978@ziepe.ca> <20260710164743.GX118978@ziepe.ca> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Jul 10, 2026 at 10:02:55AM -0700, Stanislav Kinsburskii wrote: > The main customer for this new feature I have in mind is the MSHV driver > which backs VMs memory with HMM, requires userfaultfd support for > post-copy live migration and fast restore and it doesn't timeout. > > I agree, that this current timeout value used by the other callers might > not be enough to repopulate the mappings with userfaultfd, but there > drivers would get -EFAULT for uderfaultfd-backed mappings without this > change anyway, so getting -EBUSY with the change instead doesn't look > like a significant change to the behaviour from my POV. It sounds like it won't be reliable either then. > > So, maybe the deadline should be resetting after every handled fault? > > ie the timeout really is only about the mmu notifier and we don't > > count the time spent handling faults or walking? > > The timeout was inherited from existing HMM users rather than introduced > as a new HMM policy. Some GPU drivers use HMM_RANGE_DEFAULT_TIMEOUT as a > budget for the whole range population operation, including HMM retries > and subsequent driver mapping work. Yes, because we always had a timeout around the notifier because that scheme can sort of live lock. The timeout was to protect that only, ie limit the number of notifier retries. Expanding the timeout to be outside what is bounded by the notifier retry is not right, and heavy stuff like mapping should be done after the hmm side succeeds and the notifiers concluded so they can rely on normal locking instead. This is why I'm suggesting to reset the deadline as hmm makes forward progress, we really only want to bound the notifier retry loop not anything else. Jason