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 5233C606A320 for ; Tue, 1 Dec 2026 11:52:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=o1NAdTDk Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 18AF010E050; Tue, 1 Dec 2026 11:51:55 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4720F10E050 for ; Tue, 1 Dec 2026 11:51:49 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 249A341334; Tue, 1 Dec 2026 11:51:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E46321F000C1; Tue, 1 Dec 2026 11:51:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796125909; bh=ukRkJBxbqMQLeG9A/JtI5pOVK72B+sB4h5FbYwHgepE=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=o1NAdTDkz8MxkVww56b/NBFWL9zptki5zbjFs2KOIvG1Ykgh0l3obp4V64KMOXIpG bg/1kBmwskDlQG+TlyGZwmsNVX45YuedQ+2epN5fsB9a0cfX8ZbXkkyQ7Sw6Iomwn6 nEUtTaNjnWXd18Hbxb7JyfFHlljOY1JtK4ypplEtCSc3CP2GoepcW4/uH1hfRhVfeX 7DY2hKrdwIKynYn9cfwD/HOlLilr62+u8yKUswYtQv/xehhY66RWrX9TfdRIhDYVpa kHBVnu30NJnNbr0dr/ETGs0atK7SyYWpBactpu6WQVOiAFsQhHfLriPSLu0P1fWww9 p9aBGthABfhpw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH V4 1/3] drm/xe/vram: add decay-based reinstatement of soft-offlined VRAM pages To: "Tejas Upadhyay" , intel-xe@lists.freedesktop.org In-Reply-To: <20261201113518.146130-6-tejas.upadhyay@intel.com> References: <20261201113518.146130-5-tejas.upadhyay@intel.com> <20261201113518.146130-6-tejas.upadhyay@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 11:51:48 +0000 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: , Reply-To: sashiko-reviews@lists.linux.dev 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=ham 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 X-Archived-By: Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] drm/xe/vram: race in xe_ttm_vram_mgr_fini() can re-arm decay_gc_work - [Low] drm/xe: unused XE_BAD_PAGE_DECAY_SECS_DEFAULT and missing configfs visibility -- commit a18ba37985069c5d01894a2deb36a31a4255b80e Author: Tejas Upadhyay drm/xe/vram: add decay-based reinstatement of soft-offlined VRAM pages This commit adds a per-VRAM-manager delayed work timer and a bad_page_decay_secs configfs attribute to reinstate soft-offlined VRAM pages after a decay period with no further faults, while promoting repeated faults to permanent hard retirement. > diff --git a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c b/drivers/gpu/drm/xe/xe= _ttm_vram_mgr.c > index 36d47de8b11ba..ed9fa4e2b574f 100644 > --- a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c > +++ b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c > @@ -229,6 +229,8 @@ static void xe_ttm_vram_buddy_free(struct xe_ttm_vram= _mgr *mgr, > * > * Called with @mgr->lock held. > */ > +static unsigned long xe_ttm_vram_decay_gc_period(struct xe_ttm_vram_mgr = *mgr); > + > static void xe_ttm_vram_retry_queued_pages(struct xe_ttm_vram_mgr *mgr) > { > struct xe_ttm_vram_offline_resource *pos, *n; > @@ -247,6 +249,11 @@ static void xe_ttm_vram_retry_queued_pages(struct xe= _ttm_vram_mgr *mgr) > list_del(&pos->queued_link); > ++mgr->n_offlined_pages; > list_add(&pos->offlined_link, &mgr->offlined_pages); > + > + if (pos->mode =3D=3D XE_PAGE_OFFLINE_SOFT && mgr->decay_interval_jiffi= es && > + !delayed_work_pending(&mgr->decay_gc_work)) > + schedule_delayed_work(&mgr->decay_gc_work, > + xe_ttm_vram_decay_gc_period(mgr)); > } > } [ ... ] > @@ -415,6 +470,8 @@ static void xe_ttm_vram_mgr_fini(struct drm_device *d= ev, void *arg) > struct xe_ttm_vram_mgr *mgr =3D arg; > struct ttm_resource_manager *man =3D &mgr->manager; > =20 > + cancel_delayed_work_sync(&mgr->decay_gc_work); > + > mutex_lock(&mgr->lock); > xe_ttm_vram_free_bad_pages(mgr); > mutex_unlock(&mgr->lock); [Severity: Medium] Can xe_ttm_vram_retry_queued_pages() re-arm mgr->decay_gc_work after cancel_delayed_work_sync() returns in xe_ttm_vram_mgr_fini()? During drmm teardown, xe_ttm_vram_mgr_fini() runs before ttm_resource_manager_evict_all() and before xe_device_destroy() drains xe->bo_device.async_free and xe->ttm.wq. If an in-flight BO or ghost object deletion freeing a queued soft-offlined page runs in the window before mgr->lock is taken, it schedules decay_gc_work again: CPU0 CPU1 (kworker) xe_ttm_vram_mgr_fini() cancel_delayed_work_sync(&mgr->decay_gc_work) xe_ttm_vram_mgr_del() mutex_lock(&mgr->lock) ... xe_ttm_vram_retry_queued_pages() schedule_delayed_work(&mgr->decay= _gc_work, ...) mutex_unlock(&mgr->lock) mutex_lock(&mgr->lock) xe_ttm_vram_free_bad_pages(mgr) mutex_unlock(&mgr->lock) ... gpu_buddy_fini(&mgr->mm) xe_ttm_vram_decay_gc_worker() <-- use-after-free on mgr Cancelling decay_gc_work after xe_ttm_vram_free_bad_pages() has emptied mgr->queued_pages (or zeroing mgr->decay_interval_jiffies under mgr->lock before cancel_delayed_work_sync()) would prevent it from being re-armed. > diff --git a/drivers/gpu/drm/xe/xe_ttm_vram_mgr_types.h b/drivers/gpu/drm= /xe/xe_ttm_vram_mgr_types.h > index 4a2cd27a5b617..0a6d8f8c2aa83 100644 > --- a/drivers/gpu/drm/xe/xe_ttm_vram_mgr_types.h > +++ b/drivers/gpu/drm/xe/xe_ttm_vram_mgr_types.h > @@ -7,8 +7,16 @@ > #define _XE_TTM_VRAM_MGR_TYPES_H_ > =20 > #include > +#include > #include > =20 > +#define XE_BAD_PAGE_DECAY_SECS_DEFAULT (24 * 60 * 60) [Severity: Low] This isn't a bug, but XE_BAD_PAGE_DECAY_SECS_DEFAULT is unused while device_defaults in drivers/gpu/drm/xe/xe_configfs.c open-codes 24 * 60 * 60 (and configfs defaults live in xe_defaults.h). Also, xe_config_device_is_visible() hides attr_disable_vram_page_offline when !dev->desc->is_dgfx || dev->desc->platform !=3D XE_CRESCENTISLAND, but does not gate attr_bad_page_decay_secs, and the DOC: Xe Configfs comment in xe_configfs.c wasn't updated for the new attribute. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201113518.1461= 30-5-tejas.upadhyay@intel.com?part=3D1