Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BA5A8E73151 for ; Mon, 2 Feb 2026 09:49:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DFA1510E28E; Mon, 2 Feb 2026 09:49:43 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="b4FHKik3"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id BAEE910E28E for ; Mon, 2 Feb 2026 09:49:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1770025782; x=1801561782; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=KYLWXHG5CV4pfZ0AMIfxHVjeWQhyjMHTo9SoYGh5nSE=; b=b4FHKik3NeYQQkUxLt04Sb/CeRZ1+DwPvDXkwHlBNOzgOkMRRUkEPdqe thlRdF8uK7DR4CBfCEo94vsdv41zw6N70Mt+xRxAKCTNlB9dCe7T+wfCm bYkk0TZcK9/RyER6Gn97U5++IVg9QMRxoBxG4dlDzdWMCZme0xP663+jr 0442pZ7x9rbgPhk2J9pCaRuYnfIPrXv6eLlWhIRDuY2Eq84bd9JBnDCLv HPpGogWfcRG8UDqRW/BqMLcDjx1RZDXXsa7JL7WJBl6DTgmTjFcbI3OCO 8BPmoxc3H+yAsNk30G23I4KfvfxtSBrvLp1aLgot37eCvVsisZ8eqqfja Q==; X-CSE-ConnectionGUID: 7DzpiwVaQ52WlaRGY8i+xA== X-CSE-MsgGUID: xSCrOLpFQNGP2MsmtB6Oyw== X-IronPort-AV: E=McAfee;i="6800,10657,11689"; a="74802547" X-IronPort-AV: E=Sophos;i="6.21,268,1763452800"; d="scan'208";a="74802547" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Feb 2026 01:49:42 -0800 X-CSE-ConnectionGUID: KGnY2pOJQfaAjQSF8RtbjQ== X-CSE-MsgGUID: d5gdnoEPSQmYDQ9HO0Dvgw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,268,1763452800"; d="scan'208";a="247082861" Received: from abityuts-desk.ger.corp.intel.com (HELO [10.245.244.193]) ([10.245.244.193]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Feb 2026 01:49:40 -0800 Message-ID: <081c00e4b349ec6b81ef9659b8180c1b834909b7.camel@linux.intel.com> Subject: Re: drm_gpusvm: questions on multi-GPU support From: Thomas =?ISO-8859-1?Q?Hellstr=F6m?= To: Honglei Huang , matthew.brost@intel.com Cc: Ray.Huang@amd.com, dri-devel@lists.freedesktop.org Date: Mon, 02 Feb 2026 10:49:37 +0100 In-Reply-To: References: Organization: Intel Sweden AB, Registration Number: 556189-6027 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.2 (3.58.2-1.fc43) MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Mon, 2026-02-02 at 15:56 +0800, Honglei Huang wrote: >=20 > Hi Matthew and Thomas, >=20 > I'm exploring the use of drm_gpusvm for multi-GPU shared virtual > memory > scenarios and have some questions about potential synchronization > issues. >=20 > The drm_gpusvm design is per-device oriented, so for multi-GPU > setups, > each GPU would have its own drm_gpusvm instance with independent MMU > notifiers registered to the same mm_struct. >=20 > When multiple drm_gpusvm instances share the same process address > space, > I'm concerned about the following synchronization issues: >=20 > 1. MMU notifier ordering: When CPU modifies memory (e.g., munmap), > =C2=A0=C2=A0=C2=A0 multiple notifier callbacks are triggered independentl= y. Is there > any > =C2=A0=C2=A0=C2=A0 guarantee on the ordering or atomicity across GPUs? Co= uld this > lead > =C2=A0=C2=A0=C2=A0 to inconsistent states between GPUs? The guarantee is that the invalidation may not proceed until all mmu notifiers have completed, and then gpusvm_range_get_pages() will never complete successfully until the invalidation is complete. >=20 > 2. Range state consistency: If GPU-A and GPU-B both have ranges > =C2=A0=C2=A0=C2=A0 covering the same virtual address, and an invalidation= occurs, > how > =C2=A0=C2=A0=C2=A0 should we ensure both GPUs see a consistent view befor= e allowing > =C2=A0=C2=A0=C2=A0 new GPU accesses? Multiple gpus may maintain ranges of different size with different attributes pointing to the same memory, and that's really not a problem. It's up to user-space to ensure that we're not bouncing data around between gpus. In xe, we're using the gpu_madvise() ioctl to allow UMD to specify things like preferred region and access mode. >=20 > 3. Concurrent fault handling: If GPU-A and GPU-B fault on the same > =C2=A0=C2=A0=C2=A0 address simultaneously, is there potential for races i= n > =C2=A0=C2=A0=C2=A0 drm_gpusvm_range_find_or_insert()? each drm_gpusvm() instance is meant to be per-vm and per-device so each vm on each gpu only sees its own ranges. The drm_pagemap code is then the code that maintains the migration state, and that is per-cpu-vm so if it is fed conflicting migration requests from different gpus or even different vms, it will try its best to mitigate. However, the invalidation scheme in 1. will always guarantee that all gpus either have invalid page-tables causing gpu-faults or point to common memory that holds the data. >=20 > Is multi-GPU a considered use case for drm_gpusvm? If so, are there > recommended patterns for handling these coordination issues? For us it's considered a valid use-case. In the end I guess that depends on the API you are exposing to the end-user. KMD ensures all GPUs always point to the correct data for a given cpu virtual address space, but leaves it to user-space to supply non-conflicting migration requests to avoid excessive migration. I'm under the impression that our L0 user-facing API is also forwarding this responsibility to the end-user. Hope this information helps. Thanks, Thomas >=20 > Regards, > Honglei