From patchwork Tue Dec 13 09:15:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 17988 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 23D54C328D for ; Tue, 13 Dec 2022 09:16:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D00B96336E; Tue, 13 Dec 2022 10:16:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670922981; bh=RBr4bT1bI9efjqqwFc9pjDaNt8QG7v1WHc89a0WZTv0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ZABTxtygFOaOj/YlNuxYNE5VJY/mxbVNUa8B/NHy+l6sMtz9ahg9nJIKwIWnqCbwM 95jTvH4TUs4TSn9qyQMLlJsrJa/LypjuWWDCxSiLAhVXMs8sXcsIx6LlGf2XjmdPif jnRygntfTIUKH/o97wWm/QbunRUT21o6TGxEmSGXC2RawG3JXUwrPhFLZ8nggQgitc 0gSS29O0YHsF/czpfblS0wyf7O/EmSCuXdxBhubQTUpjASXrruiMzT0bMCN2qFbPBZ YwTqAsZ9lwzfJg9Y+sG1S128O+7RR9Ox4QQyyyhFj/Z5PhDJl+BJBoT7I2Nr7mO4y7 HiK2/N17kpBlA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 33B3363362 for ; Tue, 13 Dec 2022 10:16:19 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="uUtdpQN0"; dkim-atps=neutral Received: from pyrite.tail37cf.ts.net (h175-177-042-159.catv02.itscom.jp [175.177.42.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EC5164A7; Tue, 13 Dec 2022 10:16:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1670922978; bh=RBr4bT1bI9efjqqwFc9pjDaNt8QG7v1WHc89a0WZTv0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uUtdpQN0MkHU7Bp9tIdXNj0qjMg8FUbdN4AIp+fcY8ZQiUi7fqzS3Ksu5VI42LxxE CXcBVClCYcuVJKkO/ITFZ87Qttrnss4XKrkfM3udnMYDTser56wQIzJuI9SHZ+1Pb+ TqHg+6JtpJPm1IeNdVwP0gfmQRt+H3mrQCWerkFE= To: libcamera-devel@lists.libcamera.org Date: Tue, 13 Dec 2022 18:15:56 +0900 Message-Id: <20221213091558.621950-6-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221213091558.621950-1-paul.elder@ideasonboard.com> References: <20221213091558.621950-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 5/7] tracepoints: v4l2: Add tracepoints for tracking buffer lifetime X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add tracepoints in V4L2VideoDevice for tracing the lifetime of libcamera FrameBuffers. Signed-off-by: Paul Elder --- New in v2 --- .../internal/tracepoints/meson.build | 2 + .../libcamera/internal/tracepoints/v4l2.tp | 77 +++++++++++++++++++ .../internal/tracepoints/v4l2_enums.tp | 16 ++++ src/libcamera/v4l2_videodevice.cpp | 9 +++ 4 files changed, 104 insertions(+) create mode 100644 include/libcamera/internal/tracepoints/v4l2.tp create mode 100644 include/libcamera/internal/tracepoints/v4l2_enums.tp diff --git a/include/libcamera/internal/tracepoints/meson.build b/include/libcamera/internal/tracepoints/meson.build index d9b2fca5..83f1144b 100644 --- a/include/libcamera/internal/tracepoints/meson.build +++ b/include/libcamera/internal/tracepoints/meson.build @@ -4,9 +4,11 @@ tracepoint_files = files([ 'buffer_enums.tp', 'request_enums.tp', + 'v4l2_enums.tp', ]) tracepoint_files += files([ 'pipeline.tp', 'request.tp', + 'v4l2.tp', ]) diff --git a/include/libcamera/internal/tracepoints/v4l2.tp b/include/libcamera/internal/tracepoints/v4l2.tp new file mode 100644 index 00000000..f80eeb30 --- /dev/null +++ b/include/libcamera/internal/tracepoints/v4l2.tp @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Paul Elder + * + * v4l2.tp - Tracepoints for V4L2 devices + */ + +#include +#include + +#include "libcamera/internal/v4l2_device.h" +#include "libcamera/internal/v4l2_videodevice.h" + +TRACEPOINT_EVENT_CLASS( + libcamera, + v4l2_with_buffer, + TP_ARGS( + libcamera::V4L2VideoDevice *, vdev, + libcamera::FrameBuffer *, buf + ), + TP_FIELDS( + ctf_string(devnode, vdev->deviceNode().c_str()) + ctf_integer_hex(uintptr_t, buffer, reinterpret_cast(buf)) + ctf_enum(libcamera, buffer_status, uint32_t, buf_status, buf->metadata().status) + ) +) + +TRACEPOINT_EVENT( + libcamera, + v4l2_videodev_streamoff, + TP_ARGS( + libcamera::V4L2VideoDevice *, vdev, + uint32_t, stream_state, + uint32_t, queued_buffers_size + ), + TP_FIELDS( + ctf_string(devnode, vdev->deviceNode().c_str()) + ctf_enum(libcamera, v4l2_streaming_state, uint32_t, state, stream_state) + ctf_integer(uint32_t, queued_buffers, queued_buffers_size) + ) +) + +TRACEPOINT_EVENT( + libcamera, + v4l2_videodev_send_back_buffer, + TP_ARGS( + libcamera::V4L2VideoDevice *, vdev, + libcamera::FrameBuffer *, buf, + libcamera::Request *, req + ), + TP_FIELDS( + ctf_string(devnode, vdev->deviceNode().c_str()) + ctf_integer_hex(uintptr_t, buffer, reinterpret_cast(buf)) + ctf_enum(libcamera, buffer_status, uint32_t, buf_status, buf->metadata().status) + ctf_integer_hex(uintptr_t, request, reinterpret_cast(req)) + ) +) + +TRACEPOINT_EVENT_INSTANCE( + libcamera, + v4l2_with_buffer, + v4l2_videodev_add_buffer_to_queue, + TP_ARGS( + libcamera::V4L2VideoDevice *, vdev, + libcamera::FrameBuffer *, buf + ) +) + +TRACEPOINT_EVENT_INSTANCE( + libcamera, + v4l2_with_buffer, + v4l2_videodev_remove_buffer_from_queue, + TP_ARGS( + libcamera::V4L2VideoDevice *, vdev, + libcamera::FrameBuffer *, buf + ) +) diff --git a/include/libcamera/internal/tracepoints/v4l2_enums.tp b/include/libcamera/internal/tracepoints/v4l2_enums.tp new file mode 100644 index 00000000..38506e17 --- /dev/null +++ b/include/libcamera/internal/tracepoints/v4l2_enums.tp @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Paul Elder + * + * v4l2_enums.tp - Tracepoint definition for enums in V4L2 + */ + +TRACEPOINT_ENUM( + libcamera, + v4l2_streaming_state, + TP_ENUM_VALUES( + ctf_enum_value("Streaming", 0) + ctf_enum_value("Stopping", 1) + ctf_enum_value("Stopped", 2) + ) +) diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 1051997e..b134b0d4 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -31,6 +31,7 @@ #include "libcamera/internal/framebuffer.h" #include "libcamera/internal/media_device.h" #include "libcamera/internal/media_object.h" +#include "libcamera/internal/tracepoints.h" /** * \file v4l2_videodevice.h @@ -1706,6 +1707,7 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer) watchdog_.start(std::chrono::duration_cast(watchdogDuration_)); } + LIBCAMERA_TRACEPOINT(v4l2_videodev_add_buffer_to_queue, this, buffer); queuedBuffers_[buf.index] = buffer; return 0; @@ -1786,6 +1788,7 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer() cache_->put(buf.index); FrameBuffer *buffer = it->second; + LIBCAMERA_TRACEPOINT(v4l2_videodev_remove_buffer_from_queue, this, buffer); queuedBuffers_.erase(it); if (queuedBuffers_.empty()) { @@ -1930,6 +1933,9 @@ int V4L2VideoDevice::streamOn() */ int V4L2VideoDevice::streamOff() { + LIBCAMERA_TRACEPOINT(v4l2_videodev_streamoff, this, + static_cast(state_), queuedBuffers_.size()); + int ret; if (state_ != State::Streaming && queuedBuffers_.empty()) @@ -1954,6 +1960,9 @@ int V4L2VideoDevice::streamOff() cache_->put(it.first); metadata.status = FrameMetadata::FrameCancelled; + + LIBCAMERA_TRACEPOINT(v4l2_videodev_send_back_buffer, this, buffer, buffer->request()); + bufferReady.emit(buffer); }