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 B7E2C606B4AA for ; Tue, 1 Dec 2026 23:49:39 +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=lea4L1sg Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B452C10FDF6; Tue, 1 Dec 2026 23:49:33 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5C43E10EA88; Tue, 1 Dec 2026 23:49:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796168962; x=1827704962; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=79HaGLm9jo94v7tWwMcYT+9Azvh+dM6T8HXXoYfCa5Q=; b=lea4L1sg8VHf0SQUgGUODyvjOnPjUS2+uTSyfor+hibZRHt/+gzdRvFE BqTxn7q0nvaimhXQlXfMOFWetEKhYkiOaFw49mUgCXxr8xrjSHTujOzwR k9kFcmoyHVs7vW6SGVfHtGtZ0LTei3j7QJbGA5ZttxUDnHf0wn0JwHbhR qkNjQVIdi6bojHzrnBC3S54YqqNCT4THew6HbQ5GipjoO0oKxnceTPHnF A6A3+YbYcfGyqDtUha6TgWamgTdNRpStowzoTIc2dPyAsdPVAouNOnx0q S7zAFkDXTieMIRyXyLq0eOOQW1WuxxwQdYYr21Q2Oz4J4w9/k6M8+IMwh A==; X-CSE-ConnectionGUID: keZk6ozgRkCxIONJIZkVjg== X-CSE-MsgGUID: 8Jx3nIyhROaSayOh+uLCNg== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="4977334" X-IronPort-AV: E=Sophos;i="6.27,245,1787036400"; d="scan'208";a="4977334" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 15:49:21 -0800 X-CSE-ConnectionGUID: RZjj+GShSOC308m0L0Iuww== X-CSE-MsgGUID: GOg3UaP1TgSxK+VNvUWNfg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,245,1787036400"; d="scan'208";a="13919904" Received: from gsse-cloud1.jf.intel.com ([10.54.39.91]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 15:49:21 -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?= Subject: [PATCH v4 01/33] drm/ttm/pool: Allow backing off reclaim at the beneficial order Date: Tue, 1 Dec 2026 15:48:43 -0800 Message-Id: <20261201234915.3305331-2-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261201234915.3305331-1-matthew.brost@intel.com> References: <20261201234915.3305331-1-matthew.brost@intel.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT 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 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 Assisted-by: LLM Signed-off-by: Matthew Brost --- 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