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

drm/vmwgfx: Add a mksstat counter for cotable resizes

There's been a lot of cotable resizes on startup which we can track
by adding a mks stat to measure both the invocation count and
time spent doing cotable resizes.

This is only used if kernel is configured with CONFIG_DRM_VMWGFX_MKSSTATS
The stats are collected on the host size inside the vmware-stats.log
file.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Michael Banack <banackm@vmware.com>
Reviewed-by: Martin Krastev <krastevm@vmware.com>
Reviewed-by: Maaz Mombasawala <mombasawalam@vmware.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221022040236.616490-16-zack@kde.org

+22 -9
+11 -2
drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c
··· 33 33 #include <drm/ttm/ttm_placement.h> 34 34 35 35 #include "vmwgfx_drv.h" 36 + #include "vmwgfx_mksstat.h" 36 37 #include "vmwgfx_resource_priv.h" 37 38 #include "vmwgfx_so.h" 38 39 ··· 396 395 int ret; 397 396 size_t i; 398 397 398 + MKS_STAT_TIME_DECL(MKSSTAT_KERN_COTABLE_RESIZE); 399 + MKS_STAT_TIME_PUSH(MKSSTAT_KERN_COTABLE_RESIZE); 400 + 399 401 ret = vmw_cotable_readback(res); 400 402 if (ret) 401 - return ret; 403 + goto out_done; 402 404 403 405 cur_size_read_back = vcotbl->size_read_back; 404 406 vcotbl->size_read_back = old_size_read_back; ··· 415 411 true, true, vmw_bo_bo_free, &buf); 416 412 if (ret) { 417 413 DRM_ERROR("Failed initializing new cotable MOB.\n"); 418 - return ret; 414 + goto out_done; 419 415 } 420 416 421 417 bo = &buf->base; ··· 489 485 /* Release the pin acquired in vmw_bo_init */ 490 486 ttm_bo_unpin(bo); 491 487 488 + MKS_STAT_TIME_POP(MKSSTAT_KERN_COTABLE_RESIZE); 489 + 492 490 return 0; 493 491 494 492 out_map_new: ··· 499 493 ttm_bo_unpin(bo); 500 494 ttm_bo_unreserve(bo); 501 495 vmw_bo_unreference(&buf); 496 + 497 + out_done: 498 + MKS_STAT_TIME_POP(MKSSTAT_KERN_COTABLE_RESIZE); 502 499 503 500 return ret; 504 501 }
+2
drivers/gpu/drm/vmwgfx/vmwgfx_mksstat.h
··· 29 29 #define _VMWGFX_MKSSTAT_H_ 30 30 31 31 #include <asm/page.h> 32 + #include <linux/kconfig.h> 32 33 33 34 /* Reservation marker for mksstat pid's */ 34 35 #define MKSSTAT_PID_RESERVED -1 ··· 42 41 43 42 typedef enum { 44 43 MKSSTAT_KERN_EXECBUF, /* vmw_execbuf_ioctl */ 44 + MKSSTAT_KERN_COTABLE_RESIZE, 45 45 46 46 MKSSTAT_KERN_COUNT /* Reserved entry; always last */ 47 47 } mksstat_kern_stats_t;
+9 -7
drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
··· 85 85 u32 cookie_low; 86 86 }; 87 87 88 - 88 + #if IS_ENABLED(CONFIG_DRM_VMWGFX_MKSSTATS) 89 + /* Kernel mksGuestStats counter names and desciptions; same order as enum mksstat_kern_stats_t */ 90 + static const char* const mksstat_kern_name_desc[MKSSTAT_KERN_COUNT][2] = 91 + { 92 + { "vmw_execbuf_ioctl", "vmw_execbuf_ioctl" }, 93 + { "vmw_cotable_resize", "vmw_cotable_resize" }, 94 + }; 95 + #endif 89 96 90 97 /** 91 98 * vmw_open_channel ··· 702 695 /* Header to the text description of mksGuestStat instance descriptor */ 703 696 #define MKSSTAT_KERNEL_DESCRIPTION "vmwgfx" 704 697 705 - /* Kernel mksGuestStats counter names and desciptions; same order as enum mksstat_kern_stats_t */ 706 - static const char* const mksstat_kern_name_desc[MKSSTAT_KERN_COUNT][2] = 707 - { 708 - { "vmw_execbuf_ioctl", "vmw_execbuf_ioctl" }, 709 - }; 710 - 711 698 /** 712 699 * mksstat_init_record: Initializes an MKSGuestStatCounter-based record 713 700 * for the respective mksGuestStat index. ··· 787 786 /* Set up all kernel-internal counters and corresponding structures */ 788 787 pstrs_acc = pstrs; 789 788 pstrs_acc = mksstat_init_record_time(MKSSTAT_KERN_EXECBUF, pstat, pinfo, pstrs_acc); 789 + pstrs_acc = mksstat_init_record_time(MKSSTAT_KERN_COTABLE_RESIZE, pstat, pinfo, pstrs_acc); 790 790 791 791 /* Add new counters above, in their order of appearance in mksstat_kern_stats_t */ 792 792