From 27c9d6eceb15b8a4e400fd2b053fb84d0db10da4 Mon Sep 17 00:00:00 2001 From: Paul Elder Date: Wed, 28 Oct 2020 19:10:27 +0900 Subject: libcamera: request: Add tracepoints Add and use tracepoints in Request. Requests are core to libcamera operation, thus detecting delays in their processing is important, and serves as a good usage example of tracepoints. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- .../libcamera/internal/tracepoints/buffer_enums.tp | 9 +++ include/libcamera/internal/tracepoints/meson.build | 8 +++ include/libcamera/internal/tracepoints/pipeline.tp | 25 ++++++++ include/libcamera/internal/tracepoints/request.tp | 68 ++++++++++++++++++++++ .../internal/tracepoints/request_enums.tp | 9 +++ src/libcamera/request.cpp | 11 ++++ 6 files changed, 130 insertions(+) create mode 100644 include/libcamera/internal/tracepoints/buffer_enums.tp create mode 100644 include/libcamera/internal/tracepoints/pipeline.tp create mode 100644 include/libcamera/internal/tracepoints/request.tp create mode 100644 include/libcamera/internal/tracepoints/request_enums.tp diff --git a/include/libcamera/internal/tracepoints/buffer_enums.tp b/include/libcamera/internal/tracepoints/buffer_enums.tp new file mode 100644 index 00000000..fdbea69a --- /dev/null +++ b/include/libcamera/internal/tracepoints/buffer_enums.tp @@ -0,0 +1,9 @@ +TRACEPOINT_ENUM( + libcamera, + buffer_status, + TP_ENUM_VALUES( + ctf_enum_value("FrameSuccess", 0) + ctf_enum_value("FrameError", 1) + ctf_enum_value("FrameCancelled", 2) + ) +) diff --git a/include/libcamera/internal/tracepoints/meson.build b/include/libcamera/internal/tracepoints/meson.build index 2dd6733e..d9b2fca5 100644 --- a/include/libcamera/internal/tracepoints/meson.build +++ b/include/libcamera/internal/tracepoints/meson.build @@ -1,4 +1,12 @@ # SPDX-License-Identifier: CC0-1.0 +# enum files must go first tracepoint_files = files([ + 'buffer_enums.tp', + 'request_enums.tp', +]) + +tracepoint_files += files([ + 'pipeline.tp', + 'request.tp', ]) diff --git a/include/libcamera/internal/tracepoints/pipeline.tp b/include/libcamera/internal/tracepoints/pipeline.tp new file mode 100644 index 00000000..c0a94635 --- /dev/null +++ b/include/libcamera/internal/tracepoints/pipeline.tp @@ -0,0 +1,25 @@ +TRACEPOINT_EVENT( + libcamera, + ipa_call_begin, + TP_ARGS( + const char *, pipe, + const char *, func + ), + TP_FIELDS( + ctf_string(pipeline_name, pipe) + ctf_string(function_name, func) + ) +) + +TRACEPOINT_EVENT( + libcamera, + ipa_call_end, + TP_ARGS( + const char *, pipe, + const char *, func + ), + TP_FIELDS( + ctf_string(pipeline_name, pipe) + ctf_string(function_name, func) + ) +) diff --git a/include/libcamera/internal/tracepoints/request.tp b/include/libcamera/internal/tracepoints/request.tp new file mode 100644 index 00000000..dd28a714 --- /dev/null +++ b/include/libcamera/internal/tracepoints/request.tp @@ -0,0 +1,68 @@ +#include +#include + +TRACEPOINT_EVENT_CLASS( + libcamera, + request, + TP_ARGS( + libcamera::Request *, req + ), + TP_FIELDS( + ctf_integer_hex(uintptr_t, request, reinterpret_cast(req)) + ctf_integer(uint64_t, cookie, req->cookie()) + ctf_enum(libcamera, request_status, uint32_t, status, req->status()) + ) +) + +TRACEPOINT_EVENT_INSTANCE( + libcamera, + request, + request_construct, + TP_ARGS( + libcamera::Request *, req + ) +) + +TRACEPOINT_EVENT_INSTANCE( + libcamera, + request, + request_destroy, + TP_ARGS( + libcamera::Request *, req + ) +) + +TRACEPOINT_EVENT_INSTANCE( + libcamera, + request, + request_reuse, + TP_ARGS( + libcamera::Request *, req + ) +) + +TRACEPOINT_EVENT_INSTANCE( + libcamera, + request, + request_complete, + TP_ARGS( + libcamera::Request *, req + ) +) + + +TRACEPOINT_EVENT( + libcamera, + request_complete_buffer, + TP_ARGS( + libcamera::Request *, req, + libcamera::FrameBuffer *, buf + ), + TP_FIELDS( + ctf_integer_hex(uintptr_t, request, reinterpret_cast(req)) + ctf_integer(uint64_t, cookie, req->cookie()) + ctf_integer(int, status, req->status()) + ctf_integer_hex(uintptr_t, buffer, reinterpret_cast(buf)) + ctf_enum(libcamera, buffer_status, uint32_t, buf_status, buf->metadata().status) + ) +) diff --git a/include/libcamera/internal/tracepoints/request_enums.tp b/include/libcamera/internal/tracepoints/request_enums.tp new file mode 100644 index 00000000..371f6544 --- /dev/null +++ b/include/libcamera/internal/tracepoints/request_enums.tp @@ -0,0 +1,9 @@ +TRACEPOINT_ENUM( + libcamera, + request_status, + TP_ENUM_VALUES( + ctf_enum_value("RequestPending", 0) + ctf_enum_value("RequestComplete", 1) + ctf_enum_value("RequestCancelled", 2) + ) +) diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp index ae8b1660..a68684ef 100644 --- a/src/libcamera/request.cpp +++ b/src/libcamera/request.cpp @@ -16,6 +16,7 @@ #include "libcamera/internal/camera_controls.h" #include "libcamera/internal/log.h" +#include "libcamera/internal/tracepoints.h" /** * \file request.h @@ -85,10 +86,14 @@ Request::Request(Camera *camera, uint64_t cookie) * \todo: Add a validator for metadata controls. */ metadata_ = new ControlList(controls::controls); + + LIBCAMERA_TRACEPOINT(request_construct, this); } Request::~Request() { + LIBCAMERA_TRACEPOINT(request_destroy, this); + delete metadata_; delete controls_; delete validator_; @@ -106,6 +111,8 @@ Request::~Request() */ void Request::reuse(ReuseFlag flags) { + LIBCAMERA_TRACEPOINT(request_reuse, this); + pending_.clear(); if (flags & ReuseBuffers) { for (auto pair : bufferMap_) { @@ -259,6 +266,8 @@ void Request::complete() LOG(Request, Debug) << "Request has completed - cookie: " << cookie_ << (cancelled_ ? " [Cancelled]" : ""); + + LIBCAMERA_TRACEPOINT(request_complete, this); } /** @@ -276,6 +285,8 @@ void Request::complete() */ bool Request::completeBuffer(FrameBuffer *buffer) { + LIBCAMERA_TRACEPOINT(request_complete_buffer, this, buffer); + int ret = pending_.erase(buffer); ASSERT(ret == 1); -- cgit v1.2.1