From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) (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 51B6A3CF960 for ; Fri, 10 Jul 2026 16:41:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783701667; cv=none; b=q/xv+X3NKb2zQHwAB43deTogz0K5LR3sgPG5620wyUYlg2a65yJLLdH7PopFZ6vn/pebdcLMXXNUZIlwZpNPYV9yIablGVotDVABMh8DLq0jgG2wuqmeXrxzfvXkJzq10zC+JwbqlQPOhTeGGVL8Ms9FkUTcJxiC+FRjU6bzif8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783701667; c=relaxed/simple; bh=97gDvxv4aZQT4UUmzVBR2oQfVgbx3iRf3Vdj/SRY1i0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=M5uG9HRAyhqPvYEur0iUanS686/8L4n/8A1efPZyN+mmGzvbZ/6AUErOq3OV3S8TbjMOm23eZeeuOEH7Y4r2MzjQNQboJf2xAlnOgBu/7dSf3d0qxJEHy/1iOBfC0Z0RxT/p5H8jRt179nKX8a5mB15bxWXvQUiHs7CMXLmBVcw= 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=H4JDKSpr; arc=none smtp.client-ip=209.85.160.177 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="H4JDKSpr" Received: by mail-qt1-f177.google.com with SMTP id d75a77b69052e-51c08df8513so6767861cf.3 for ; Fri, 10 Jul 2026 09:41:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1783701665; x=1784306465; 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=z7U3THTZDjx6I8tSiQ91l//DDsukKiO5Egsu4KIAjvc=; b=H4JDKSprNq69KrAblUxp9+Zyv83+SaEGahDvSRbidlssa+EH9fcy7sXcUGlkIVlJ14 QHC9sawO+9coKNk6TW0DMeJRa4BKYtQXEyNhoYpfGyyFUpB/WgHdqfuynRN+YQyDRqyY 0VAvdxffBtpO5wEHvvQd5E3W6O0DETwFjnX3oyYhh4wfSCVBfyyQovbR30v253EPf5YF yFlPypUrAxIZSndhq/wBRRWhR3H28IpgBWxBvFm8DVOJHFdt0ENnfaJl4B5tUZg/3rFp kK97vUHolwefDzcWod9yNLgbb/fRdxz3UZNhdjY+jXoOuqD+htNEv6EfrgRk7y4oqUvP lPmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783701665; x=1784306465; 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=z7U3THTZDjx6I8tSiQ91l//DDsukKiO5Egsu4KIAjvc=; b=rHvRUq/8d00t8jqK08UJ1lbfTUSNGfwnRq+J9qgeXydnj5FicanajOskUDTB8l+NNO g/hGnmubf5xqfjTcSrGaOouX2xJMJvzuoudpANsBzYVSKp2ZJL6y/iVs2v3ty9IW9YUm PYFKiQcQfgWF5WKbBhSRLjFrwbjqmEk3UbsNOy6yLOhnQW90jLnNJTngPo6RXHIsaopR UYzDrMiCit67Hg1NIPci5rfWt+A4olHdHqXeDNgvSQcPHhirAr56XiqmIXlkdN3DsI/7 GPL5JQOdP93nSFa7W0+qovsYNZRNplLQAcicDWc5tXYmS3ckOOAvHX7IZx5NcRT7WGB0 Qp+w== X-Forwarded-Encrypted: i=1; AHgh+RrFq7AtkRpYXPZ/pATD7KN72HdM68PTDgY4yTPXP9Me4nwkEkJjanMzP7BBHdbXIZxjKFradsVC7j8=@vger.kernel.org X-Gm-Message-State: AOJu0YwiYEpTKaucpjfKuSCKekeL2XqAMFA++CcH0Sl90WlD1L8wBKGL d9dZpp5xCNMlf4dlPa2QQKaybU8M0qBlyrrPhL/u6ghuT5XZI32AErsOnZOe9EUTIbQ= X-Gm-Gg: AfdE7ckZf8eFFTtm7bZ+RuOsTefADiaANJOSBdbT9RzgFDdVBzErhw6/GoGfy4clGvJ jf6PNYJ5c83ff17q/6q6stVyJQrcK7kY1HTVW2xqLkKcXapkETwY+iuW3i/FUhyPWzdwYxvVwFt ZrMz3XkpwXZSmuaOa9YMO9T20CLqCgwoiplL7myeeqliWcM2yg0e78WpBreSwsEBwb0RVFtJTMe dcGM3kWlNjcQuHu8s6J7YMN/I/TlvkLqN5B1F+q4der+WG1W9sHi/NEFazMHA530QDd+FLFlFO9 jGbOOSK4sDG0MS9c+b2mMT4KZ8VVhd4pO0M/Sl1UR22gqEi908Nhwrbh7cMVnQJOQHQ0kxYuH98 99o4kRDfBRhlI7XnqlOw/QCqGrJOPFBGDjG7/nlhT2e425ZMbV17g3Av+Q0xhdaMWzLu1ftM= X-Received: by 2002:a05:622a:558d:b0:51c:164b:b241 with SMTP id d75a77b69052e-51c8b2d5582mr133755821cf.13.1783701660503; Fri, 10 Jul 2026 09:41:00 -0700 (PDT) Received: from ziepe.ca ([159.2.72.92]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8ffd50e0347sm45334476d6.2.2026.07.10.09.40.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2026 09:40:59 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1wiEHb-00000007Yc5-1TXt; Fri, 10 Jul 2026 13:40:59 -0300 Date: Fri, 10 Jul 2026 13:40:59 -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 5/8] drm/nouveau: Use hmm_range_fault_unlocked_timeout() for SVM faults Message-ID: <20260710164059.GT118978@ziepe.ca> References: <178345345668.660027.2952911919681614557.stgit@skinsburskii> <178345364273.660027.15274510603185163961.stgit@skinsburskii> Precedence: bulk X-Mailing-List: linux-doc@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: <178345364273.660027.15274510603185163961.stgit@skinsburskii> On Tue, Jul 07, 2026 at 12:47:22PM -0700, Stanislav Kinsburskii wrote: > nouveau_range_fault() takes mmap_read_lock() only to call > hmm_range_fault(). It also keeps a single HMM_RANGE_DEFAULT_TIMEOUT > deadline across both HMM -EBUSY retries and post-fault > mmu_interval_read_retry() retries. > > Use hmm_range_fault_unlocked_timeout() instead. The HMM helper now owns > the mmap lock and refreshes range->notifier_seq for its internal retries. > Nouveau keeps its existing absolute deadline in the outer loop and passes > the remaining jiffies to the helper for each fault attempt, so retries > caused by mmu_interval_read_retry() do not reset the overall retry budget. > > Nouveau still validates the interval notifier sequence while holding > svmm->mutex before programming the GPU mapping. > > Signed-off-by: Stanislav Kinsburskii > --- > drivers/gpu/drm/nouveau/nouveau_svm.c | 11 +++-------- > 1 file changed, 3 insertions(+), 8 deletions(-) Reviewed-by: Jason Gunthorpe > - range.notifier_seq = mmu_interval_read_begin(range.notifier); > - mmap_read_lock(mm); > - ret = hmm_range_fault(&range); > - mmap_read_unlock(mm); > - if (ret) { > - if (ret == -EBUSY) > - continue; > + ret = hmm_range_fault_unlocked_timeout(&range, > + max_t(long, timeout - jiffies, 1UL)); Avoid max_t, 1L should be a signed long. Though I'm even more concerned about the timeout if drivers are now wrapping the whole thing in a timeout... That's not sensible at all Jason