From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (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 8EA0B43CEFE for ; Fri, 10 Jul 2026 16:47:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783702070; cv=none; b=uhIvZnb3yFX5sBZmCVFXw6kfrZUwOLUDY2L40hGSmV5ii3UWIoewz7uKXghXVpMTVfzoE52j2DiGp7XX/T31H0L3UT558idbKpNR/rSBKepm+esHMna2jk+gOm2z26khRknf01t2hxMghOpgttUJilN5CM4mQLqQWh7a4dG6298= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783702070; c=relaxed/simple; bh=5mY/LNzOoYWIQwJjGaIbGESQyPbUXU5+u9YysOMf/yw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AMe/TwHdp0ol+jtZsADYrJoRjlvTW7qTdSjG/VufI+Vni8bplzL2RG5NxQ2dgE3v6IcNS+XHqT6zA/1r9jBOtkMJSkCHUKLEVsdntuStEj4LA/ALT+BwfaOj2T02VrkAh21rmllzAL95qzqB7/OBYAuCbV3x6KlmaxywRi5va68= 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=pJjUs4fx; arc=none smtp.client-ip=209.85.222.170 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="pJjUs4fx" Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-9204711e831so93963985a.2 for ; Fri, 10 Jul 2026 09:47:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1783702065; x=1784306865; 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=ldYpDeT5zs3T98XMfsT8ni9uE73SXe2oYxwTATvCf1s=; b=pJjUs4fxJRRV4JyKYlLYpWw2bzk38dHrOh6nkT9Fk9sBD5r2HLAYjShp/o6Cg6ZF/q Gcp+e2f0MX07bpFIZtTZE3rC/QY83URHHcn/Y7Of2fITSLy3FIy18aw7x1UoV35GELov dNC0vVBsROWvwix7FeVYppBiNutBs7LzTTbELawNd6P7ReUVwboVJ66LT1SzaVt3ZDbv cwpfjr33yr5c0UpQqB072mC1rty2Ao2KZWj4gV2U8OvZPENCqA2SvCxk2+P4seYkMskX N8kFoYFWDXKD+KoWDBl/g/WHzBDxI+NIKG4vTr/cF/0hgOXKAAnzXeMOSvwbBLoVQWwl RI1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783702065; x=1784306865; 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=ldYpDeT5zs3T98XMfsT8ni9uE73SXe2oYxwTATvCf1s=; b=COO8ImccO1yAei3+nSeHCBgf0cSLnFO9MDoCGIHP7bISHuCstIw9xE07/3EEEs6Ol5 mdl4bwXNmja057MVZO5ykxK6z7Fng/O79iySbpRREFSoZ1nE3FL+hLlYHtDZplWnKNuV 63YZGWlCzVem+7TVa/nponSElyf3OiQ+w5KudBZgX5p8VuNlm3pPb+lb8qDF/TctbPnf X91Z5+tstoyhZ5nvhVa6ByWz7tPcPFZh1VbfjsB69EbuxtDKkuS8cjPt9traSH5BNFQR ea7PJX15v4W3v3EgyFImTgvTR10KM5r6kLAnbnXtNa3YUMaCb7Ph00vcug7LbX87dFAJ cU8w== X-Forwarded-Encrypted: i=1; AHgh+Rp/WDNHFrefD6w6Ap/PtbQ0nJi3DA2T2uvZAkFU7V7LKKNWyPGzJMQ8crQp/8RQTRu8ZwwqiBAUl/0/y7U=@vger.kernel.org X-Gm-Message-State: AOJu0YzVAV6mwL0mFqS8DbsJCTRUjFn+7VWHAGYI9uvHE7jWhjzGZa3L jvrnJXM7HtOsMDQZ7juO3j9ZQrYIou8r6shjW8Xzl7LbF5VbBJZpk7zMLJ+1rHgpcuM= X-Gm-Gg: AfdE7cl3cdnMHGIXlMjD+P4n+4uTLRF0gPU7f5nTmRX9yjShbw3h5xCNdLZmSdZq2wC 4fuEQq1AB7O82cukFXmgnZDMwibQgbMXfOvkuOv1KjEBZhISw/We4ES4WeB7SL1MF/5fLNuAJN1 B0A/v6BXgXOhedxxKBqnF7gAJ9zeudBJh8eY+x4YGrU9IRAI5mJnN3oYL5lujttFGgZDybYZqH/ nrKWxOb+qvRXcG2I4/wNwETv3uFzMF3Q2fbbzWfcynk0rihQKEenuT9MgacSgL8+ubJRqBtfX10 BkrY/PKfyq3FG4g3685JO3lnOUyH0874VFEMLr7remrp5orivFxDTcFV+mSp1mezdCv7Fntlb7o YxYe58xNfIiEMX3iXi5yxfcQV7/id/HCSzWtoa784zvo6N8IgpabVT86YyjYb X-Received: by 2002:a05:620a:4044:b0:92a:3ceb:9cf1 with SMTP id af79cd13be357-92ecf68b839mr1385461685a.37.1783702065110; Fri, 10 Jul 2026 09:47:45 -0700 (PDT) Received: from ziepe.ca ([159.2.72.92]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8ffd5bbac2asm45778726d6.21.2026.07.10.09.47.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2026 09:47:44 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1wiEO7-00000007ZDn-3hnt; Fri, 10 Jul 2026 13:47:43 -0300 Date: Fri, 10 Jul 2026 13:47:43 -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: <20260710164743.GX118978@ziepe.ca> References: <178345345668.660027.2952911919681614557.stgit@skinsburskii> <178345362182.660027.12809852179204464964.stgit@skinsburskii> <20260710162749.GP118978@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: <20260710162749.GP118978@ziepe.ca> On Fri, Jul 10, 2026 at 01:27:49PM -0300, Jason Gunthorpe wrote: > On Tue, Jul 07, 2026 at 12:47:01PM -0700, Stanislav Kinsburskii wrote: > > > +int hmm_range_fault_unlocked_timeout(struct hmm_range *range, > > + unsigned long timeout) > > +{ > > + struct mm_struct *mm = range->notifier->mm; > > + unsigned long deadline = 0; > > + int locked, ret; > > + > > + if (timeout) > > + deadline = jiffies + timeout; > > + > > + do { > > + if (fatal_signal_pending(current)) > > + return -EINTR; > > + > > + if (timeout && time_after(jiffies, deadline)) > > + return -EBUSY; > > I really dislike there is a timeout here, HMM is supposed to be more > deterministic. GUP doesn't have a timeout, what is this about? It looks like you've moved the timeout processing related to the mmnu notifier sequence from the callers into this helper. I'm fine with that, but maybe add some comments that this timeout is helping implement the mmu notifiers, and we do expect that the HMM part will not timeout. Though it is a little hard to see how your stated purpose of enabling userfaultfd is going to work, aren't you pretty much guarenteed to hit a timeout if the userfaultfd process is adversly scheduled? That's going to end up broken. 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? Jason