From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FCAD33689C for ; Thu, 5 Mar 2026 09:39:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772703586; cv=none; b=DNvnaaxtkQ3046CBPwvim9iN5JVTGMyL7z92fVvopOipr0Nkmh46AUYqcRTetSATMrE8iqR3VYYnHY8FgTNKkfMjkoQ+z/dhGmtjcKpjNX7G1a8q/hRTdqQDGL1r2Ci0PNxA3rpIkh8mxExQspemJs2+nbMi6vNP3f+JN8zCQkk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772703586; c=relaxed/simple; bh=bpL7MiGzLlgeJDkxUeNpB6VxlUDAZkq+QvjkG45XU8o=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=B/yw2fbqB0C+A//WviTRkd+tX/cbGsNlXkou6bBhibrZaiik6VMB9ObUiBfV6non4nYZ3QvG+OyFwQCJJVuQ5SnaDeM8GquN1fcc/Co2YxmKHhVDxEk8eGaq7CGzW1SqO3e3YN5dHhaHOixllxTKLtOJVhf3N3tssIKfHUYKYOc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Y3W5Xc2v; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Y3W5Xc2v" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1772703585; x=1804239585; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=bpL7MiGzLlgeJDkxUeNpB6VxlUDAZkq+QvjkG45XU8o=; b=Y3W5Xc2vXJ2eth6YmKCnLzM+gfcsR0mR2BohsgB4KH55lldWw6+T0f+I VQbT9XV7OUhVZLZyDmFT++pb7ASzLFRF7cDakyiEQuHIv8l9yHPOY4IEz 1BqsZQ+1yQjkWMHTSI+13NzSGU/X0PreBXxjavTYh5FhcZwn648uU++H5 s9f1UXJgqRnM8pKT3CkQIpb0TpMcgKlKx/S88E6dL132ZKLVGNIbaO9If 8gNdzB7Mfzpaq/RGtWOQtC7u4jSB09EXgrszzSg9s+17rjSXJexqPMXP2 QCMW629P1+H3TneaBWpkMzYpIfIgyjYLVS279KYadsh5FiqWbc50dkpl+ A==; X-CSE-ConnectionGUID: 2AC0iwcsRQS+WMkKzU/LuA== X-CSE-MsgGUID: t+dxGCKmTvyk9oy6whf9Cw== X-IronPort-AV: E=McAfee;i="6800,10657,11719"; a="84870943" X-IronPort-AV: E=Sophos;i="6.23,102,1770624000"; d="scan'208";a="84870943" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2026 01:39:44 -0800 X-CSE-ConnectionGUID: XlUf5igBRuegKqAZriXKgQ== X-CSE-MsgGUID: kIk+aQ3GRXqvHx1gbHabNQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,102,1770624000"; d="scan'208";a="214684973" Received: from vpanait-mobl.ger.corp.intel.com (HELO fedora) ([10.245.244.71]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2026 01:39:40 -0800 From: =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= To: intel-xe@lists.freedesktop.org Cc: =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Matthew Brost , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jason Gunthorpe , Andrew Morton , Simona Vetter , Dave Airlie , Alistair Popple , dri-devel@lists.freedesktop.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 0/4] Two-pass MMU interval notifiers Date: Thu, 5 Mar 2026 10:39:05 +0100 Message-ID: <20260305093909.43623-1-thomas.hellstrom@linux.intel.com> X-Mailer: git-send-email 2.53.0 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-Transfer-Encoding: 8bit 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. This also applies in non-recoverable page-fault scenarios to starting a preemption requests on GPUs and waiting for the GPUs to preempt so that system pages they access can be reclaimed. 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 two-pass in the core appears like the right choice. So this series does that, with pach 1 implementing the core support and also describes the choices made. The rest of the patches implements a POC with xeKMD userptr invalidation and potential TLB-flushing. A follow-up series will extend to drm_gpusvm. v2 hightlights: - Refactor the core mm patch to use the struct mmu_interval_notifier_ops for the invalidate_finish() callback. - Rebase on xe driver tlb invalidation changes. - Provide an initial implementation for userptr instead of drm_gpusvm. The intent is to handle drm_gpusvm in a follow-up series. v3: - Address review comments from Matt Brost: Code formatting, documentation, additional asserts and removal of unnecessary waits, as specified in each patch. v4: - Extend to wider audience and add R-Bs on the xe patches. - Address documentation review comments from 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: Thomas Hellström (4): mm/mmu_notifier: Allow two-pass struct mmu_interval_notifiers drm/xe/userptr: Convert invalidation to two-pass MMU notifier drm/xe: Split TLB invalidation into submit and wait steps drm/xe/userptr: Defer Waiting for TLB invalidation to the second pass if possible drivers/gpu/drm/xe/xe_svm.c | 8 +- drivers/gpu/drm/xe/xe_tlb_inval.c | 84 +++++++++++++ drivers/gpu/drm/xe/xe_tlb_inval.h | 6 + drivers/gpu/drm/xe/xe_tlb_inval_types.h | 14 +++ drivers/gpu/drm/xe/xe_userptr.c | 155 ++++++++++++++++++++---- drivers/gpu/drm/xe/xe_userptr.h | 31 ++++- drivers/gpu/drm/xe/xe_vm.c | 99 +++++---------- drivers/gpu/drm/xe/xe_vm.h | 5 +- drivers/gpu/drm/xe/xe_vm_madvise.c | 10 +- drivers/gpu/drm/xe/xe_vm_types.h | 1 + include/linux/mmu_notifier.h | 42 +++++++ mm/mmu_notifier.c | 65 ++++++++-- 12 files changed, 416 insertions(+), 104 deletions(-) -- 2.53.0