From patchwork Mon Apr 12 09:10:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12197315 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=-16.8 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,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 D8D2DC433B4 for ; Mon, 12 Apr 2021 09:12: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 53E5661207 for ; Mon, 12 Apr 2021 09:12:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 53E5661207 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=X1bXyYqNtUun3n1QwFC9PTzefnFWR3FijjdaW9VVKEI=; b=c1+7HDavsHvdZVU90rHh4CcC/ 1J5SB+ir6Cdd1CcLYI1to8RRmmRlshMz8ad3xF5TDnmcTNT9CIK9zppdWsy/XRwT96/Od6ll4M0KI jmm6U3YlsVIAg/7mIl61q4ehXEQILwX59eqhR63I7P3ZG3pzsf7nr5XJQg00sZA0Gl3+DIZwRuqsw f5d1e4N0IlIT5xGQej5IyUvgRuLfCVx17bzZMsaCyCMbUE1FCKl8J1B+vnQyHS2xYOKnJllwWhIOv Hv6BzQLrdtoPgtnFiTgGIduMJ7guiH5yj2Yqzh+N28VSSBBNsI2Js+dfDBPCwESGT6A3IimPN0TMd CAlFTW+cw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lVsas-006Dfl-7K; Mon, 12 Apr 2021 09:10:54 +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 1lVsaU-006Dch-Sj for linux-arm-kernel@desiato.infradead.org; Mon, 12 Apr 2021 09:10:31 +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=b2AJdiv36eBYj95RGDnrJVH8a4LrKTTY6S8FUinX/Ek=; b=I8ipg3iHuALQqjtSDFcS8qS95K Gi5cfpToVAqKX1sP3Zx0s5Dej6aswme2NuP7cdW3MO/ZcuUb+AwXJ9HZFzqB1HnXe/UH3bfFUz7l2 nq+QCkn6bYXZgPGcB7kGHKuSMFoUP89dJaSYJhVUstNWEFUhduoLne8GKPTOgonU86GOWiyYA4PjB Uku4C9a59VHloei8ur/y7RpI+fDwB2Zi/MBJHQKTwj3FDVkTOneoCMkgHmT6+Z+FwEr1EBPPbYtoj obNZuob6XSgOGO7DDT0/UJzQyqe9FZQCQ1O9HXZbC9kLQlmxDZM6UeUOP3dqD4QTc8SN6dFVoXU5v HwrKq7hw==; Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVsaS-0061wS-Ab for linux-arm-kernel@lists.infradead.org; Mon, 12 Apr 2021 09:10:29 +0000 Received: by mail-pg1-x52f.google.com with SMTP id k8so8883508pgf.4 for ; Mon, 12 Apr 2021 02:10:28 -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=b2AJdiv36eBYj95RGDnrJVH8a4LrKTTY6S8FUinX/Ek=; b=Td9+tp0wklJ8cJy3VNdoI8FvHbgafWiNNYrFEuuLLkAIg8DmNuruHKMheCyYiP7NtQ 4IodPCkBl4C4hW+2nDcJNoTyKY1Rpek5iMB3nosruXirr7BSlE8an9jHytAU9gt42kIK vP969yuqrr1mybkcxBHVcETAw7dI2BU7BVtBjIeIY7xvGSYYEgv6ya0enzSCaDPsWR+u Xl0By+qUPeIRymThbK0s57f32ykZx3NI0gulVX3FeCmf2CUcxLRJr4mFtRjXcqqUXM8n y+W7VBGWQTaHr3DnZcRzM3PrUlfec9foWhTr6gTryRaKFA7JYk3wzOJKYaWrkTIyt0Ts TooQ== 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=b2AJdiv36eBYj95RGDnrJVH8a4LrKTTY6S8FUinX/Ek=; b=bNPQbb8aS+dRk2Qf3A/lE53FRgdJErCfmff/zW2HHXod1EbZcBytiRI+yAKhZPEseq He+IxzY2xwb8TDFNdag3Q6pn3dD+OlkDa/6BGEpTWep/CkRCtSRBvmq5/W1S1Ch70gHd hXNb9ae4ZaeG3zR9LK9RmSE2iNUSi+sIRbQGM1rG3OjpMRRqvj7o3uuaYvsu/tyvLn1v luGTMK2GFqHF2j8HSLMsey8oIdbLQff3+GmjH0Pq7A/Hk0Kgr8rYhDAG6zoOArJKeVuD dseIbHC6D2smU/KShg1Hc2ICpuuSjC8KFmh1gy81jhXHpExhMjCT3R2sHfQo7Owi2JZ+ M7MA== X-Gm-Message-State: AOAM5330EoXXFlhr6vDEdnd4W999lF3gnsYSPDtUsFb5nJCLJoNzLrCZ h5d7Olkdwgj1RrcVGEKZQmcWdg== X-Google-Smtp-Source: ABdhPJziG0wwEPvJ8tGBnqDJmL17LQRkS6qICH0szLW3oAIHOgvlzefrtdZ00/ZP9HzlFDN6F2KYbQ== X-Received: by 2002:a63:d61:: with SMTP id 33mr26266191pgn.201.1618218627554; Mon, 12 Apr 2021 02:10:27 -0700 (PDT) Received: from localhost ([116.206.101.232]) by smtp.gmail.com with ESMTPSA id t1sm1164493pjo.33.2021.04.12.02.10.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 02:10:27 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Al Grant , John Garry , Will Deacon , Mathieu Poirier , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Dave Martin , James Clark , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v4 2/6] perf arm-spe: Save clock parameters from TIME_CONV event Date: Mon, 12 Apr 2021 17:10:02 +0800 Message-Id: <20210412091006.468557-3-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210412091006.468557-1-leo.yan@linaro.org> References: <20210412091006.468557-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-20210412_021028_390643_AB393796 X-CRM114-Status: GOOD ( 18.66 ) 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 During the recording phase, "perf record" tool synthesizes event PERF_RECORD_TIME_CONV for the hardware clock parameters and saves the event into the data file. Afterwards, when processing the data file, the event TIME_CONV will be processed at the very early time and is stored into session context. This patch extracts these parameters from the session context and saves into the structure "spe->tc" with the type perf_tsc_conversion, so that the parameters are ready for conversion between clock counter and time stamp. Signed-off-by: Leo Yan --- tools/perf/util/arm-spe.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 2539d4baec44..7620dcc45940 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -26,6 +26,7 @@ #include "symbol.h" #include "thread.h" #include "thread-stack.h" +#include "tsc.h" #include "tool.h" #include "util/synthetic-events.h" @@ -45,6 +46,8 @@ struct arm_spe { struct machine *machine; u32 pmu_type; + struct perf_tsc_conversion tc; + u8 timeless_decoding; u8 data_queued; @@ -1006,6 +1009,7 @@ int arm_spe_process_auxtrace_info(union perf_event *event, { struct perf_record_auxtrace_info *auxtrace_info = &event->auxtrace_info; size_t min_sz = sizeof(u64) * ARM_SPE_AUXTRACE_PRIV_MAX; + struct perf_record_time_conv *tc = &session->time_conv; struct arm_spe *spe; int err; @@ -1027,6 +1031,29 @@ int arm_spe_process_auxtrace_info(union perf_event *event, spe->pmu_type = auxtrace_info->priv[ARM_SPE_PMU_TYPE]; spe->timeless_decoding = arm_spe__is_timeless_decoding(spe); + + /* + * The synthesized event PERF_RECORD_TIME_CONV has been handled ahead + * and the parameters for hardware clock are stored in the session + * context. Passes these parameters to the struct perf_tsc_conversion + * in "spe->tc", which is used for later conversion between clock + * counter and timestamp. + * + * For backward compatibility, checks the event size and save extended + * fields staring from "time_cycles" if these fields are contained in + * the event. + */ + spe->tc.time_shift = tc->time_shift; + spe->tc.time_mult = tc->time_mult; + spe->tc.time_zero = tc->time_zero; + + if (tc->header.size > ((void *)&tc->time_cycles - (void *)tc)) { + spe->tc.time_cycles = tc->time_cycles; + spe->tc.time_mask = tc->time_mask; + spe->tc.cap_user_time_zero = tc->cap_user_time_zero; + spe->tc.cap_user_time_short = tc->cap_user_time_short; + } + spe->auxtrace.process_event = arm_spe_process_event; spe->auxtrace.process_auxtrace_event = arm_spe_process_auxtrace_event; spe->auxtrace.flush_events = arm_spe_flush;