From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.12 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796168962; b=1P8meAtV2JtKaL4YLdNxRbfcC5GdGIO4aM0YL9mkb0RcO7RuvN3eSV0tPgupGWdoCSj+ Bl7MNXTO23z4L14AjSEdTf4dffoUtrbS6sHVTAIFFRW4un4yN0eiAV6j1MlNxoasNi+as 8M5p4zgixKCI8KA0/V3/Z+oEQFBGgY6fv59KTaceIy77lza9Y/LvMjHPsd8Dt5GpBUiJB TXB1TQ274Eh0azgAXDgFO/mylg3sLqGdZ83ZZ2X83sp8g9fUEgV4KdwUvF6ePKh6K19lA mNNiZclvtRcBonptvv17cAel8X5IS0MOzuW3ki86phYJzIR9AvYrs1qj5ZX5A1oYzaA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796168962; 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=79HaGLm9jo94v7tWwMcYT+9Azvh+dM6T8HXXoYfCa5Q=; b=0L5rrtrfBLN/5c3BpVdzxBeNcbK5OwLSZi7hmWa8oyc0vEbFftNHhRcuUVdKht7GOQD+ OBe5zLX8nIk+wumcRrVoe7+HEy1KmhB5qpj8YN/tJlTqcThcHx9/NZaB7zRJUrSc41juE VpD/SBf2Ivtk/itNVw5uMgyAuYS53wr1sinDw4Q5YbnnC5JcGWwV0JwEyClIjy+9BwoX2 4lxN8C1CXfa/3LWjKhJ/p4PSu/q4YLMgmCDR5ogUWIqpmTgcnp9PVw1cnvUqk1clDOzqY V7tW8ShZzye8Ylh6nKVMLHgcGAZQylhTq1UWd+SCzccL74pGqPtgSxbdjiwvb2qJzMw== 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=lea4L1sg; arc=none smtp.remote-ip=192.198.163.12 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 ECE57606A31A for ; Tue, 1 Dec 2026 23:49:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org ECE57606A31A 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=lea4L1sg 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: Y9mNv0+GRSGXiqCT1vKUEA== X-CSE-MsgGUID: 2DTg6KGNSgW0jLQf6cei2w== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="4977340" X-IronPort-AV: E=Sophos;i="6.27,245,1787036400"; d="scan'208";a="4977340" 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-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 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