Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: add gpu active/reclaim per-node stat counters (v2)

While discussing memcg intergration with gpu memory allocations,
it was pointed out that there was no numa/system counters for
GPU memory allocations.

With more integrated memory GPU server systems turning up, and
more requirements for memory tracking it seems we should start
closing the gap.

Add two counters to track GPU per-node system memory allocations.

The first is currently allocated to GPU objects, and the second
is for memory that is stored in GPU page pools that can be reclaimed,
by the shrinker.

Cc: Christian Koenig <christian.koenig@amd.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: linux-mm@kvack.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Zi Yan <ziy@nvidia.com>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Acked-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>

+28 -1
+8
Documentation/filesystems/proc.rst
··· 1089 1089 CmaFree: 0 kB 1090 1090 Unaccepted: 0 kB 1091 1091 Balloon: 0 kB 1092 + GPUActive: 0 kB 1093 + GPUReclaim: 0 kB 1092 1094 HugePages_Total: 0 1093 1095 HugePages_Free: 0 1094 1096 HugePages_Rsvd: 0 ··· 1271 1269 Memory that has not been accepted by the guest 1272 1270 Balloon 1273 1271 Memory returned to Host by VM Balloon Drivers 1272 + GPUActive 1273 + System memory allocated to active GPU objects 1274 + GPUReclaim 1275 + System memory stored in GPU pools for reuse. This memory is not 1276 + counted in GPUActive. It is shrinker reclaimable memory kept in a reuse 1277 + pool because it has non-standard page table attributes, like WC or UC. 1274 1278 HugePages_Total, HugePages_Free, HugePages_Rsvd, HugePages_Surp, Hugepagesize, Hugetlb 1275 1279 See Documentation/admin-guide/mm/hugetlbpage.rst. 1276 1280 DirectMap4k, DirectMap2M, DirectMap1G
+5
drivers/base/node.c
··· 523 523 #ifdef CONFIG_UNACCEPTED_MEMORY 524 524 "Node %d Unaccepted: %8lu kB\n" 525 525 #endif 526 + "Node %d GPUActive: %8lu kB\n" 527 + "Node %d GPUReclaim: %8lu kB\n" 526 528 , 527 529 nid, K(node_page_state(pgdat, NR_FILE_DIRTY)), 528 530 nid, K(node_page_state(pgdat, NR_WRITEBACK)), ··· 558 556 , 559 557 nid, K(sum_zone_node_page_state(nid, NR_UNACCEPTED)) 560 558 #endif 559 + , 560 + nid, K(node_page_state(pgdat, NR_GPU_ACTIVE)), 561 + nid, K(node_page_state(pgdat, NR_GPU_RECLAIM)) 561 562 ); 562 563 len += hugetlb_report_node_meminfo(buf, len, nid); 563 564 return len;
+6
fs/proc/meminfo.c
··· 163 163 show_val_kb(m, "Balloon: ", 164 164 global_node_page_state(NR_BALLOON_PAGES)); 165 165 166 + show_val_kb(m, "GPUActive: ", 167 + global_node_page_state(NR_GPU_ACTIVE)); 168 + 169 + show_val_kb(m, "GPUReclaim: ", 170 + global_node_page_state(NR_GPU_RECLAIM)); 171 + 166 172 hugetlb_report_meminfo(m); 167 173 168 174 arch_report_meminfo(m);
+2
include/linux/mmzone.h
··· 260 260 #endif 261 261 NR_BALLOON_PAGES, 262 262 NR_KERNEL_FILE_PAGES, 263 + NR_GPU_ACTIVE, /* Pages assigned to GPU objects */ 264 + NR_GPU_RECLAIM, /* Pages in shrinkable GPU pools */ 263 265 NR_VM_NODE_STAT_ITEMS 264 266 }; 265 267
+5 -1
mm/show_mem.c
··· 254 254 " sec_pagetables:%lukB" 255 255 " all_unreclaimable? %s" 256 256 " Balloon:%lukB" 257 + " gpu_active:%lukB" 258 + " gpu_reclaim:%lukB" 257 259 "\n", 258 260 pgdat->node_id, 259 261 K(node_page_state(pgdat, NR_ACTIVE_ANON)), ··· 281 279 K(node_page_state(pgdat, NR_PAGETABLE)), 282 280 K(node_page_state(pgdat, NR_SECONDARY_PAGETABLE)), 283 281 str_yes_no(kswapd_test_hopeless(pgdat)), 284 - K(node_page_state(pgdat, NR_BALLOON_PAGES))); 282 + K(node_page_state(pgdat, NR_BALLOON_PAGES)), 283 + K(node_page_state(pgdat, NR_GPU_ACTIVE)), 284 + K(node_page_state(pgdat, NR_GPU_RECLAIM))); 285 285 } 286 286 287 287 for_each_populated_zone(zone) {
+2
mm/vmstat.c
··· 1281 1281 #endif 1282 1282 [I(NR_BALLOON_PAGES)] = "nr_balloon_pages", 1283 1283 [I(NR_KERNEL_FILE_PAGES)] = "nr_kernel_file_pages", 1284 + [I(NR_GPU_ACTIVE)] = "nr_gpu_active", 1285 + [I(NR_GPU_RECLAIM)] = "nr_gpu_reclaim", 1284 1286 #undef I 1285 1287 1286 1288 /* system-wide enum vm_stat_item counters */