Received: by 10.223.185.116 with SMTP id b49csp556458wrg; Wed, 14 Feb 2018 03:26:40 -0800 (PST) X-Google-Smtp-Source: AH8x224jaqEQE1Ph9udGDkWVa32vaAtCIVXz9R2N22HqJZbXmg+t1g+8PsB/VR1Kp95ct/7m1Num X-Received: by 10.99.186.73 with SMTP id l9mr3573038pgu.83.1518607599951; Wed, 14 Feb 2018 03:26:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518607599; cv=none; d=google.com; s=arc-20160816; b=PLqoaT6oBO3wGKuWkz/RZ2vY6M2OW/arGrp/msvCO0u4d/ilh79+vEkaTSWWDdg3Ea wBmO8Vepc+AL7H0h65eVqGEsj1xBYKWERc+H5Uk6Z8CFDnDLn+4Pq9aamk6M0cDFxyPu cEWmkzU7VTrNqNRfKYdeyxA2Hn2HBwGPNdMHP4/MYTL7QcTaPJEmmus97u/uWwgVUlq7 aT22Fp8LZ/dm9TlIQT71ncvUwKWXTL4XfVLyO1F3IlFJUS/CNjjlcFrZ2UxgezJMlTz6 0obkpcKmfX7Thi1P2ggjb8nfJ5ojp+lPDOw+fu00jWqd1iW42yW8oXRilVtttwUDID/8 Ar2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=KziACELH81qn26Bx6F0Q9Zfr/YkL4qjqf/LbbB2zg94=; b=o46PhVFLEUfTAqD2MJUjrcln2IS4tlnF+lO0epqUwME32f8zwjAZm2/u0ebKnhqpgW /Tp0LskbkhC4LTf2YhwXHcyMvJdwgI5rflXCmFw+mY1qdI/MSye+91Im9aJiqVhfjQbj UyPNl9qef2ZDjq/qxmgqeZmDIv2inJIrhn76cIC3G89O5G2VqcMO4KiECGDOkee7Go1F BYF/u6+7NJUuWIL+1iGY+WKkBLdCVH4njjqkTv6qhoVEBQ2IDJIIioOuQgc8omWp2T6V fM76VqGaaCpZHQ9Rqs0Y5+tYioe5Fc+Us9fqApDWjGBJuWJ5xPXq+4ECrzi7YA8t1SSi mD6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y6si7864887pgc.112.2018.02.14.03.26.25; Wed, 14 Feb 2018 03:26:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967440AbeBNLZh (ORCPT + 99 others); Wed, 14 Feb 2018 06:25:37 -0500 Received: from foss.arm.com ([217.140.101.70]:40880 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967392AbeBNLZN (ORCPT ); Wed, 14 Feb 2018 06:25:13 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 879CE164F; Wed, 14 Feb 2018 03:25:13 -0800 (PST) Received: from e111474-lin.blackburn.arm.com (e111474-lin.blackburn.arm.com [10.33.1.161]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2B6003F487; Wed, 14 Feb 2018 03:25:12 -0800 (PST) From: Robert Walker To: acme@kernel.org, Mathieu Poirier , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Robert Walker , coresight@lists.linaro.org Subject: [PATCH v2 3/3] coresight: Update documentation for perf usage Date: Wed, 14 Feb 2018 11:24:41 +0000 Message-Id: <1518607481-4059-4-git-send-email-robert.walker@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518607481-4059-1-git-send-email-robert.walker@arm.com> References: <1518607481-4059-1-git-send-email-robert.walker@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add notes on using perf to collect and analyze CoreSight trace Signed-off-by: Robert Walker --- Documentation/trace/coresight.txt | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/Documentation/trace/coresight.txt b/Documentation/trace/coresight.txt index a33c88c..eb5d1e4 100644 --- a/Documentation/trace/coresight.txt +++ b/Documentation/trace/coresight.txt @@ -330,3 +330,54 @@ Details on how to use the generic STM API can be found here [2]. [1]. Documentation/ABI/testing/sysfs-bus-coresight-devices-stm [2]. Documentation/trace/stm.txt + + +Using perf tools +---------------- + +perf can be used to record and analyze trace of programs. + +Execution can be recorded using perf record with the cs_etm event, +specifying the name of the sink to record to, e.g: + + perf record -e cs_etm/@20070000.etr/u --per-thread + +The perf report and script commands can be used to analyze execution, +synthesizing instruction and branch events from the instruction trace. perf +inject can be used to replace the trace data with the synthesized events. +The --itrace option controls the type and frequency of synthesized events +(see perf documentation). + +Note that only 64-bit programs are currently supported - further work is +required to support instruction decode of 32-bit Arm programs. + + +Generating coverage files for Feedback Directed Optimization: AutoFDO +--------------------------------------------------------------------- + +perf inject accepts the --itrace option in which case tracing data is +removed and replaced with the synthesized events. e.g. + + perf inject --itrace --strip -i perf.data -o perf.data.new + +Below is an example of using ARM ETM for autoFDO. It requires autofdo +(https://github.com/google/autofdo) and gcc version 5. The bubble +sort example is from the AutoFDO tutorial (https://gcc.gnu.org/wiki/AutoFDO/Tutorial). + + $ gcc-5 -O3 sort.c -o sort + $ taskset -c 2 ./sort + Bubble sorting array of 30000 elements + 5910 ms + + $ perf record -e cs_etm/@20070000.etr/u --per-thread taskset -c 2 ./sort + Bubble sorting array of 30000 elements + 12543 ms + [ perf record: Woken up 35 times to write data ] + [ perf record: Captured and wrote 69.640 MB perf.data ] + + $ perf inject -i perf.data -o inj.data --itrace=il64 --strip + $ create_gcov --binary=./sort --profile=inj.data --gcov=sort.gcov -gcov_version=1 + $ gcc-5 -O3 -fauto-profile=sort.gcov sort.c -o sort_autofdo + $ taskset -c 2 ./sort_autofdo + Bubble sorting array of 30000 elements + 5806 ms -- 2.7.4