Linux Trace Kernel
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Detlev Casanova" <detlev.casanova@collabora.com>
Cc: linux-trace-kernel@vger.kernel.org, media-ci@linuxtv.org
Subject: Re: [PATCH v3 4/9] media: Add tgid and fd to the v4l2-requests trace fields
Date: Wed, 25 Nov 2026 18:56:35 +0000	[thread overview]
Message-ID: <sashiko-outbox-234022@kernel.org> (raw)
In-Reply-To: <20261125-v4l2-add-ftrace-v3-4-1d1db48372ed@collabora.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] media: v4l2_controls tracepoints declare signed fd as unsigned
  u32
--

commit 3152eaf4ee2021252442052cd8aab150bbaf3891
Author: Detlev Casanova <detlev.casanova@collabora.com>

media: Add tgid and fd to the v4l2-requests trace fields

This commit adds the v4l2_fh tgid and fd fields to all v4l2_controls
tracepoints and updates visl_trace_ctrls() to pass them.

> diff --git a/include/trace/events/v4l2_controls.h b/include/trace/events/v4l2_controls.h
> index 722e10a5078e3..531aef185b85e 100644
> --- a/include/trace/events/v4l2_controls.h
> +++ b/include/trace/events/v4l2_controls.h
> @@ -17,27 +17,39 @@
>   * They can be identified by the name of the event. All control fields are copied in a TP_STRUCT
>   * field so that they can be filtered separately in userspace.
>   *
> + * In addition to the controls fields, tgid and fd are also added in each trace events.
> + * This allows to identify controls set by a specific process and to match them with other events
> + * from the same process.
> + * tgid contains the process id that opened the video device.
> + * fd is the file descriptor in the tgid, used in case a process opens multiple video devices.
> + *
>   * Currently only the codec controls are supported.
>   */
>  
>  /* AV1 controls */
>  DECLARE_EVENT_CLASS(v4l2_ctrl_av1_seq_tmpl,
> -	TP_PROTO(const struct v4l2_ctrl_av1_sequence *s),
> -	TP_ARGS(s),
> -	TP_STRUCT__entry(__field(__u32, flags)
> +	TP_PROTO(u32 tgid, u32 fd, const struct v4l2_ctrl_av1_sequence *s),
> +	TP_ARGS(tgid, fd, s),
> +	TP_STRUCT__entry(__field(u32, tgid)
> +			 __field(u32, fd)
> +			 __field(__u32, flags)
>  			 __field(__u8, seq_profile)
>  			 __field(__u8, order_hint_bits)
>  			 __field(__u8, bit_depth)
>  			 __field(__u16, max_frame_width_minus_1)
>  			 __field(__u16, max_frame_height_minus_1)),
> -	TP_fast_assign(__entry->flags = s->flags;
> +	TP_fast_assign(__entry->tgid = tgid;
> +		       __entry->fd = fd;
> +		       __entry->flags = s->flags;
>  		       __entry->seq_profile = s->seq_profile;
>  		       __entry->order_hint_bits = s->order_hint_bits;
>  		       __entry->bit_depth = s->bit_depth;
>  		       __entry->max_frame_width_minus_1 = s->max_frame_width_minus_1;
>  		       __entry->max_frame_height_minus_1 = s->max_frame_height_minus_1;),
> -	TP_printk("\nflags %s\nseq_profile: %u\norder_hint_bits: %u\nbit_depth: %u\n"
> +	TP_printk("tgid = %u, fd = %u\n"
> +		  "flags %s\nseq_profile: %u\norder_hint_bits: %u\nbit_depth: %u\n"
>  		  "max_frame_width_minus_1: %u\nmax_frame_height_minus_1: %u\n",
> +		  __entry->tgid, __entry->fd,

[Severity: Low]
Should fd be declared as a signed int (or s32) and printed with %d
across all trace events in v4l2_controls.h?

struct v4l2_fh defines fd as int, and __video_do_ioctl() sets
vfh->fd = -1 when iterate_fd() returns 0 (for example, when the video
device is opened on file descriptor 0):

drivers/media/v4l2-core/v4l2-ioctl.c:__video_do_ioctl() {
	...
	if (unlikely(!vfh->fd)) {
		vfh->fd = iterate_fd(current->files, 0, _file_iterate, file);
		if (!vfh->fd)
			vfh->fd = -1;
	}
	...
}

Declaring fd as u32 and formatting it with %u turns -1 into 4294967295
in the trace output and exposes an unsigned field in tracefs.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-v4l2-add-ftrace-v3-0-1d1db48372ed@collabora.com?part=4

  reply	other threads:[~2026-11-25 18:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 18:33 [PATCH v3 0/9] v4l2: Add tracing for stateless codecs Detlev Casanova
2026-11-25 18:33 ` [PATCH v3 1/9] media: Move visl traces to v4l2-core Detlev Casanova
2026-11-25 18:58   ` sashiko-bot
2026-11-25 18:33 ` [PATCH v3 2/9] media: Map each struct field to its own trace field Detlev Casanova
2026-11-25 18:33 ` [PATCH v3 3/9] media: Add tgid and fd fields in v4l2_fh struct Detlev Casanova
2026-11-25 18:59   ` sashiko-bot
2026-11-25 18:33 ` [PATCH v3 4/9] media: Add tgid and fd to the v4l2-requests trace fields Detlev Casanova
2026-11-25 18:56   ` sashiko-bot [this message]
2026-11-25 18:33 ` [PATCH v3 5/9] media: Add missing types to v4l2_ctrl_ptr Detlev Casanova
2026-11-25 18:33 ` [PATCH v3 6/9] media: Trace the stateless controls when set in v4l2-ctrls-core.c Detlev Casanova
2026-11-25 19:00   ` sashiko-bot
2026-11-25 18:33 ` [PATCH v3 7/9] media: Add stream on/off traces and run them in the ioctl Detlev Casanova
2026-11-25 18:57   ` sashiko-bot
2026-11-25 18:33 ` [PATCH v3 8/9] media: Add HW run/done trace events Detlev Casanova
2026-11-25 18:33 ` [PATCH v3 9/9] media: hantro: Add v4l2_hw run/done traces Detlev Casanova
2026-11-25 19:01   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-234022@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=detlev.casanova@collabora.com \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=media-ci@linuxtv.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox