From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (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 E4D533D25B6 for ; Fri, 10 Jul 2026 21:55:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783720503; cv=none; b=ThDLejXK6TG+uvBFwdYn2j4RlaztQamQNAQW/+sFrf4Bj6qvckXylzUDirYP2PCvto9qROYIl46nD26SiD5N4Ns6Hgc3DiuZnyHvQR7KwQJ+m/kRIIQepUSKXZE4qhShHXsznECF/70Ya6fxUZn0pATs/NptLQ7eTuoiZI40CGs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783720503; c=relaxed/simple; bh=cbP6tEvbRD0S2XfIB8Mi9mEJEIVpdG6/v8k9ps/vcxM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=RafknmuQ1aw5F11eSj65QaZFdvV3rwnO5tGn0bQyE1w2UqlNPrEJH/C4ikkLRsVUSntmb9hfeZY8xOHWIQOFvxkL9jOAMV8i32NAO9Vv/aG7TV+EdMWVTkLg7rUt8kHBfZJsRveftLQ+FsoMBv7lKRRx5BudU8qGBMngo7K/2tk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=HfV5JnA6; arc=none smtp.client-ip=192.198.163.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HfV5JnA6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1783720501; x=1815256501; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cbP6tEvbRD0S2XfIB8Mi9mEJEIVpdG6/v8k9ps/vcxM=; b=HfV5JnA6rJeEl/du1yzLcQTNt319K9zzkKu66ctHbR9lczxdO2HC2cCw 1UkJuJ+XoJDgErtsVA1WULheOG9cu/Wh2K4HljJeMVHbNnm55VIFLIgyy y1dJSk2HqWSfgoF/1/qb4sKoHTkdyIOGFLStzillVpSsCcccrU1xk0ycZ r9ulmsdWGNguCLk5C3RHarUKSxYe7YtBcu+kqiKg/SbmZyKTsp/MGAlGn t0EgON5mXS6uUzbkxvETtWwUgiCdS4VNNWzmrXiqvSF6oJTm7gKFlhkHB 99lGuL1e81h+Ryc7ma+4Kw5t9NIRO9ZQju0/zqY3f7WxKR8GgTcTeamoU w==; X-CSE-ConnectionGUID: x1jygypnQCy+mKc70feu5Q== X-CSE-MsgGUID: PQutqz3ST4idnFAi7ldHxQ== X-IronPort-AV: E=McAfee;i="6800,10657,11841"; a="83543140" X-IronPort-AV: E=Sophos;i="6.25,154,1779174000"; d="scan'208";a="83543140" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jul 2026 14:54:52 -0700 X-CSE-ConnectionGUID: jaoiRWSESKaLCb6cQBCH7A== X-CSE-MsgGUID: ptQyJZmNRRCxsLaiywo/qw== X-ExtLoop1: 1 Received: from gsse-cloud1.jf.intel.com ([10.54.39.91]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jul 2026 14:54:52 -0700 From: Matthew Brost To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: Carlos Santa , Ryan Neph , Christian Koenig , Huang Rui , Matthew Auld , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , linux-kernel@vger.kernel.org, =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= Subject: [PATCH v2 16/33] drm/xe: Back off beneficial-order reclaim under defrag pressure Date: Fri, 10 Jul 2026 14:54:25 -0700 Message-Id: <20260710215442.2444235-17-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260710215442.2444235-1-matthew.brost@intel.com> References: <20260710215442.2444235-1-matthew.brost@intel.com> 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 Once a meaningful number of BOs are already tracked as being backed at a sub-optimal order, continuing to push hard for beneficial-order pages during populate mostly wastes time in reclaim/compaction. In xe_ttm_tt_populate(), set ctx->beneficial_reclaim_backoff when the device defrag count reaches XE_BO_DEFRAG_RECLAIM_BACKOFF_THRESHOLD (2) so the TTM pool backs off and allocations make forward progress. The deferred defrag pass is responsible for upgrading these objects to beneficial order later. Cc: Carlos Santa Cc: Ryan Neph Cc: Christian Koenig Cc: Huang Rui Cc: Matthew Auld Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: David Airlie Cc: Simona Vetter Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org Cc: Thomas Hellström Assisted-by: GitHub_Copilot:claude-opus-4.8 Signed-off-by: Matthew Brost --- drivers/gpu/drm/xe/xe_bo.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c index d7b0536564ab..21d087170ef3 100644 --- a/drivers/gpu/drm/xe/xe_bo.c +++ b/drivers/gpu/drm/xe/xe_bo.c @@ -41,6 +41,14 @@ #include "xe_vm.h" #include "xe_vram_types.h" +/* + * Once this many BOs are tracked on the device defrag list (i.e. were backed + * with a sub-optimal page order), request that the TTM pool backs off from + * aggressive reclaim at the beneficial order during populate, so that + * allocations make forward progress instead of stalling. + */ +#define XE_BO_DEFRAG_RECLAIM_BACKOFF_THRESHOLD 2 + const char *const xe_mem_type_to_name[TTM_NUM_MEM_TYPES] = { [XE_PL_SYSTEM] = "system", [XE_PL_TT] = "gtt", @@ -598,6 +606,12 @@ static int xe_ttm_tt_populate(struct ttm_device *ttm_dev, struct ttm_tt *tt, if (ttm_tt_is_backed_up(tt) && !xe_tt->purgeable) { err = ttm_tt_restore(ttm_dev, tt, ctx); } else { + struct xe_device *xe = ttm_to_xe_device(ttm_dev); + + if (atomic_read(&xe->mem.defrag.count) >= + XE_BO_DEFRAG_RECLAIM_BACKOFF_THRESHOLD) + ctx->beneficial_reclaim_backoff = true; + ttm_tt_clear_backed_up(tt); err = ttm_pool_alloc(&ttm_dev->pool, tt, ctx); } -- 2.34.1