Skip to contentSkip to conversation

ttm/pool: Use sentinels in debugfs

PATCH In review Mario Limonciello 2 participants 3 messages Apr 27 – May 21

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ttm/pool: Use sentinels in debugfs

The values in the page_pool_shrink debugfs file should recognize the sentinels rather than causing an underflow.

---
 drivers/gpu/drm/ttm/ttm_pool.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/ttm/ttm_pool.c +10 -3
index 26a3689e5fd90..4e83f4978b136 100644
@@ -1335,15 +1335,22 @@ 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;
+	unsigned long count, scanned;
 	int nid;
 
 	fs_reclaim_acquire(GFP_KERNEL);
 	for_each_node(nid) {
 		sc.nid = nid;
 		count = ttm_pool_shrinker_count(mm_shrinker, &sc);
-		seq_printf(m, "%d: %lu/%lu\n", nid, count,
-			   ttm_pool_shrinker_scan(mm_shrinker, &sc));
+		scanned = ttm_pool_shrinker_scan(mm_shrinker, &sc);
+
+		/* Convert shrinker API sentinel values to 0 for debugfs output */
+		if (count == SHRINK_EMPTY)
+			count = 0;
+		if (scanned == SHRINK_STOP)
+			scanned = 0;
+
+		seq_printf(m, "%d: %lu/%lu\n", nid, count, scanned);
 	}
 	fs_reclaim_release(GFP_KERNEL);
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 9 lines · Mario Limonciello

The values in the page_pool_shrink debugfs file should recognize the sentinels rather than causing an underflow.

---
  drivers/gpu/drm/ttm/ttm_pool.c | 13 ++++++++++---
  1 file changed, 10 insertions(+), 3 deletions(-)

ping?

Quoted 30 lines
drivers/gpu/drm/ttm/ttm_pool.c +10 -3
index 26a3689e5fd90..4e83f4978b136 100644
@@ -1335,15 +1335,22 @@ 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;
+	unsigned long count, scanned;
  	int nid;
 
  	fs_reclaim_acquire(GFP_KERNEL);
  	for_each_node(nid) {
  		sc.nid = nid;
  		count = ttm_pool_shrinker_count(mm_shrinker, &sc);
-		seq_printf(m, "%d: %lu/%lu\n", nid, count,
-			   ttm_pool_shrinker_scan(mm_shrinker, &sc));
+		scanned = ttm_pool_shrinker_scan(mm_shrinker, &sc);
+
+		/* Convert shrinker API sentinel values to 0 for debugfs output */
+		if (count == SHRINK_EMPTY)
+			count = 0;
+		if (scanned == SHRINK_STOP)
+			scanned = 0;
+
+		seq_printf(m, "%d: %lu/%lu\n", nid, count, scanned);
  	}
  	fs_reclaim_release(GFP_KERNEL);
 
Reviewed-by
#2 lore raw
Quoted 6 lines · Mario Limonciello
Quoted 3 lines · Mario Limonciello

The values in the page_pool_shrink debugfs file should recognize the sentinels rather than causing an underflow.

Quoted 7 lines
Quoted 6 lines

---
  drivers/gpu/drm/ttm/ttm_pool.c | 13 ++++++++++---

  1 file changed, 10 insertions(+), 3 deletions(-)

ping?

LGTM.

Regards,

Tvrtko

Quoted 31 lines
Quoted 30 lines
drivers/gpu/drm/ttm/ttm_pool.c +4 -3
index 26a3689e5fd90..4e83f4978b136 100644
@@ -1335,15 +1335,22 @@ 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;
+    unsigned long count, scanned;
       int nid;
       fs_reclaim_acquire(GFP_KERNEL);
       for_each_node(nid) {
           sc.nid = nid;
           count = ttm_pool_shrinker_count(mm_shrinker, &sc);
-        seq_printf(m, "%d: %lu/%lu\n", nid, count,
-               ttm_pool_shrinker_scan(mm_shrinker, &sc));
+        scanned = ttm_pool_shrinker_scan(mm_shrinker, &sc);
+
+        /* Convert shrinker API sentinel values to 0 for debugfs 

output */
+        if (count == SHRINK_EMPTY)
+            count = 0;
+        if (scanned == SHRINK_STOP)
+            scanned = 0;
+
+        seq_printf(m, "%d: %lu/%lu\n", nid, count, scanned); }
      fs_reclaim_release(GFP_KERNEL);