aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2025-06-04 08:09:01 +1000
committerDave Airlie <airlied@redhat.com>2025-06-05 07:15:12 +1000
commitc87a3f4fac5b6fee3b3e6a82a12147da5b5df507 (patch)
tree2cadb36405632df23261bf6c09b24a2b1346853d
parentdrm/ttm: Fix build with CONFIG_DEBUG_FS=n (diff)
downloadlinux-c87a3f4fac5b6fee3b3e6a82a12147da5b5df507.tar.gz
linux-c87a3f4fac5b6fee3b3e6a82a12147da5b5df507.zip
drm/ttm: handle undefined printf arg evaluation order in debugfs
When you read this debugfs file it's isn't guaranteed the count will happen before the scan, but I think the intent is that it does. printf argument evaluation order is undefined. Cc: Christian Koenig <christian.koenig@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Dave Airlie <airlied@redhat.com> Link: https://lore.kernel.org/r/20250603220901.1217161-1-airlied@gmail.com
-rw-r--r--drivers/gpu/drm/ttm/ttm_pool.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c
index cd31a30df3b0..99197aac09a1 100644
--- a/drivers/gpu/drm/ttm/ttm_pool.c
+++ b/drivers/gpu/drm/ttm/ttm_pool.c
@@ -1280,9 +1280,11 @@ static int ttm_pool_debugfs_shrink_show(struct seq_file *m, void *data)
.gfp_mask = GFP_NOFS,
.nr_to_scan = TTM_SHRINKER_BATCH,
};
+ unsigned long count;
fs_reclaim_acquire(GFP_KERNEL);
- seq_printf(m, "%lu/%lu\n", ttm_pool_shrinker_count(mm_shrinker, &sc),
+ count = ttm_pool_shrinker_count(mm_shrinker, &sc);
+ seq_printf(m, "%lu/%lu\n", count,
ttm_pool_shrinker_scan(mm_shrinker, &sc));
fs_reclaim_release(GFP_KERNEL);