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 11D16606A322 for ; Thu, 3 Dec 2026 20:09:23 +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=lhJ7ixC3 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9CB7C112B89; Thu, 3 Dec 2026 20:09:17 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id A988D112BA8 for ; Thu, 3 Dec 2026 20:09:11 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 03EC8614C2; Thu, 3 Dec 2026 20:09:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B90C91F000C2; Thu, 3 Dec 2026 20:09:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796328550; bh=FyTvLTT6Irt3NM4VQc6kbRBYgW0bo35GS+Ck3hDXntE=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=lhJ7ixC38XCENUhxajtv/0qbJUb23zkCrMMcVkV+MkaXr5Dz/NN+OlGR359Ob8Ybu Ixk2vqfL9haMlFNMZKCZrUjB47KNqxqgemAG1WBnmVmbZXlRFOQsx1iOPrbivFYE3l asMdBvVWIfFa4xWAV+dylwG5Tceydm4D+M2vy3BhHFmYVrBITk+77pcFTxad9tQzSx 1JPvCz95g63P/NBD57foPX0kGvKR2XeRENAvpyNlKT+LMM/uJzHSLgw1Aeuy3z7quu 3GELnxeZrIpbH726eIelhF2fuYghfiwFWCyqv3MmAV9hhrnmlfMOrC8+zAVv8lbVdY /AX6SeFlCvL+A== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 1/2] drm/i915/guc: Use a delayed wakeref put in guc_engine_busyness() To: "Umesh Nerlige Ramappa" , intel-gfx@lists.freedesktop.org In-Reply-To: <20261203194610.2030696-5-umesh.nerlige.ramappa@intel.com> References: <20261203194610.2030696-4-umesh.nerlige.ramappa@intel.com> <20261203194610.2030696-5-umesh.nerlige.ramappa@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 20:09:10 +0000 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "Intel-gfx" 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/i915/gt: intel_gt_pm_put_delay() can wake kswapd under rq lock - [Medium] drm/i915/gt: intel_gt_pm_put_delay() breaks scheduler safety on DEBUG_WAKEREF -- commit 0ade1154ca3e2c5818eb07814d5eadbfbfdf75dd Author: Umesh Nerlige Ramappa drm/i915/guc: Use a delayed wakeref put in guc_engine_busyness() This commit adds intel_gt_pm_put_delay() to defer releasing the final GT wakeref on a timer, and switches guc_engine_busyness() to use it with a 1 jiffy delay to avoid waking a workqueue worker under a runqueue lock. > diff --git a/drivers/gpu/drm/i915/gt/intel_gt_pm.h b/drivers/gpu/drm/i915= /gt/intel_gt_pm.h > index 6f25c747bc29b..24c8b014864d8 100644 > --- a/drivers/gpu/drm/i915/gt/intel_gt_pm.h > +++ b/drivers/gpu/drm/i915/gt/intel_gt_pm.h > @@ -72,6 +72,30 @@ static inline void intel_gt_pm_put_async(struct intel_= gt *gt, intel_wakeref_t ha > intel_gt_pm_put_async_untracked(gt); > } > =20 > +/** > + * intel_gt_pm_put_delay - release the GT wakeref, deferred by a timer > + * > + * @gt: pointer to the gt > + * @handle: the handle returned by the matching intel_gt_pm_get*() > + * @delay: delay, in jiffies, before the release is processed > + * > + * As intel_gt_pm_put_async(), except that dropping the last reference a= rms a > + * timer instead of queueing the release immediately. > + * > + * intel_gt_pm_put_async() ends up in mod_delayed_work() with a zero del= ay, > + * which queues the work straight away and so wakes a workqueue worker t= hrough > + * try_to_wake_up(). That deadlocks if the caller already holds a runque= ue > + * lock, since try_to_wake_up() then tries to take it again. Callers whi= ch can > + * run from inside the scheduler must use this variant with a non-zero @= delay, > + * which takes the add_timer_on() path and never wakes a task. > + */ > +static inline void intel_gt_pm_put_delay(struct intel_gt *gt, intel_wake= ref_t handle, > + unsigned long delay) > +{ > + intel_wakeref_untrack(>->wakeref, handle); > + intel_wakeref_put_delay(>->wakeref, delay); > +} [Severity: Medium] Does intel_gt_pm_put_delay() violate raw spinlock nesting when CONFIG_DRM_I915_DEBUG_WAKEREF is enabled? When called from scheduler context with raw_spinlock_t rq->__lock held (prepare_task_switch() -> perf_cgroup_switch() -> i915_pmu_event_del()), intel_wakeref_untrack() calls ref_tracker_free(), which takes non-raw dir->lock and calls kfree(), triggering CONFIG_PROVE_RAW_LOCK_NESTING. ref_tracker_free() also calls stack_depot_save() with GFP_NOWAIT, which can wake kswapd and self-deadlock on rq->__lock under memory pressure. Commit "drm/i915/pmu: Use a delayed wakeref put in get_rc6()" reuses intel_gt_pm_put_delay() with the same issue. > diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/= gpu/drm/i915/gt/uc/intel_guc_submission.c > index 788e59cdfac9b..32d722c378e84 100644 > --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c > +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c > @@ -1361,7 +1361,12 @@ static ktime_t guc_engine_busyness(struct intel_en= gine_cs *engine, ktime_t *now) > */ > guc_update_engine_gt_clks(engine); > guc_update_pm_timestamp(guc, now); > - intel_gt_pm_put_async(gt, wakeref); > + /* > + * We are reached from the perf callbacks, which perf may invoke > + * from the scheduler with the runqueue lock held. Defer the put > + * on a timer so that it can never wake a task from here. > + */ > + intel_gt_pm_put_delay(gt, wakeref, 1); [Severity: Medium] Can the tracked wakeref pair here still wake kswapd and deadlock on rq->__lock when CONFIG_DRM_I915_DEBUG_WAKEREF is enabled? Both intel_gt_pm_get_if_awake() and intel_gt_pm_put_delay() invoke ref_tracker with GFP_NOWAIT, which includes __GFP_KSWAPD_RECLAIM. stack_depot_save_flags() preserves that flag via gfp_nested_mask() when allocating a new depot pool. Under memory pressure, alloc_pages() enters __alloc_pages_slowpath() -> wakeup_kswapd() -> try_to_wake_up(), self-deadlocking on rq->__lock while guc->timestamp.lock is held and stalling __guc_context_update_stats(). Untracked get_if_awake and put_delay helpers would avoid ref_tracker. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203194610.2030= 696-4-umesh.nerlige.ramappa@intel.com?part=3D1