Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.17 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796254410; b=VcUBS6DIw4nLY+nfjzMsUPmxtJ/dxIOihYYF8TtxgN+VCSXIeJNNzcLYbMNNZpPp9wMg gSfNVPadI8xEOBJqCZMY5Ei1Uza90USuKVe4/ZQT0BWotpiYadHsbAypNmEY2zbxly0UY eyW8yZ3zrrKJpgtjCKXvgHQ+msAO/Z9B2anCuGVU6vGUdjNwQ4FngIBpKpw7cqKFUpsV8 vlySDd7vnD7EmZcHDYVWL1/MFOVvE8/mDZ1OIVAxYTjJ3Oz/ELJUuyralQA/ODkWC4+Tf 5Kzr8b5BnfeqTLmAq6tb9nY1DB5+qI7IJJg70iRX7S0snyRNOoRfqaI3L+q3E8usIzg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796254410; 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=2GzfHk4f1DR5wztgWFiWd4nZavijpTWV//kvo8/fkI6ghSpdS0QpxIJKgkcJ+deSubwE sWU8Kla7FTID4w10GRcFWd7IxRx7wgUfRyHhRMK9q5xOjLHYJBbfWMRwT2YIIpnywXpOQ A062kh7q2JLiSnjt6WRNo3oBjtTGWMf0kwrWsEPKlXxJQk5PRhxDPwL9jNPf77HhegGsm nYY9wxWslrXZfWhKgAxO4vp4FJKciHmlvMoNe3RRAv8dgbbGAwv8bJE+3+0O1v7PdLXJl YhOdkWnWhH4k9XIuVNOwsMvzcie1H2d4GLkVBBBJ7+AgkdWq6fQqNLkWcensY1E5PSA== 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=c84a26cK; arc=none smtp.remote-ip=192.198.163.17 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 0DD33606A32C for ; Wed, 2 Dec 2026 23:33:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0DD33606A32C 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=c84a26cK DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796254409; x=1827790409; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q101RlCTcRB4Hh7ssZtGkl2UFOnW4tZFBdbHLvuscWM=; b=c84a26cKGv/+aCK3a2ZlykqXV2aW2rfnfNz3FzepVVjyfv0ELqv54zoQ z+mc45uuUgFVprq/sHsUhTMYpDk7/qKiGPjgFCBF2A0Piik6Q/8LK0CZ4 ajHsJcmlyowcImvqGsNbl1+z7IdKnb+CI6HYQTl/KH7BL2kMoDkKAyz2R OA+d2rHAgia6CeLnqWbUmo4zJ+noF5muTpCSIEoiAKg+t6waa4OW+i+Ui RNkBOUpMhcELwBfy9g49utkPET/j9WQs0IKOYECqsk3IuW17gndVmyEiB cruUEWS71b+0K+5Yb5NymUG4XAu0KDkIUkDt7FleZpssJPLduq/a0uzMi g==; X-CSE-ConnectionGUID: 1eCgDjZ2Tx2BW3te/VRU4A== X-CSE-MsgGUID: qoWCKMXUQ/CTdn3kVKef3A== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5203063" X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="5203063" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 15:33:28 -0800 X-CSE-ConnectionGUID: UuDbu2ohT1CQoQILZcdDoQ== X-CSE-MsgGUID: mp/eZ+sOTEOXhs2Y5F5K+g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="13484024" Received: from gsse-cloud1.jf.intel.com ([10.54.39.91]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 15:33:28 -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 v5 01/36] drm/ttm/pool: Allow backing off reclaim at the beneficial order Date: Wed, 2 Dec 2026 15:32:48 -0800 Message-Id: <20261202233323.3743190-2-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261202233323.3743190-1-matthew.brost@intel.com> References: <20261202233323.3743190-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