From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 174C0126C02 for ; Wed, 6 May 2026 03:33:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778038389; cv=none; b=OaX0ots637kVeRnWne/IR2Nejlop2ExmHgVBm0pm8xxgU+qX8POqDKMwG6ElYcaFUBcoDtjrC75HZApETyC4J+r/d7vwwZ9f+zpXFKFp+cu0nsOdjuMg1SnUbm7W2aG+XyLe6yxHOPsoku5wdZ7Zw0pYRCXZu0Kxd4G9xf6aAJ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778038389; c=relaxed/simple; bh=kfiSeyy6TX7E2Ycbz/YAGvO5z9U19PNK24VluwAir5s=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=fo0J7cDKCMBl3IlPGWkulcdnM8QVGSLJNeKKIljxEgwSvqcc3kMUXoP3RrDHQAeSzjETY5yxjDhVs7e9Jj3Ld3j/blLdoOirMUOzXCJN+oHQX3sTMD8UNfclmmGL7X0omQa9PEfTZPJwURCgroRSqDEFS2BpB6kgNp6sAESu3O4= 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=abu83tYu; arc=none smtp.client-ip=198.175.65.21 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="abu83tYu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1778038388; x=1809574388; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=kfiSeyy6TX7E2Ycbz/YAGvO5z9U19PNK24VluwAir5s=; b=abu83tYuYUa96rbBtFzPYbJJ3stZmcJFePIoQ1KBKJivAP4YD9836qb1 +Htm/gnjXO46YRT0dOG7FEa2Elj74fQEYFWV1STnoKNuuMkczWtda+vtA JLKEfu+mHeEEeqOxyqegs14O8HDpbjXzD1PrSPEiPgjFqJTu2larhq0p5 /LcjnBIvKvNzDmVHWXW65dhzq48/BAj18bPzKZoucQVuWCn6SGhurvzzH +HUtp/XhMYMRq+PAsOZ29l/1J+h8ym+S83WPBc+SpvWkL0kE3HgY5okng QQWPBj4fS4zl9zpUcWcekTMuyCntTydIJR2JofuHV4xDth0RLcMuUTsKO A==; X-CSE-ConnectionGUID: VLFDtVDZS1y9ivU0w54hwA== X-CSE-MsgGUID: XctV8fvoTOit+dj6IVKoDw== X-IronPort-AV: E=McAfee;i="6800,10657,11777"; a="78829009" X-IronPort-AV: E=Sophos;i="6.23,218,1770624000"; d="scan'208";a="78829009" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2026 20:33:06 -0700 X-CSE-ConnectionGUID: WqzPK9p/RQ+MwU1h2N649A== X-CSE-MsgGUID: Yugi3qNSSg28Cd6KFmMrlQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,218,1770624000"; d="scan'208";a="266342145" Received: from gsse-cloud1.jf.intel.com ([10.54.39.91]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2026 20:33:06 -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 v5 0/5] mm, drm/ttm, drm/xe: Avoid reclaim/eviction loops under fragmentation Date: Tue, 5 May 2026 20:32:55 -0700 Message-Id: <20260506033300.3534883-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 Alternative approach to [1]. 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 three layers: MM: Introduce an opportunistic_compaction hint in shrink_control. kswapd folds the gfp flags of its wakers into a per-pgdat tri-state (see enum kswapd_opportunistic_compaction_type) and forwards it to shrinkers. The hint is set when every waker for a kswapd run is a failable high-order allocation (__GFP_NORETRY or __GFP_RETRY_MAYFAIL, without __GFP_NOFAIL) — i.e. callers that would rather see the allocation fail than have working sets torn down to satisfy it. Any order-0 or non-failable waker clears the hint for that run, so normal memory pressure is unaffected. TTM: Restrict direct reclaim to beneficial_order. Larger allocations use __GFP_NORETRY so they fail fast (and feed the opportunistic hint above) rather than synchronously triggering reclaim that is unlikely to produce a contiguous higher-order block. Xe: Consume shrink_control::opportunistic_compaction in the Xe shrinker. When the hint is set for a high-order pass, the shrinker skips advertising and performing TTM backup work — which operates at native page order and would not help compaction — and avoids tearing down active GPU working sets. Order-0 and non-opportunistic reclaim behaviour is unchanged, so the shrinker still participates fully under genuine memory pressure. 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) v5: - Use shrinker based heurstics (Dave Chinner, Thomas's GFP idea) - Rename lazy_compaction → opportunistic_compaction [1] https://patchwork.freedesktop.org/series/165330/#rev3 [2] 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 (5): mm: Wire up order in shrink_control mm: Introduce opportunistic_compaction concept to vmscan and shrinkers drm/ttm: Issue direct reclaim at beneficial_order drm/xe: Set TTM device beneficial_order to 9 (2M) drm/xe: Make use of shrink_control::opportunistic_compaction hint drivers/gpu/drm/ttm/ttm_pool.c | 4 +- drivers/gpu/drm/xe/xe_device.c | 3 +- drivers/gpu/drm/xe/xe_shrinker.c | 20 +++++++-- include/linux/mmzone.h | 40 +++++++++++++++++ include/linux/shrinker.h | 23 ++++++++++ mm/internal.h | 5 ++- mm/shrinker.c | 23 +++++++--- mm/vmscan.c | 73 +++++++++++++++++++++++++++++--- 8 files changed, 170 insertions(+), 21 deletions(-) -- 2.34.1