From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) (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 E691133F38A for ; Fri, 10 Apr 2026 15:40:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775835614; cv=none; b=JkiEjrWqEvWFayeiP2/i43FOAaIfryTeA6p6gI0DY3De7LKlrK/DZaGpliJVYXFz0S6h6eu1zQBCpa3m/Dk/zO+Sb3FaCyeGCH3NMllYLlIuH00E8RHZEob+EG1oIpJeR/TDXxmm6fXGP+LEC56I3AWVUTmsMI87X7gQTpDX69M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775835614; c=relaxed/simple; bh=VGrAYDcWAIt6hfLkvJx3TgjmPVRhySPvgKax5RpznGA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=j3ACBOmLNSp4/8gP2FzEtUjak3ErKRp8l7VU2atvUX2SYmyJjhmGeXuHzpCxUA/syf2O9kb4VwGVOOklCanHJbiH7CFGi7457Q16/ATB0S+ubFA4K0HFReIKL/8nNi3S1GDRO1fV6tdMW8SBpyL/mpHXkKLciyrHwQ5bq6aNrgE= 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=CHKFJ8Dz; arc=none smtp.client-ip=209.85.219.52 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="CHKFJ8Dz" Received: by mail-qv1-f52.google.com with SMTP id 6a1803df08f44-8a08fa355a1so31459736d6.0 for ; Fri, 10 Apr 2026 08:40:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1775835612; x=1776440412; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=P+N+RyRq+4Lu2ncfMlDfFIZSLyoiGyTWZ5uga3Pmg4s=; b=CHKFJ8DzPFtgUZj8ly5pmuDibe9dovQP1NHyN311eIrNMp4PTi3kJne/I+a51MUjSd tQ1yaAiCpnHssz5MFACp9VjnjEa4N6Vy5bRh/rNThzkatlfCC8BOsvQ1blkOx+RZrPvf OhunQYxbNHtYurXDUnZ3rmTIe+H4sgcjtw46cs7Ki65Lmy9HskqFAKnlPu1Bd2JS9DX0 cKR36hZG7g2WmZLMmgyaHec7IPTZjBLleM74p79iMEevGSgN4tXN1h+CZHEbPm12/yZ6 aWp8eDEyzOsWpZQI6yRWIhcHRSGnxN4zp+16+IljfS2Zj+99wEyUol/yLeDwH7hn/qMU tMsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775835612; x=1776440412; h=in-reply-to:content-transfer-encoding:content-disposition :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; bh=P+N+RyRq+4Lu2ncfMlDfFIZSLyoiGyTWZ5uga3Pmg4s=; b=JFC/jbayT5oHxdTGXPUPel7/jBoJz56G+PuP1JU1Vg79uZpw3tqLCVs5Ub+lhu0h45 hd3RGQ7BBaEwoRB7t0tFwHBah5XrvCqfQ8TqA9UxUkmL/pwYlNWUTESqP1caRLhcMPZn +3VZN0LodYzQL8YEnkoB6OEv7aqNhJcWNu1c4rbndjcR9WxvnDA/f9Ikoef1Z5ErjA96 CF3hoo52JNiQ5gzsQX3KdJXZBicsba2yrpTn7nOBg5ux6ee3MKx/H9mUKpvbusb0qfGI PNpvcjbAqmkQnCkwpUGpgWH5Pt9SmOdoK7J5igrI6b4m+I3mxKOaeR2FbYAUQg5BaAHV G3ug== X-Forwarded-Encrypted: i=1; AJvYcCVtRajAff/dX0tAYANfNjVotoKcIgvybd1mwfYUQ3+QBn2G8max2AhLn0XjaDhJ3kbs8Yv2qJ7X1e6oLew=@vger.kernel.org X-Gm-Message-State: AOJu0YzU3j9XYywKMJm/vwKCXHi8gofWMRRuZJbBFOjdKTO2FiSS6y0q BW0zNsxp3HjC7ewSTU8l28VxgO63aevlu8B9AOgEmWIA8V06WVb04xLPQLUyebcXPLA= X-Gm-Gg: AeBDieu7cieH8pxRGqg/MPUcWXQPjZ5dQ7uAgWQUoXBHurFvn1qZnDRQCh2KbS2bm7r MU4POEa1D+hgXs46tW9LQhPSXFy7O843dmpn5+0yPo1BxzZeCKtsVHnlHDHXCxRpnjjslJ/8/Au +1NU2eFgURPj6wnz3Xt7F/3HN5jKTc8kJJ4ZSGphzBjDwsANfxI+YKDgnCPR/uO1h//2e3RgaG6 Qt9x++T1qdT7hXuXXAULEGNtfUhiTxtKDb0P/ZmbWRVkO6Ky2LQaSkoWz4XaZYIhttIvTMUWX05 cXsGYQ5TIT06xLbyLWBcCP1iW1LogjA/wQyfd6//fgr5ZsFrdAMIw+9wY3D3EqUqur8+st5Bq4I GKo4gigHpGbYnnuRsn1RI0cHMZG2CcIOQRNvNHxtCkBOMzJiJTpfs6R+Loyo9tJkMQyNfqSTt26 OLnK1JpkNrBYEhfD57/MF69lAVJOumWBY+x2jqMCffRSzHBD/f1uaUlO0FYnIJppDUmAJCUQ== X-Received: by 2002:a0c:f118:0:b0:89c:5c57:98c with SMTP id 6a1803df08f44-8ac861b003cmr41115156d6.18.1775835611674; Fri, 10 Apr 2026 08:40:11 -0700 (PDT) Received: from ziepe.ca (mctnnbsa70w-159-2-73-22.dhcp-dynamic.fibreop.nb.bellaliant.net. [159.2.73.22]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8ac84a104ddsm24587146d6.14.2026.04.10.08.40.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2026 08:40:11 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1wBDxq-0000000EhY3-2N2g; Fri, 10 Apr 2026 12:40:10 -0300 Date: Fri, 10 Apr 2026 12:40:10 -0300 From: Jason Gunthorpe To: Thomas =?utf-8?Q?Hellstr=C3=B6m?= Cc: intel-xe@lists.freedesktop.org, Matthew Brost , Christian =?utf-8?B?S8O2bmln?= , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Andrew Morton , Simona Vetter , Dave Airlie , Alistair Popple , dri-devel@lists.freedesktop.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 1/4] mm/mmu_notifier: Allow two-pass struct mmu_interval_notifiers Message-ID: <20260410154010.GZ2551565@ziepe.ca> References: <20260305093909.43623-1-thomas.hellstrom@linux.intel.com> <20260305093909.43623-2-thomas.hellstrom@linux.intel.com> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260305093909.43623-2-thomas.hellstrom@linux.intel.com> On Thu, Mar 05, 2026 at 10:39:06AM +0100, Thomas Hellström wrote: > GPU use-cases for mmu_interval_notifiers with hmm often involve > starting a gpu operation and then waiting for it to complete. > These operations are typically context preemption or TLB flushing. > > With single-pass notifiers per GPU this doesn't scale in > multi-gpu scenarios. In those scenarios we'd want to first start > preemption- or TLB flushing on all GPUs and as a second pass wait > for them to complete. > > One can do this on per-driver basis multiplexing per-driver > notifiers but that would mean sharing the notifier "user" lock > across all GPUs and that doesn't scale well either, so adding support > for multi-pass in the core appears to be the right choice. > > Implement two-pass capability in the mmu_interval_notifier. Use a > linked list for the final passes to minimize the impact for > use-cases that don't need the multi-pass functionality by avoiding > a second interval tree walk, and to be able to easily pass data > between the two passes. > > v1: > - Restrict to two passes (Jason Gunthorpe) > - Improve on documentation (Jason Gunthorpe) > - Improve on function naming (Alistair Popple) > v2: > - Include the invalidate_finish() callback in the > struct mmu_interval_notifier_ops. > - Update documentation (GitHub Copilot:claude-sonnet-4.6) > - Use lockless list for list management. > v3: > - Update kerneldoc for the struct mmu_interval_notifier_finish::list member > (Matthew Brost) > - Add a WARN_ON_ONCE() checking for NULL invalidate_finish() op if > if invalidate_start() is non-NULL. (Matthew Brost) > v4: > - Addressed documentation review comments by David Hildenbrand. > > Cc: Matthew Brost > Cc: Christian König > Cc: David Hildenbrand > Cc: Lorenzo Stoakes > Cc: Liam R. Howlett > Cc: Vlastimil Babka > Cc: Mike Rapoport > Cc: Suren Baghdasaryan > Cc: Michal Hocko > Cc: Jason Gunthorpe > Cc: Andrew Morton > Cc: Simona Vetter > Cc: Dave Airlie > Cc: Alistair Popple > Cc: > Cc: > Cc: > > Assisted-by: GitHub Copilot:claude-sonnet-4.6 # Documentation only. > Signed-off-by: Thomas Hellström > --- > include/linux/mmu_notifier.h | 42 +++++++++++++++++++++++ > mm/mmu_notifier.c | 65 +++++++++++++++++++++++++++++++----- > 2 files changed, 98 insertions(+), 9 deletions(-) Reviewed-by: Jason Gunthorpe Jason