From patchwork Sun Jan 15 21:15:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1726820 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=n/Ky52XW; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Nw7Hr0nhxz23fk for ; Mon, 16 Jan 2023 08:16:22 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 28DD085117; Sun, 15 Jan 2023 22:16:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="n/Ky52XW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B8243850D5; Sun, 15 Jan 2023 22:16:14 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 25D9C8547B for ; Sun, 15 Jan 2023 22:16:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd32.google.com with SMTP id p66so12867955iof.1 for ; Sun, 15 Jan 2023 13:16:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=bl0gsRDkElWfTRBovS+33ml9iNJGsXlBOMS92l9r6I4=; b=n/Ky52XWyS68fWrZcQBc3bizdbwOs/zZL8Ug2T3TM7Dlu7oR7FuFQewbkiC3PMoUgv 7NEFGlaNWJ1CfXQd8FI6m9A3drWoZpqmfLkgAuYVxaB9b5giN+3jXJ5pIFsxwmJKbGQM HauSXYIBFqgsiU01pP47Dau6A+YVTkseOvLXs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bl0gsRDkElWfTRBovS+33ml9iNJGsXlBOMS92l9r6I4=; b=Gszxb3Mj0VjEuBwb7v67uTaMRptf97wm4gwytscTIVq68D3MPZdhndl2tUnYFAmIP/ dcXJI3swDVX5/f1sZnXr6HuY0ninHEltjp40i7vT87EqFjzS7NePT4ZBJyl0VX2cyfvN bOAWteZParY4G9s3EICFCHGi6yMWQHMpGI1IGKNpHlEOpbQbZWGLIcV5YTvWAAWuyvuE DHEDMsYqWaYuIugW3DkTXy161U3/1oxsJ6BscD7hPHE+wqJj5zw/6Yxv6+EMLGHiJbkV jMnpGZ7m2uqoOb/mwoytyfZ9zRmlsF7SNR162b+rRng+dgf6a859mtln0QeX17qg0ZKi oapw== X-Gm-Message-State: AFqh2kojtb1WH5gjwuLce+/xXEfp1e5IHwdvw4QjQ6dKbPTF+ohJImbb QGsTGcb4dSwm4dZ4ivH1hWhUQESPGeYwPXyv X-Google-Smtp-Source: AMrXdXsXhKW2d0bAK2Xv2yIrN2x6yBhnefWzKV8nBa5hMwoVr3xo0Pgy7Z8z2XJZJ2pfJ6REmyfAFA== X-Received: by 2002:a05:6602:314e:b0:6bc:d712:c30f with SMTP id m14-20020a056602314e00b006bcd712c30fmr57682566ioy.6.1673817367653; Sun, 15 Jan 2023 13:16:07 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id j6-20020a6bf906000000b007046e9e138esm4329107iog.22.2023.01.15.13.16.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jan 2023 13:16:07 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Simon Glass , AKASHI Takahiro , Andrey Zhizhikin , Bin Meng , Dzmitry Sankouski , Harald Seiler , Heiko Thiery , Huang Jianan , Ilias Apalodimas , Joel Stanley , Kautuk Consul , Marek Vasut , Max Krummenacher , Michael Walle , Michal Simek , Michal Suchanek , Ovidiu Panait , =?utf-8?q?Pali_Roh=C3=A1r?= , Pavel Herrmann , Philippe Reynes , Rasmus Villemoes , Rick Chen , Roger Knecht , Samuel Holland , Stefan Roese , Sughosh Ganu Subject: [PATCH 00/24] trace: Update the trace feature to work with trace-cmd Date: Sun, 15 Jan 2023 14:15:37 -0700 Message-Id: <20230115211602.1127661-1-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Since U-Boot's tracing feature was originally written, quite a few changes have taken place in this domain. The original text format used by tracing is still emitted by Linux, but a new trace-cmd tool has invented a binary format which is now used by new tools, such as kernelshark. With recent distributions and the move to Python 3, the old pybootchart tool does not build or run. Unfortunately there is no 1:1 replacement for the features that were provided by pybootchart, or at least it is not obvious. Still, it makes sense to keep with the times. This series updates proftool to use the new binary format, adding support for function and funcgraph tracing, so that U-Boot's trace records can be examined by trace-cmd and kernelshark. This series also adds support for a flamegraph, which provides a visual way to see which functions are called a lot, as well as which ones consume the most time. Some minor updates to the trace implementation within U-Boot are included, to provide a little more information and to fix a few problems. No unit tests are provided by proftool, but a functional test ensures that sandbox can emit traces which can be processed by proftool, then parsed by trace-cmd and that the timing of the various formats looks consistent. Simon Glass (24): .gitignore: Ignore the moveconfig database sandbox: Expand the space for sandbox_vpl sandbox: Bring back setting mon_len in global_data dm: Allow serial output during the relocation process timer: Tidy up use of notrace time: Tidy up some unnecessary #ifdefs trace: Reduce the default for TRACE_EARLY_CALL_DEPTH_LIMIT abuf: Support use from tools trace: Update the file header trace: Reduce the number of function sites trace: Track the minimum stack depth trace: Show a few more stats about tracing trace: Correct the relocation handover with buffer overflow trace: Detect an infinite loop trace: Rename prof to trace and improve comments trace: Update proftool to use new binary format trace: Drop use of objsection trace: Use text_base from the trace header trace: Support output of funcgraph records trace: Support output of a flamegraph trace: Provide a flamegraph that uses timing Docker: Support trace-cmd trace: Add a test trace: Update documentation .azure-pipelines.yml | 8 + .gitattributes | 1 + .gitignore | 3 + .gitlab-ci.yml | 12 + arch/sandbox/dts/sandbox_vpl.dtsi | 4 +- common/board_f.c | 3 + common/board_r.c | 9 + doc/develop/pics/flamegraph.png | Bin 0 -> 48224 bytes doc/develop/pics/flamegraph_timing.png | Bin 0 -> 31305 bytes doc/develop/pics/flamegraph_zoom.png | Bin 0 -> 25465 bytes doc/develop/pics/kernelshark.png | Bin 0 -> 29617 bytes doc/develop/pics/kernelshark_fg.png | Bin 0 -> 28899 bytes doc/develop/trace.rst | 281 ++++- doc/usage/cmd/trace.rst | 163 +++ doc/usage/index.rst | 1 + drivers/core/device.c | 3 +- drivers/timer/timer-uclass.c | 2 +- include/timer.h | 13 +- include/trace.h | 18 +- lib/Kconfig | 2 +- lib/abuf.c | 21 +- lib/time.c | 14 +- lib/trace.c | 93 +- test/py/tests/test_trace.py | 304 +++++ tools/Makefile | 3 + tools/docker/Dockerfile | 16 + tools/proftool.c | 1598 ++++++++++++++++++++++-- 27 files changed, 2345 insertions(+), 227 deletions(-) create mode 100644 doc/develop/pics/flamegraph.png create mode 100644 doc/develop/pics/flamegraph_timing.png create mode 100644 doc/develop/pics/flamegraph_zoom.png create mode 100644 doc/develop/pics/kernelshark.png create mode 100644 doc/develop/pics/kernelshark_fg.png create mode 100644 doc/usage/cmd/trace.rst create mode 100644 test/py/tests/test_trace.py