[PATCH 00/11] v4l2: Add tracing for stateless codecs

Detlev Casanova detlev.casanova at collabora.com
Fri May 1 11:07:08 PDT 2026


Hi Nicolas,

On 4/28/26 15:52, Nicolas Dufresne wrote:
> Le jeudi 12 février 2026 à 11:23 -0500, Detlev Casanova a écrit :
>> Hi !
>>
>> This patchset aims to improve codec event tracing in v4l2.
>>
>> The traces added in visl by Daniel Almeida are moved to the global trace
>> events and slightly reworked to be printed in a more consistent format.
>>
>> To each trace are also added a tgid and fd fields, helping userspace track
>> different decoding sessions (contexts) based on the given file descriptor
>> used by the given process id.
>>
>> Also for better tracking, stream on and stream off events are added as
>> well as HW run and HW done events to track decoder core usage.
>>
>> Finally, add a show_fdinfo callback on video device files, allowing drivers
>> to expose usage information.
>> Currently only used for frame buffer memory usage.
>>
>> The main focus is to be able to generate perfetto traces to show VPU usage,
>> a perfetto producer using this can be found at [1].
>>
>> [1]:
>> https://gitlab.collabora.com/detlev/hantro-perf/-/tree/hantro-improved-info
> I would recommend renaming this repo, as its not really evolving toward
> something truly hantro specific anymore, same goes for the code below appart
> from the run/done traces and the fdinfo that has to be opted in.
Yes, hantro was the first focus, but I've also been integrating rkvdec 
into this.
>
> There is effectively a bit of an overlap with the v4l2-tracer, but there is also
> advantages having it in the kernel, as you source all the event, for the entire
> system, in one place, so I'm fine with that. Considering the possible large
> overhead of the full trace, I'd like to see the ability to filter what we want
> to trace, with some level of granularity.
Tracing is by default disable and and has a really small performance 
footprint when disabled.
On the userspace side, each trace events can be enabled separately and 
even filtered (although I'm not sure filtering is good for performance, 
has it has to match each event with a regex).
> Maybe we only need decode_params for
> specific use case to be debugged, and don't care about large scaling list/matrix
> ? I would also like to see some Documentation on the tracing, so that its usage
> is not only explained in a tool.
Agreed.
> To Hans, there is nice tools idea in there, the perfetto producer is simply C++,
> and the v4l2top utility is Rust. Would you see these as tools v4l2-utils ? For
> the rust part, we can either leave the build independent, and cargo would be
> used to build and run, or we can implement a meson wrapper around cargo. But I
> don't believe its a good idea to use native rustc support in meson for that one
> because of the large number of third party crate needed.
>
> I like the direction, hope the feedback suite you well.
>
> Nicolas
>
>> Detlev Casanova (11):
>>    media: Move visl traces to v4l2-core
>>    media: Reformat v4l2-requests trace event printk
>>    media: Add tgid and fd fields in v4l2_fh struct
>>    media: Add tgid and fd to the v4l2-requests trace fields
>>    media: Add missing types to v4l2_ctrl_ptr
>>    media: Trace the stateless controls when set in v4l2-ctrls-core.c
>>    media: Add stream on/off traces and run them in the ioctl
>>    media: Add HW run/done trace events
>>    media: hantro: Add v4l2_hw run/done traces
>>    media: v4l2: Add callback for show_fdinfo
>>    media: hantro: Add fdinfo callback
>>
>>   drivers/media/platform/verisilicon/hantro.h   |    2 +
>>   .../media/platform/verisilicon/hantro_drv.c   |   25 +
>>   .../media/platform/verisilicon/hantro_v4l2.c  |   10 +-
>>   .../verisilicon/rockchip_vpu981_regs.h        |    1 +
>>   .../platform/verisilicon/rockchip_vpu_hw.c    |    4 +
>>   drivers/media/test-drivers/visl/Makefile      |    2 +-
>>   drivers/media/test-drivers/visl/visl-dec.c    |   76 -
>>   .../media/test-drivers/visl/visl-trace-av1.h  |  314 ---
>>   .../media/test-drivers/visl/visl-trace-fwht.h |   66 -
>>   .../media/test-drivers/visl/visl-trace-h264.h |  349 ----
>>   .../media/test-drivers/visl/visl-trace-hevc.h |  464 -----
>>   .../test-drivers/visl/visl-trace-mpeg2.h      |   99 -
>>   .../test-drivers/visl/visl-trace-points.c     |   11 -
>>   .../media/test-drivers/visl/visl-trace-vp8.h  |  156 --
>>   .../media/test-drivers/visl/visl-trace-vp9.h  |  292 ---
>>   drivers/media/v4l2-core/v4l2-ctrls-api.c      |   10 +
>>   drivers/media/v4l2-core/v4l2-ctrls-core.c     |  114 +
>>   drivers/media/v4l2-core/v4l2-dev.c            |   10 +
>>   drivers/media/v4l2-core/v4l2-fh.c             |    1 +
>>   drivers/media/v4l2-core/v4l2-ioctl.c          |   37 +-
>>   drivers/media/v4l2-core/v4l2-trace.c          |   48 +
>>   include/media/v4l2-ctrls.h                    |   19 +
>>   include/media/v4l2-dev.h                      |    1 +
>>   include/media/v4l2-fh.h                       |    4 +
>>   include/trace/events/v4l2.h                   |   58 +
>>   include/trace/events/v4l2_requests.h          | 1836 +++++++++++++++++
>>   26 files changed, 2178 insertions(+), 1831 deletions(-)
>>   delete mode 100644 drivers/media/test-drivers/visl/visl-trace-av1.h
>>   delete mode 100644 drivers/media/test-drivers/visl/visl-trace-fwht.h
>>   delete mode 100644 drivers/media/test-drivers/visl/visl-trace-h264.h
>>   delete mode 100644 drivers/media/test-drivers/visl/visl-trace-hevc.h
>>   delete mode 100644 drivers/media/test-drivers/visl/visl-trace-mpeg2.h
>>   delete mode 100644 drivers/media/test-drivers/visl/visl-trace-points.c
>>   delete mode 100644 drivers/media/test-drivers/visl/visl-trace-vp8.h
>>   delete mode 100644 drivers/media/test-drivers/visl/visl-trace-vp9.h
>>   create mode 100644 include/trace/events/v4l2_requests.h




More information about the linux-arm-kernel mailing list