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 47AC11B7910 for ; Thu, 30 Apr 2026 19:18:16 +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=1777576698; cv=none; b=P2KWg7kLvZMbONpAcZxMokk6c0v3ww9nfuZShzpFXZY9NTJFIBKwVAwdjO8gSTFz+ptgi3Yn0bP139kiS6FDpoc2sUjUwJjxcEGFz50N3GvA3ggsomE5PGN1NHQwpA5KKjIIZ1UlymkJR/Od5duRUuYpZ9py5mG/jn6U+8l73yA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777576698; c=relaxed/simple; bh=L42AqUAT3K2YUIBwfKldplRFGyIb5HBQqwcfYoydKXo=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=Skq0m0O4Xcysi0F2k3dwsOF3Z2s09kWLi/M3Meu9D6DPc5AB8uB/R3izTzsFcGS4G32SjjCzHhQv0FhaJNPk42do4EjBQAnRyOE8QEmbwflRfyct9woGA9GV309oBwBr/ZUyynue1vu8vAx+WV3Cy3SvmmocCHwW4ETX9sxtt98= 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=dkM82LRl; 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="dkM82LRl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1777576696; x=1809112696; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=L42AqUAT3K2YUIBwfKldplRFGyIb5HBQqwcfYoydKXo=; b=dkM82LRlolaDNU1i8anIX03gG+kvg1T9oRFPVd3cwMdrfQps01GVKKvC tcwqJ/AvNYV3L+FHLW/OBDnkK2IirZH81B8ki0pi+4yM6aLigjdQIi029 yKyFA+rCPk1l1MaGCaVmguB1D9kXsxejg5NElcQ1FEzLoQsxV1VNX8XiQ iVW0QFWaIRlpDXRqT3M77qc0m1t7Es8BVMMayTeamTQ2MTr5yi5PDL9xc pRjXwZB1UazvAjJR579YELqInV/quGcNmQl1tO12T5JYFZyy2OxlAKuc6 uss1+z6skgEu2FvTqNQQEIeoeY2KYIREareaA7VPTTSoCR0R7gVXF1plg Q==; X-CSE-ConnectionGUID: oZf3GYdbTZeJLbD3iWtGpg== X-CSE-MsgGUID: S7kX/XRGR/yVQjDoobwgPA== X-IronPort-AV: E=McAfee;i="6800,10657,11772"; a="77706709" X-IronPort-AV: E=Sophos;i="6.23,208,1770624000"; d="scan'208";a="77706709" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Apr 2026 12:18:14 -0700 X-CSE-ConnectionGUID: GvPf6uxBSM6MkFg5UrhPnA== X-CSE-MsgGUID: dEMwV383Q5yUPDG4MwmODw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,208,1770624000"; d="scan'208";a="233801143" Received: from gsse-cloud1.jf.intel.com ([10.54.39.91]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Apr 2026 12:18:14 -0700 From: Matthew Brost To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: Dave Chinner , Qi Zheng , Roman Gushchin , Johannes Weiner , Shakeel Butt , Kairui Song , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Tvrtko Ursulin , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Carlos Santa , Christian Koenig , Huang Rui , Matthew Auld , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Daniel Colascione , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 0/6] mm, drm/ttm, drm/xe: Avoid reclaim/eviction loops under fragmentation Date: Thu, 30 Apr 2026 12:18:03 -0700 Message-Id: <20260430191809.2142544-1-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 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 TTM allocations at higher orders can drive Xe into a pathological reclaim loop when memory is fragmented: kswapd → shrinker → eviction → rebind (exec ioctl) → repeat In this state, reclaim is triggered despite substantial free memory, but fails to produce contiguous higher-order pages. The Xe shrinker then evicts active buffer objects, increasing faulting and rebind activity and further feeding the loop. The result is high CPU overhead and poor GPU forward progress. This issue was first reported in [1] and independently observed internally and by Google. A simple reproducer is: - Boot an iGPU system with mem=8G - Launch 10 Chrome tabs running the WebGL aquarium demo - Configure each tab with ~5k fish Under this workload, ftrace shows a continuous loop of: xe_shrinker_scan (kswapd) xe_vma_rebind_exec Performance degrades significantly, with each tab dropping to ~2 FPS on PTL (Ubuntu 24.04). At the same time, /proc/buddyinfo shows substantial free memory but no higher-order availability. For example, the Normal zone: Count: 4063 4595 3455 3400 3139 2762 2293 1655 643 0 0 This corresponds to ~2.8GB free memory, but no order-9 (2MB) blocks, indicating severe fragmentation. This series addresses the issue in two ways: TTM: Restrict direct reclaim to beneficial_order. Larger allocations use __GFP_NORETRY to fail quickly rather than triggering reclaim. Xe: Introduce a heuristic in the shrinker to avoid eviction when running under kswapd and the system appears memory-rich but fragmented. With these changes, the reclaim/eviction loop is eliminated. The same workload improves to ~10 FPS per tab (Ubuntu 24.04) or ~15 FPS per tab (Ubuntu 24.10), and kswapd activity subsides. Buddyinfo after applying this series shows restored higher-order availability: Count: 8526 7067 3092 1959 1292 660 194 28 20 13 1 Matt v2: - Layer with core MM / TTM helpers (Thomas) v4: - Fix build (CI) [1] https://patchwork.freedesktop.org/patch/716404/?series=164353&rev=1 Cc: Dave Chinner Cc: Qi Zheng Cc: Roman Gushchin Cc: Johannes Weiner Cc: Shakeel Butt Cc: Kairui Song Cc: Barry Song Cc: Axel Rasmussen Cc: Yuanchu Xie Cc: Wei Xu Cc: Tvrtko Ursulin Cc: Thomas Hellström Cc: Carlos Santa Cc: Christian Koenig Cc: Huang Rui Cc: Matthew Auld Cc: Matthew Brost Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: David Airlie Cc: Simona Vetter CC: dri-devel@lists.freedesktop.org Cc: Daniel Colascione Cc: Andrew Morton Cc: David Hildenbrand Cc: Lorenzo Stoakes Cc: "Liam R. Howlett" Cc: Vlastimil Babka Cc: Mike Rapoport Cc: Suren Baghdasaryan Cc: Michal Hocko Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Matthew Brost (6): mm: Wire up order in shrink_control mm: Introduce zone_maybe_fragmented_in_shrinker() drm/ttm: Issue direct reclaim at beneficial_order drm/ttm: Introduce ttm_bo_shrink_kswap_maybe_fragmented() drm/xe: Set TTM device beneficial_order to 9 (2M) drm/xe: Avoid shrinker reclaim from kswapd under fragmentation drivers/gpu/drm/ttm/ttm_bo_util.c | 38 +++++++++++++++++++++++++++++++ drivers/gpu/drm/ttm/ttm_pool.c | 4 ++-- drivers/gpu/drm/xe/xe_device.c | 3 ++- drivers/gpu/drm/xe/xe_shrinker.c | 3 +++ include/drm/ttm/ttm_bo.h | 2 ++ include/linux/shrinker.h | 3 +++ include/linux/vmstat.h | 12 ++++++++++ mm/internal.h | 4 ++-- mm/shrinker.c | 13 +++++++---- mm/vmscan.c | 7 +++--- 10 files changed, 76 insertions(+), 13 deletions(-) -- 2.34.1