Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.20 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796329438; b=rKGD8YlSNeN4zL8UoQ5gpN/4Ic5ZlQ5qBKNm5AOxzjgW0pW2ZDwFUlkIMcXcZLFUJbeh uY7ozwKbC6YALfrZweJ7n7xD/QqFrgbbH5RFUMuYAk+9YHqQ4hZKapmX6w3SmmTlNXHVh JshHsYTF0vW2VnVJO4rl80ZQxqNtzwz3e6Zvul1Fqyno9MafONgEk3UwBUlE7VraR7aK3 4F9AwrigoTEG12/k18QpLfTvTNJY/gJ7OoHvnC7hKo/DyCKY86t1wkyvVEs70t4f9IjNu fS6/XJ0XATDq4LqF5Srpx2yzOqgZgfCrX3051AU3mPdXSJNVdtK9Bfqb+7FguF4Jvlg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796329438; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Type:Content-Transfer-Encoding; bh=Q101RlCTcRB4Hh7ssZtGkl2UFOnW4tZFBdbHLvuscWM=; b=niNb6z7+LSwfeWhTPhFcN+Z0k82iAAYGQSQ2jlBF1pmG5xpn2JMH4whQSCtab1cwhkEU qZzIZF7+C6sW7sWtZw3hxTtzAFxWpn1itnmpcXUCeW6itPRGgRo1jTPe55P7qvFTQ0STZ onPsHR5TaC8lD+BoN66Ce/WMAUjSlhLaKWW8ZSy4prZJfJuiaWoABsX1TRR03JEqres69 EfwT06SbO1A6zXZR/4waZaDFjjQuUYVvNsHq1/BXJeQ10yKaVJ3FdU29ncEeFW5RC7+L2 rmsaNim3LwlA+C9d+tWESZNufbbjEgwtMTAkK18A14W8LRP256z48UIRg8Mu6/cqDIA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=YVANwZu5; arc=none smtp.remote-ip=198.175.65.20 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25FAF606A322 for ; Thu, 3 Dec 2026 20:23:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 25FAF606A322 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.a=rsa-sha256 header.s=Intel header.b=YVANwZu5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796329439; x=1827865439; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q101RlCTcRB4Hh7ssZtGkl2UFOnW4tZFBdbHLvuscWM=; b=YVANwZu5kjV91I+5K6vw6cuWKn93INdPdF+TbwDCRH7D50LU70J+hxbz akeeL/Du7m0yYRZb9ipLuJxOqQgtuhZXZNI8XAGKrPGh8DsqS2Nmhz+m7 xc8UpXjnaeXeW9RXkbksVCdW+Wx2uzgPTBjs/d5qjZfJjjAVYNLYS0fPJ +PAsFh+Xb8mvTaKih6OiYbCaAiTZNvq36TyIgecBbvIndHHx0o4Uq+Oew JP45MI1YKslXQh+x89ZbH98DcqiHj0Mk1GJQZ7LCOMbP6IG/o3ekLAg/W zUe5me/6+hHp8spyJRVwu5fGP348wHRqGtkQ7TDth8t50KS1SejJQLTCI Q==; X-CSE-ConnectionGUID: 88F5X6+WSDezWpquGDom8Q== X-CSE-MsgGUID: ZxEqBreuSduee7nn8xsJyw== X-IronPort-AV: E=McAfee;i="6800,10657,11985"; a="5350987" X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="5350987" Received: from fmviesa013.fm.intel.com ([10.60.135.153]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 12:23:58 -0800 X-CSE-ConnectionGUID: 6dPQjn2iRhCAadFCbzqTyA== X-CSE-MsgGUID: yTUi8fIiSSWa++6R9CIu7g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="15862407" Received: from gsse-cloud1.jf.intel.com ([10.54.39.91]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 12:23:57 -0800 From: Matthew Brost To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: Carlos Santa , Ryan Neph , Natalie Vock , Arun Pravin , Matthew Auld , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , linux-kernel@vger.kernel.org, =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Niranjana Vishwanathapura Subject: [PATCH v6 01/35] drm/ttm/pool: Allow backing off reclaim at the beneficial order Date: Thu, 3 Dec 2026 12:23:18 -0800 Message-Id: <20261203202352.4153159-2-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261203202352.4153159-1-matthew.brost@intel.com> References: <20261203202352.4153159-1-matthew.brost@intel.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allocating at the pool's beneficial order normally uses __GFP_RETRY_MAYFAIL to push hard for a contiguous high-order page. When beneficial-order allocations have recently been failing, this retry just burns CPU cycles in reclaim/compaction before falling back to a smaller order anyway. Add a beneficial_reclaim_backoff flag to struct ttm_operation_ctx and plumb it through to ttm_pool_alloc_page(). When set, the beneficial order is treated like the orders we already consider not worth stalling for: __GFP_RECLAIM is cleared so the allocation skips reclaim/compaction entirely, and the __GFP_NORETRY clearing / __GFP_RETRY_MAYFAIL promotion is skipped. Together this makes the allocator back off quickly to a smaller order instead of stalling. This is a no-op until a caller opts in. Cc: Carlos Santa Cc: Ryan Neph Cc: Natalie Vock Cc: Arun Pravin 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 Signed-off-by: Matthew Brost Reviewed-by: Niranjana Vishwanathapura --- drivers/gpu/drm/ttm/ttm_pool.c | 12 ++++++++---- include/drm/ttm/ttm_bo.h | 7 +++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c index 6894536e85ce..16fd125d7375 100644 --- a/drivers/gpu/drm/ttm/ttm_pool.c +++ b/drivers/gpu/drm/ttm/ttm_pool.c @@ -160,7 +160,8 @@ static int ttm_pool_nid(struct ttm_pool *pool) /* Allocate pages of size 1 << order with the given gfp_flags */ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags, - unsigned int order) + unsigned int order, + bool beneficial_reclaim_backoff) { const unsigned int beneficial_order = ttm_pool_beneficial_order(pool); unsigned long attr = DMA_ATTR_FORCE_CONTIGUOUS; @@ -180,10 +181,12 @@ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags, * Do not add latency to the allocation path for allocations orders * device tolds us do not bring them additional performance gains. */ - if (order && beneficial_order && order != beneficial_order) + if (order && beneficial_order && + (beneficial_reclaim_backoff || order != beneficial_order)) gfp_flags &= ~__GFP_RECLAIM; - if (beneficial_order && order == beneficial_order) { + if (!beneficial_reclaim_backoff && + beneficial_order && order == beneficial_order) { gfp_flags &= ~__GFP_NORETRY; gfp_flags |= __GFP_RETRY_MAYFAIL; } @@ -830,7 +833,8 @@ static int __ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt, if (!p) { page_caching = ttm_cached; allow_pools = false; - p = ttm_pool_alloc_page(pool, gfp_flags, order); + p = ttm_pool_alloc_page(pool, gfp_flags, order, + ctx->beneficial_reclaim_backoff); } /* If that fails, lower the order if possible and retry. */ if (!p) { diff --git a/include/drm/ttm/ttm_bo.h b/include/drm/ttm/ttm_bo.h index 53d130a02111..cd3d3980dbce 100644 --- a/include/drm/ttm/ttm_bo.h +++ b/include/drm/ttm/ttm_bo.h @@ -187,6 +187,13 @@ struct ttm_operation_ctx { * when multiple BOs share the same reservation object @resv. */ bool allow_res_evict; + /** + * @beneficial_reclaim_backoff: Back off from direct reclaim at the + * pool's beneficial order. Useful when beneficial-order allocation has + * recently been failing, to avoid burning CPU cycles in + * reclaim/compaction before falling back to a smaller order anyway. + */ + bool beneficial_reclaim_backoff; /** * @resv: Reservation object to be used together with * @allow_res_evict. -- 2.34.1