From patchwork Tue Feb 2 16:38:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12062245 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9981DC433E0 for ; Tue, 2 Feb 2021 16:40:29 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5305064F74 for ; Tue, 2 Feb 2021 16:40:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5305064F74 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=V0ltrpSPmo5xxtO6YxQerw+gnrK3m4cMfSyuXcrO/ys=; b=wZHrMpnKBj9/vdudfodl9eMnpD /Rzq7CHrcOoDx6rYdkOllD/svoHjgVlWZsLWQgywC5VC6Q3mBLs6UcKXyZwmfLehqWwZLritJc1IN ZGxlqX71RFnfrV/tA+PFMSfkKWoNFJy7HCs0WNfjcjwcQkapC8434NnSB9HZ04PV8dbi7vq/BWXfv zKPpV5LmGp6WQETgY5cZ85U3PX485BnahOx6VIHowCPXw09Opx8ac13yzsTyrh7XuJF7r5+yqkctW ZG5rB7FItIOrUyEzePcBS0P4InvL7jJe1Tw4VrcT+SuIPO50Nf09w1R8R1COgVh2XN0sef5FP2bHq 3fLhrWkw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6yhv-00067b-6c; Tue, 02 Feb 2021 16:39:15 +0000 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6yhr-00065f-P9 for linux-arm-kernel@lists.infradead.org; Tue, 02 Feb 2021 16:39:12 +0000 Received: by mail-pj1-x102b.google.com with SMTP id nm1so2602563pjb.3 for ; Tue, 02 Feb 2021 08:39:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=b38PbWWvjwCc9O3KDe7MyXUwafx01VvqV6s7ApqBfZE=; b=lLjL48NNB64cbd5J1UH6ZeGorOS5hhpQTI1NLBW0+P3g76xMFsc1j05rkEKOBoS8Hq lrR4bPXZg7i2smlnXKn8HEWUktTsiEBeaseEs3NCY51WVkRmehj81oFN8dmZzjRdMgYz n9rM42fgJZ1KNq6wMk48SpPDe/M+hgeri7Y3xwAqBpyxStwh5EWnZKp+MHSTRqA5Ez45 In3CpsIOeCEJktQNKQkmlKo0drScwqMeu2UZ1cXRROWHMHmDOmUzRKcKo7zAP6CEWDHX wU3q6EBru+nIyhLmMIkVevIxNeXn15U2oZRupo6BTRmdR6l8WOvMRMsV2igRbvDoYVL3 XY1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=b38PbWWvjwCc9O3KDe7MyXUwafx01VvqV6s7ApqBfZE=; b=uAxwbFySaRNDw1UdyOHWMEDydtbEKYwjZLF9WaW7mQrTrfuag4zpoTY5Dy3cTzm2hv W191xDxEWQ2h6e8pOu02zsg0xy6kFahAm8VtP01LwMMNoHr0wgn1sXwQtyVjEnFqDdc1 xb3hCtQcrj/m1v2exkEjNhp0WvMVGCMUGfEQdBHU2BtoUY9nmHfDjHPIiBzudmBrITrP ahXPn5Pa8VsvPHhqbRb/HagCxUWr1Vpb0Fa8LsETxIMc4lOd1ADFoIPAjtNwHP1E1Gw0 R9cjebf3iPIP7DK8FjjO1OUO+xbNpfyD+pKwjlFyVoCj0UW1X4hmrCgAjLQ0euTTPq4T Y4eA== X-Gm-Message-State: AOAM531SWLClwNEm1nCTZ+HtxaMSTy8weWiDoaIxme7XJcUJqwJJytw9 hUA3RhsZ2f48x6Qp5SJO/wdQEQ== X-Google-Smtp-Source: ABdhPJyApfVZVPwqNrXCIgoJkQE38h+AcTZF+1Djd9izwDK38OVIuW5iXk+ElSIbckm88jMTNKBczg== X-Received: by 2002:a17:90b:949:: with SMTP id dw9mr5538261pjb.20.1612283946762; Tue, 02 Feb 2021 08:39:06 -0800 (PST) Received: from localhost ([45.137.216.202]) by smtp.gmail.com with ESMTPSA id ds10sm3326998pjb.1.2021.02.02.08.39.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 08:39:06 -0800 (PST) From: Leo Yan To: Arnaldo Carvalho de Melo , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Jonathan Corbet , Alexander Shishkin , John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , Namhyung Kim , Daniel Kiss , Denis Nikitin , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 0/7] coresight: etm-perf: Fix pid tracing with VHE Date: Wed, 3 Feb 2021 00:38:35 +0800 Message-Id: <20210202163842.134734-1-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210202_113911_830564_E58EC8B0 X-CRM114-Status: GOOD ( 22.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Leo Yan Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch series is to support PID tracing with Virtualization Host Extensions (VHE). Since the patch series v1 was sent out for reviewing, we had some discussion and finalized the solution which is implemented in this version. Simply to say, to be backward compatibility, and can both support PID tracing for the kernel is running at either EL1 or EL2, the two new PMU formats "contextid1" and "contextid2" are introduced, which works as a switch to trace PID for EL1 kernel and EL2 kernel respectively. The existed PMU format "contextid" needs to be backward compatible for users, it's changed to an alias for "contextid1" on EL1 kernel and for "contextid2" on EL2 kernel. Therefore, even without setting "contextid" config, the perf tool can dynamically pick up the config for PID tracing, so the user doesn't have to set the "contexid" config manually. As results, we now have three PMU formats, for easier understanding the implementation, just copy and paste the descriptions for these three PMU formats from the patch 07/07: "contextid1": Available on both EL1 kernel and EL2 kernel. When the kernel is running at EL1, "contextid1" enables the PID tracing; when the kernel is running at EL2, this enables tracing the PID of guest applications. "contextid2": Only usable when the kernel is running at EL2. When selected, enables PID tracing on EL2 kernel. "contextid": Will be an alias for the option that enables PID tracing. I.e, contextid == contextid1, on EL1 kernel. contextid == contextid2, on EL2 kernel. This patch series can be cleanly applied on perf/core branch: commit cd07e536b020 ("Merge remote-tracking branch 'torvalds/master' into perf/core") ... and applied on the mainline kernel: commit 88bb507a74ea ("Merge tag 'media/v5.11-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media") The patch series has been tested on Arm Juno-r2 board. Verified the kernel with EL1 and didn't find issue; though absenting the platform for kernel with EL2, after some hacking in kernel driver and tool to emulate the code paths for kernel on EL2, can see the code path is hit without failure. Changes from v1: * Refactored PMU formats, added formats "contextid1"/"contextid2", and reworked format "contextid" (Suzuki/Mathieu); * Refined the comments for perf configs (Leo/Mike); * Added patch 07/07 for description PID tracing in docs; * Found the issue for bitmap for option, extracted patch 03/07 for the fixing. Changes from RFC: * Added comments to clarify cases requested (Leo); * Explain the change to generic flags for cs_etm_set_option() in the commit description; * Stored PID format in metadata and passed it to decoder (Leo); * Enhanced cs-etm for backward compatibility (Denis Nikitin). Leo Yan (3): coresight: etm-perf: Clarify comment on perf options perf cs-etm: Add helper cs_etm__get_pid_fmt() Documentation: coresight: Add PID tracing description Suzuki K Poulose (4): coresight: etm-perf: Support PID tracing for kernel at EL2 perf cs-etm: Fix bitmap for option perf cs-etm: Support PID tracing in config perf cs-etm: Detect pid in VMID for kernel running at EL2 Documentation/trace/coresight/coresight.rst | 37 ++++++++++ .../hwtracing/coresight/coresight-etm-perf.c | 32 +++++++- .../coresight/coresight-etm4x-core.c | 13 ++++ include/linux/coresight-pmu.h | 20 +++-- tools/include/linux/coresight-pmu.h | 20 +++-- tools/perf/arch/arm/util/cs-etm.c | 73 +++++++++++++++---- .../perf/util/cs-etm-decoder/cs-etm-decoder.c | 32 +++++++- tools/perf/util/cs-etm.c | 43 +++++++++++ tools/perf/util/cs-etm.h | 1 + 9 files changed, 239 insertions(+), 32 deletions(-)