From patchwork Wed May 19 04:15:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12266199 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_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 F0729C433ED for ; Wed, 19 May 2021 04:18:25 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 7C96D6112F for ; Wed, 19 May 2021 04:18:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C96D6112F 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=WjEH5LUy7YjPrWKETN+8TJeKh1vCxdPKPEtvVyDSO7E=; b=LobT3KjpQsTLWEG2J1O135rPU /r+8iVZATFlXtjbsok/jtZ1NG0rGZMlky++jVbxaX2wjX0dYxi2/jWWxaZsxoNucK/6vfpJwmPbSc ypkM3xeylFac4cjm/r63QH+PFT6fkUekttoCub1cP96xKGgU1OBR6p1ka5vWj9ewQY+9jPECOilyN Na27om5ap79WU3dl2AsiHupP9/k/Ru6Fr+wfdiNmsICrK3INvwsGgN6vV+1pICwVgX0q8LGXjYx/1 CcMRAp3PX9xdQNwz0ZiJWPR7mPxxYfNSDK98k37WJ0JJAokXeRmpvAe0ZOfV9S1FoRpdo4t/Mf1yb EylKSaoTg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ljDdJ-002hfj-4C; Wed, 19 May 2021 04:16:33 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljDct-002hbk-8n for linux-arm-kernel@desiato.infradead.org; Wed, 19 May 2021 04:16:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=mnv8F8uuj2iGeObVVsabQBsjZH5xCx4JzTz8peGn5X8=; b=EAc2/PusQ/e9C6G/JdRRBLKp3y J37rDmyDYIieaKHs0PZs999bZ4U7d/2IQl8QI5+tLQhIFsXBTNnPR8X0976Bi5qAggkS/GO2n9xCY NJKllKXuKs8IHnHvzb2AcSV02sVJd8ItIaU8eOmGkerBh8S/v/DxEz865HqQlmkXnVYXnCS+vgPpI bnudXFBqzgQfzv1s6WYgmGjWGtgX7hbhWpHkp/I+CFSJi8vJkhUETW/TnJWSOs0254QWdAK1Z6pwI 4eMORx3eszCfsKCA2yZC+MGnY3FrCNwaPH2sPaakIT8LT0TCk3WELfIoOKsgu1/08+fMbW3SL9+xf w4jFcsGQ==; Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljDcq-00F78g-Oh for linux-arm-kernel@lists.infradead.org; Wed, 19 May 2021 04:16:06 +0000 Received: by mail-pj1-x1035.google.com with SMTP id b15-20020a17090a550fb029015dad75163dso2753207pji.0 for ; Tue, 18 May 2021 21:16:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mnv8F8uuj2iGeObVVsabQBsjZH5xCx4JzTz8peGn5X8=; b=Y+RMOePPmr4kW5SydrzVYc81VRZiT9Pdaw7+lMi1c/3VQAJnwsVKJZ+Owg4oqkoImN VQ/xQHlYqld5wGmU3OvkCbAK6+LLB12H9EfoDb8qfgMLqCfFItZMQjUX1NhPRHHb0zg4 u3ALxImkgMy4kfxfidk4xgaKDK/53HBYifOz5BQMJZL75y1MJ+cFXmGu+VgTSMkvT274 64uQuhmXUWh9sb5p7LndkI/DAoEuUOfLL2At1xAMn88XQ/8H+jssdSXFofc3ef1vzkdb /tmX5nIfzFoAcKgfrMlZz2GElZHwA6QkrsYvzmUwL19070gJ+1AYJ+pfQbYkzz8Ped4B 98ZQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=mnv8F8uuj2iGeObVVsabQBsjZH5xCx4JzTz8peGn5X8=; b=TePmfyTyEEPifXY8Viowh73lMkQAvikEnYG77v4KPwEQ0MCM87G4i4k/7dm650EIrR 7iBFsrPlaIpdy0aYZM7CYPlA4BwcpAuskwsWTVeiRf2BzSXjbVEcv1HEto+bJq5IWrZB AXkzjTUrucJovL0INaZjY7VAmAD5f1txlq38UOxbYS/Ubmt/ImGv0PqstNZFUNM4rOZQ rDae0jD10riDIZ2+1r3Rre02YqMdBScerKYDPyc/qkmk/reWgQzSPumhsf63x3YzgZAL eJw+iWDYJ1teS33nky0UYCt61NZQNA3PAhwnX3qyOIkI+V1scmTn06pHNqNTOx54HeeX XO0g== X-Gm-Message-State: AOAM5325tyE3EtiMOJkuuEhmszkQup/4cGdtlRfNldqdz5BxJJeu8SJM Ma5PGemX5utUVgFXWAOe+GhMOw== X-Google-Smtp-Source: ABdhPJxqPnecAC2BAEyYAoyFzR9V9h/+elZ/KCxFqPwDX2Iiya4EEcsqoiloKy2Ce3eTob3HDqmniQ== X-Received: by 2002:a17:902:a58b:b029:ee:d13a:2642 with SMTP id az11-20020a170902a58bb02900eed13a2642mr8544241plb.35.1621397764039; Tue, 18 May 2021 21:16:04 -0700 (PDT) Received: from localhost ([103.207.71.35]) by smtp.gmail.com with ESMTPSA id n23sm811091pff.93.2021.05.18.21.16.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 21:16:03 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , John Garry , Will Deacon , Mathieu Poirier , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , James Clark , Al Grant , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v2 3/4] perf arm-spe: Enable timestamp for per-cpu mode Date: Wed, 19 May 2021 12:15:45 +0800 Message-Id: <20210519041546.1574961-4-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210519041546.1574961-1-leo.yan@linaro.org> References: <20210519041546.1574961-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210518_211604_823762_FF556FE9 X-CRM114-Status: GOOD ( 19.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org For per-cpu mmap, it should enable timestamp tracing for Arm SPE; this is helpful for samples correlation. To automatically enable the timestamp, a helper arm_spe_set_timestamp() is introduced for setting "ts_enable" format bit. Signed-off-by: Leo Yan Reviewed-by: James Clark Tested-by: James Clark --- tools/perf/arch/arm64/util/arm-spe.c | 33 ++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c index 4c916626c203..bacdf366040d 100644 --- a/tools/perf/arch/arm64/util/arm-spe.c +++ b/tools/perf/arch/arm64/util/arm-spe.c @@ -14,6 +14,7 @@ #include "../../../util/cpumap.h" #include "../../../util/event.h" #include "../../../util/evsel.h" +#include "../../../util/evsel_config.h" #include "../../../util/evlist.h" #include "../../../util/session.h" #include // page_size @@ -32,6 +33,29 @@ struct arm_spe_recording { struct evlist *evlist; }; +static void arm_spe_set_timestamp(struct auxtrace_record *itr, + struct evsel *evsel) +{ + struct arm_spe_recording *ptr; + struct perf_pmu *arm_spe_pmu; + struct evsel_config_term *term = evsel__get_config_term(evsel, CFG_CHG); + u64 user_bits = 0, bit; + + ptr = container_of(itr, struct arm_spe_recording, itr); + arm_spe_pmu = ptr->arm_spe_pmu; + + if (term) + user_bits = term->val.cfg_chg; + + bit = perf_pmu__format_bits(&arm_spe_pmu->format, "ts_enable"); + + /* Skip if user has set it */ + if (bit & user_bits) + return; + + evsel->core.attr.config |= bit; +} + static size_t arm_spe_info_priv_size(struct auxtrace_record *itr __maybe_unused, struct evlist *evlist __maybe_unused) @@ -121,9 +145,14 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, */ evlist__to_front(evlist, arm_spe_evsel); - /* In the case of per-cpu mmaps, sample CPU for AUX event. */ - if (!perf_cpu_map__empty(cpus)) + /* + * In the case of per-cpu mmaps, sample CPU for AUX event; + * also enable the timestamp tracing for samples correlation. + */ + if (!perf_cpu_map__empty(cpus)) { evsel__set_sample_bit(arm_spe_evsel, CPU); + arm_spe_set_timestamp(itr, arm_spe_evsel); + } /* Add dummy event to keep tracking */ err = parse_events(evlist, "dummy:u", NULL);