From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9332A606A689 for ; Wed, 2 Dec 2026 20:16:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=REHtabeG Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 56C301124F2; Wed, 2 Dec 2026 20:16:41 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id A6C80112501; Wed, 2 Dec 2026 20:16:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796242595; x=1827778595; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=CG+k9F7kuNecDI3ouO/ycdlaQWqikIWOMg8IKfCBJC8=; b=REHtabeG96ECNO6h7LvyAjIM3WFqa2zx9bW1ajIXUL1VUHGCHJKvcR2h 6zkdKipf2GLWW5hdAdu/Cj4zLlbj8Uik8OziQ/WY4GFTy4TlxdDIushj+ /KHaMibSI1bXUfwkEkfjCa/3Y1bg/kWKQs22DjIYDClRT5NswEGID6zkG kuiNc96OKwr7vL921zZQ04KUUUlIJwoQLAw9CpC1FnVfyDW+LxSRnz3/h TxCNvzL2N5GnciCHrbUDi4x6PQn9iO+fxZB5x1DfdCrzYdI8c2ncV6zTe 9fSxi1vQdUes6KaiHOIvLiPElCUjAeq1ggGeB/48bb7eSsCALG5IjLyv5 Q==; X-CSE-ConnectionGUID: /HYbVWz9TbikO1NrrF0vEQ== X-CSE-MsgGUID: bDJO+C5ERFOQXmIV/LunHA== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5196595" X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="5196595" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 12:16:34 -0800 X-CSE-ConnectionGUID: QG5nNB3FSf646Aur+suxZQ== X-CSE-MsgGUID: faj4rf9uQQG4Rz8EAF3keQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="14001420" Received: from orsmsx901.amr.corp.intel.com ([10.22.229.23]) by orviesa009.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 12:16:34 -0800 Received: from ORSMSX901.amr.corp.intel.com (10.22.229.23) by ORSMSX901.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 12:16:33 -0800 Received: from ORSEDG903.ED.cps.intel.com (10.7.248.13) by ORSMSX901.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57 via Frontend Transport; Wed, 2 Dec 2026 12:16:33 -0800 Received: from PH7PR06CU001.outbound.protection.outlook.com (52.101.201.24) by edgegateway.intel.com (134.134.137.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 12:16:32 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bF6ywHNjIz8lDul9qwtYmiNCCBFjTF+BLgUr490qvz7xR5SOrbtLK4OMGt2h1SbmmMs1M2f1Qxqul/A2/ScsVgm3LRoGOVTTVSGBVmBJ0X5Xb5ax/MUYn9dH2x+mh6I5MfjqMUUL1iqc+IV98gtodAZSh3OqMf+oQ/CG2anRrT6fXiq/OIxmtlSFk2o4gnyhvstLY7LuGHAo3N2pSnsKnJoRMTQjYCQO4i9c2i/BNQ5jw5FUDxibCYWokDgSIjlsgOhP+MnPvBGsWC+I1amJd3DlCcUpW7akRx2ptQIcDzKCiVpkxzGjiBKXZMxCxooRkoOUuxm7alj0hGd3WRPUMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kHAUir0ngr6O8vUbJCQyR7JXHAlkMF4VELC+orr4N7s=; b=TBh2fkw/0DpDNPblDkmnwTvkf8H74mZ/HlVECDiY4MFQl+bKxH/yHws0AFZ1pB5sdtLIntG9BQ/Stm8z6eHIRsiLbz5J8bQMWIRGCQjJQiOgg/PVRxCjXEEjeVdVx1Xa0TrLUfOBHc9rUXslvIPUB59zGf1mJxBCpkoD3z9VijN8Jccj/O9WFB9VTMGTFc4iNpTmUzbcUgkeGv8cQArnv9mMEz5mEe2eHfepfrCNBks50JyWEGDrcOK6yyk4HcMOJS6I5ZNRWKX8Lmz7MzgN+uqPFIhiOMl0yudlHh8Jgk/5YaocHLhvhcbgXLeDVfoQd3qjLrgqIibYrvsjtjnidg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from CO1PR11MB4787.namprd11.prod.outlook.com (2603:10b6:303:95::23) by SJ5PPFF6F855567.namprd11.prod.outlook.com (2603:10b6:a0f:fc02::861) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Wed, 2 Dec 2026 20:16:30 +0000 Received: from CO1PR11MB4787.namprd11.prod.outlook.com ([fe80::e7eb:a872:53d1:21fd]) by CO1PR11MB4787.namprd11.prod.outlook.com ([fe80::e7eb:a872:53d1:21fd%4]) with mapi id 15.21.0688.009; Wed, 2 Dec 2026 20:16:30 +0000 Date: Wed, 2 Dec 2026 12:16:27 -0800 From: Matthew Brost To: CC: , Subject: Re: [PATCH v4 13/33] drm/xe: Flush L2 asynchronously in xe_bo_trigger_rebind() Message-ID: References: <20261201234915.3305331-1-matthew.brost@intel.com> <20261201234915.3305331-14-matthew.brost@intel.com> Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: PH8PR02CA0040.namprd02.prod.outlook.com (2603:10b6:510:2da::17) To CO1PR11MB4787.namprd11.prod.outlook.com (2603:10b6:303:95::23) X-Archived-By: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR11MB4787:EE_|SJ5PPFF6F855567:EE_ X-MS-Office365-Filtering-Correlation-Id: 1432ff3c-6244-4c52-7399-08df50b12702 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|23010399003|1800799024|376014|261028144727099003|10067099003|56012099006|261021121427099003|261022105027099003|261026140227099003|261022075727099003|261026121527099003|261102123227099003|261009223027099003|18002099003|22082099003|11063799006|4143699003|6133799003; X-Microsoft-Antispam-Message-Info: /fU/8KNJEa8pmVdWnkOLtT3bOQv/z/o6/Yle29gm9GQms9MYgyDJ0FZwO68XJiCZBKqkA9IyBQXE6DwB4vx7Yp15Z97X3CoFTQN1wwcW6xOlybTk4HMqIpveeM9RFp+GSUr+J4R9fpntvhDo7SEhSYZ6jz7KY+wSSKSXLcq317N4j9FB8By/gr2sxx4YeqIxUSKawSpksHup918rCndnqi4OM/Ec1INDhhojQQvx9cAERrUPNgB/A9WxdjFmVAv11Iy+VELPz1DS4VtnWRGS46RipBOXX/fLPUU9y/6BgtNmGyCbfxQoOYdPqVqq70rkXnhcHBBPTSVlFdk7RzpLqqGc56oDUyZk0BEXneJZEc+CXSR4y2r6zga5htmd8janwZo7zBXb8f9k2fMmO1Nte/JBFpSEreKp2Y2Ou5dlVvu7pPCDNx/2UpOkzsPBIU6i8z26bFIC82xkm/6ojn2mXxH47BCw7/yq7YA2dcQDIrlGv7IeLYw3vW6OBzQ+qR8EFLmiPC3i20iXQyQ7/r78+ogwDiONQTcHk8FFKAHqqKZ7CQ0LpbDqSxWeaaf43AWCz33IOBNN8w+wXNTsgVVJJOdy/nhnBKGfRWbLcCNbA9c= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO1PR11MB4787.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(23010399003)(1800799024)(376014)(261028144727099003)(10067099003)(56012099006)(261021121427099003)(261022105027099003)(261026140227099003)(261022075727099003)(261026121527099003)(261102123227099003)(261009223027099003)(18002099003)(22082099003)(11063799006)(4143699003)(6133799003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?zPimUxaGa6+2NB9n9fCb0GadB8mJHrn17Z4CaVI1WrolhmgSnOo7+E8CGx?= =?iso-8859-1?Q?npzsmiilKy52T8DRh5MR+an9GsRAcFWtM4oW3QX4fCaDj5Gt/9jOHqQlK2?= =?iso-8859-1?Q?6S8AArrhT9o6pUcJAEkq/rtrRmcPGzAdP/akHGcpMUPwpYTVhV1hasTCUK?= =?iso-8859-1?Q?0BW9p76OGhNeA5T3rDGzBdelYw52uNmWqy2RacIFMye/BtSOGG1dF/9tcN?= =?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C65yan3LEGYU02eLWbarmfXAMT937AwNEEw5XC1UmoXlCCGWdoy90uRRxUIk11IjtMbYu52VkoVL69GpT3zl1vwKzASELJ2Gn0wUrH3+wylKUiB8zEs4TUh5BGQNc6/IyvyMFRrgIRzr/3i9mrUrPJFZwfe5cs6cKFQ== X-MS-Exchange-CrossTenant-Network-Message-Id: 1432ff3c-6244-4c52-7399-08df50b12702 X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4787.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 20:16:30.4837 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: r01989x8wZXElLgR/6L1LWcV6gbuwF1gCeWwz/jz3mxbFKmeQcyvyilF7VPRR1+mJHDJt61uxQqeRXRuDpjO2Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ5PPFF6F855567 X-OriginatorOrg: intel.com X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Intel-xe" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Wed, Dec 02, 2026 at 12:19:37AM +0000, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 4 potential > issues to consider: > - [High] drm/xe: wrong exec queue in xe_vma_tlb_flush_client() causes > crash and race > - [High] drm/xe: GFP_KERNEL allocation under fs_reclaim in > xe_bo_trigger_rebind() > - [Medium] drm/xe: missing tile offset when indexing tlb_inval[] in > async TLB flush > - [Medium] drm/xe: sync waits in xe_bo_move() defeat async flush and > drop intr flag > -- I'm going to drop this patch and this can landed independently and Sashiko is making question if this patch is correct. Also code path isn't execerised on any release HW yet, so I'll add this one to the backlog... Matt > > commit 84c2ac189fd19c72925ce925ba1b909c879cc4a2 > Author: Matthew Brost > > drm/xe: Flush L2 asynchronously in xe_bo_trigger_rebind() > > This commit replaces the synchronous idle wait and TLB invalidation in > xe_bo_trigger_rebind() on L2-flush-optimized hardware with asynchronous TLB > invalidation jobs installed into the BO's dma-resv as kernel fences. > > > diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c > > index ff5610ba4b740..920b7b6094582 100644 > > --- a/drivers/gpu/drm/xe/xe_bo.c > > +++ b/drivers/gpu/drm/xe/xe_bo.c > > @@ -857,6 +857,19 @@ static int xe_bo_trigger_rebind(struct xe_device *xe, struct xe_bo *bo, > > */ > > if (!xe_device_is_l2_flush_optimized(xe)) > > continue; > > + > > + /* > > + * Attempt to flush L2 async, fallback to sync flush on > > + * failure. Skip the async attempt under no_wait_gpu > > + * (e.g. the shrinker's reclaim pass): job creation > > + * allocates with GFP_KERNEL, which must not run while > > + * holding the dma-resv lock under fs_reclaim. The sync > > + * fallback below honors no_wait_gpu (returns -EBUSY if > > + * the BO is not idle). > > + */ > > + if (!ctx->no_wait_gpu && > > + !xe_vm_flush_vm_bo_tlb_async(vm, bo, vm_bo)) > > + continue; > > } > > [Severity: High] > Is checking !ctx->no_wait_gpu enough to prevent GFP_KERNEL allocations in > xe_vm_flush_vm_bo_tlb_async() under fs_reclaim while holding the BO dma-resv > lock? > > When kswapd runs xe_shrinker_scan(), ttm_bo_shrink_avoid_wait() returns false > (!current_is_kswapd()), so passes 2 and 3 in xe_shrinker_walk() call > __xe_shrinker_walk() -> xe_bo_shrink() -> xe_bo_move_notify() -> > xe_bo_trigger_rebind() with ctx->no_wait_gpu == false inside fs_reclaim. > Similarly, xe_ttm_bo_swap_notify() calls xe_ttm_bo_purge() with > ctx.no_wait_gpu == false during swapout. Both paths hit the GFP_KERNEL > allocations and might_alloc(GFP_KERNEL) in xe_tlb_inval_job_alloc_dep(), > inverting the fs_reclaim -> dma_resv lock order and risking reclaim deadlock. > > [Severity: Medium] > Does xe_bo_move() still block synchronously on the new flush fence right > after xe_bo_move_notify() returns? > > xe_device_is_l2_flush_optimized() is only true on !IS_DGFX(xe), where BO > eviction moves from XE_PL_TT to XE_PL_SYSTEM. Immediately after > xe_bo_move_notify(), xe_bo_move() waits uninterruptibly on > DMA_RESV_USAGE_BOOKKEEP before reaching xe_migrate_copy(): > > drivers/gpu/drm/xe/xe_bo.c:xe_bo_move() { > ... > if (old_mem_type == XE_PL_TT && > new_mem->mem_type == XE_PL_SYSTEM) { > long timeout = dma_resv_wait_timeout(ttm_bo->base.resv, > DMA_RESV_USAGE_BOOKKEEP, > false, > MAX_SCHEDULE_TIMEOUT); > ... > } > > Because DMA_RESV_USAGE_BOOKKEEP includes the DMA_RESV_USAGE_KERNEL fence > installed by xe_vm_flush_vm_bo_tlb_async(), the calling thread still stalls > under the BO dma-resv lock for all in-flight GPU work plus the extra > dep_scheduler and job_wq hop, and the wait is no longer interruptible when > ctx->interruptible is true. > > > diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c > > index c774804ca5567..842d99a6ae1a3 100644 > > --- a/drivers/gpu/drm/xe/xe_vm.c > > +++ b/drivers/gpu/drm/xe/xe_vm.c > [ ... ] > > @@ -4668,6 +4669,130 @@ int xe_vm_invalidate_vma(struct xe_vma *vma) > > return ret; > > } > > > > +/* > > + * xe_vma_tlb_flush_client - Queue an async TLB flush for one VMA on one client > > + * > > + * Create and push a TLB invalidation job on the tile migrate (kernel) exec > > + * queue covering @vma's range, depending on @dep (the BO's in-flight GPU work) > > + * so the flush only fires once the GPU is done with the current mapping. The > > + * job's completion fence is installed into @resv as a KERNEL fence so the > > + * subsequent migration waits on the flush. No PTEs are zapped; this only > > + * flushes L2 via the TLB invalidation. > > + */ > > +static int xe_vma_tlb_flush_client(struct xe_vm *vm, struct xe_vma *vma, > > + struct xe_tile *tile, struct xe_gt *gt, > > + struct dma_resv *resv, struct dma_fence *dep, > > + int type) > > +{ > > + struct xe_exec_queue *q = xe_migrate_exec_queue(tile->migrate); > > + struct xe_tlb_inval_job *job; > > + struct dma_fence *fence; > > + int err; > > + > > + job = xe_tlb_inval_job_create(q, >->tlb_inval, > > + q->tlb_inval[type].dep_scheduler, vm, > > + xe_vma_start(vma), xe_vma_end(vma), type); > > + if (IS_ERR(job)) > > + return PTR_ERR(job); > > + > > + err = xe_tlb_inval_job_alloc_dep(job); > > + if (err) > > + goto out_put; > > + > > + err = dma_resv_reserve_fences(resv, 1); > > + if (err) > > + goto out_put; > > + > > + /* Cannot fail; takes its own ref on @dep and returns a referenced fence. */ > > + fence = xe_tlb_inval_job_push(job, dep); > > [Severity: High] > Should xe_vma_tlb_flush_client() use xe_cpu_bind_queue(vm->xe->cpu_bind) > instead of xe_migrate_exec_queue(tile->migrate)? > > Since commit f5708e761ed6 ("drm/xe: Add CPU bind layer"), > xe_tlb_inval_job_push() serializes kernel TLB invalidation jobs via > xe_cpu_bind_job_lock(cpu_bind, job->q): > > drivers/gpu/drm/xe/xe_cpu_bind.c:xe_cpu_bind_job_lock() { > bool is_cpu_bind = is_cpu_bind_queue(cpu_bind, q); > > if (is_cpu_bind) > mutex_lock(&cpu_bind->job_mutex); > else > xe_vm_assert_held(q->user_vm); /* User queues VM's should be locked */ > } > > Because tile->migrate->q is not cpu_bind->q and has q->user_vm == NULL, > xe_cpu_bind_job_lock() skips cpu_bind->job_mutex and dereferences a NULL > q->user_vm in xe_vm_assert_held() when CONFIG_LOCKDEP is enabled, followed by > failing xe_assert(xe, q == cpu_bind->q) in xe_cpu_bind_job_lock_assert(). > With lockdep and debug assertions disabled, no lock is taken at all, so > concurrent BO evictions race on the shared dep_scheduler entity and on > q->tlb_inval[idx].last_fence in xe_exec_queue_tlb_inval_last_fence_set(). > > > + dma_resv_add_fence(resv, fence, DMA_RESV_USAGE_KERNEL); > > + dma_fence_put(fence); > > + > > +out_put: > > + /* Drop the creation reference (destroys the job if it was not pushed). */ > > + xe_tlb_inval_job_put(job); > > + return err; > > +} > [ ... ] > > + for_each_tile(tile, xe, id) { > > + if (!(vma->tile_present & BIT(id))) > > + continue; > > + > > + err = xe_vma_tlb_flush_client(vm, vma, tile, > > + tile->primary_gt, resv, dep, > > + XE_EXEC_QUEUE_TLB_INVAL_PRIMARY_GT); > > + if (err) > > + goto out; > > + > > + if (tile->media_gt) { > > + err = xe_vma_tlb_flush_client(vm, vma, tile, > > + tile->media_gt, resv, dep, > > + XE_EXEC_QUEUE_TLB_INVAL_MEDIA_GT); > > + if (err) > > + goto out; > > + } > > + } > > [Severity: Medium] > Does indexing q->tlb_inval[type] without a tile offset use tile 0's slots for > every tile? > > Since commit 366365b7489f ("drm/xe: Make bind queues operate cross-tile"), > alloc_dep_schedulers() populates q->tlb_inval[] across all tiles at > id * (XE_EXEC_QUEUE_TLB_INVAL_MEDIA_GT + 1) + type. Passing the unshifted > type (0 or 1) for tile->id > 0 selects tile 0's dep_scheduler and last_fence > slot, which gives fences from different tiles the same dma_fence context so > dma_resv_add_fence() overwrites tile 0's unsignaled flush fence in resv. > > -- > Sashiko AI review · https://sashiko.dev/#/patchset/20261201234915.3305331-1-matthew.brost@intel.com?part=13