Draft: virgl: add basic tracking of resource stats
Lacking real support for Blob resources, in some cases virgl uses guest kernel shadow buffers to facilitate host <--> guest transfers (e.g. PIPE_BUFFER
resources).
As suggested during internal discussion about !14495 (merged), we'd like to have some debug facilities to check the allocation of guest buffers:
[...] add VIRGL_DEBUG=res_stats to track and dump resource memory usage occasionally? We are interested in how many shmems are pinned, their sizes, and how they are accessed (not accessed, xfer src, or xfer dst).
I've recently begun working on this to answer related memory usage questions. The basic feature I have so far can be enabled with VIRGL_DEBUG=res_stats <command>
. The current stats are printed during driver pipe_screen
instance destruction (usually just process termination).
The output is something like:
VIRGL: Resource Stats:
VIRGL: ===============
VIRGL: - pinned memory: 4294967297
VIRGL: - resource count: 1025
Maybe we also want to periodically dump the stats (every few seconds?) in addition to doing so at client app termination. I also haven't addressed a few points of the initial ask, yet, but plan to do so (e.g. "how they are accessed").
Let me know what else we'd like to track here and I'll work on adding it.
/cc @gerddie