From patchwork Sat Apr 3 07:23:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12181829 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=-13.9 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, UNWANTED_LANGUAGE_BODY,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 E3045C433ED for ; Sat, 3 Apr 2021 07:26:14 +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 6B60961206 for ; Sat, 3 Apr 2021 07:26:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B60961206 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=J+WBj1CAARZBiSeyFg33uaE+IEaYkChvk6VePfODyRY=; b=I/dFTLUkF4J5Aw8vxQ15ZndVZ n8VAfds6CTEHwBuiK/o60lFoXrnwEmsaWgNjFUh48RJhBrDtOGzrWtKey6djCZci6lrHOl3GrvNzw 2ZEw7Y1KXDw6c59nuzR8FInDXS/r/bu8+TnuNeRnrGbN1R1tenKYAFaD3Y91JSUFp/rNb5BKCauIC fKbCVVFhLimZy1cjqwsbhjg5H+GUr0n272JBQCJ0s0Jxa0bT2H0L6/0OXjhzP5cg3l+tpmwwf9sfh khqzLoC3g72+dDl9NK/GS1qXxi6nwUbaoidDzdUlZDQ7RqM75IumD7iXCJDxQzo9ju2ijyMyDdQuW JM0WPKCsg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lSadm-00EPLn-QM; Sat, 03 Apr 2021 07:24:19 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lSadW-00EPGl-Ft for linux-arm-kernel@lists.infradead.org; Sat, 03 Apr 2021 07:24:04 +0000 Received: by mail-pj1-x1032.google.com with SMTP id w8so3647632pjf.4 for ; Sat, 03 Apr 2021 00:24:02 -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=KJK8dZgEf3LiQZYSvERG5S+Cf6jpruVmV7G871UJxKw=; b=kZLfyEe5T8/wnO8BEbhuFtnTsyTc/C8sYJVZwBAi1A/HGl92g87YQ1C9Su4O0ruBCG rinlZfXPhRugDJzWwjQr068t3E0i3vSoExW770aLNZDAUFFByf/nVM3VkcW2lYmZJhUh K6o/R2OvbNqIVAnf5wnIEgo6OWNG6FJNnzjoHhE6AYXV8EXBzNpYrMN9A0gLGyvmUuOl 12QgolaRdDnxtr2T2SXnXJe9z7p0v2NFE8X7iJQ7yfnKFv4r7NPFtCepHmkpidsFhTii d4dp6Fj4IvtfsC3fdAfRn+9NwaKZNp48YIo8uD/DcPlWvtfP+E3PWF2nUmt/SQ0+NP4r 9SxA== 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=KJK8dZgEf3LiQZYSvERG5S+Cf6jpruVmV7G871UJxKw=; b=t9uO4JJyhwg8+BI26fhGfogI4vQhrVdifVHx7r9zXaix6tNP9MKUR0a1hajfUwIFNi LOoODKTvIPSA6LNRS9BK9UkxLbL2XlGf2BH7Sy5iJd3QWNNSM3HciIaj0ffA33d3uwMr w3JTggGewXrWRrvxM7R4NRicG32vd2+Pak/VOnCXCEuZwrCFvMK/Gb8gwuC3b1gaAV3X w8ESUBjj7Wmj49EP+akZvP9wKk5n2tSKxkrl+yo1mP0+LSWcAS4ndsTa5d+jz7qRWx2/ Rzk6lE0drNiP0NnXHFgMcKt4fDxyY/PrWEh57uCCgVS36g+joxF19qQmx4NWYTi0n3JR zH1Q== X-Gm-Message-State: AOAM532ra60UyYS9VA613EIGn/ki4APMu9EWxKS/4hRfJJ71uNwDpIpG BwF4S8hIrn8lFVtoLLwC4zYb0A== X-Google-Smtp-Source: ABdhPJxYJx6Wa94k81HS7tqgo1m6KoH0q4eesEXFtdU6WZbMujxG6jDxFlKdkYfyee3d0Z9yXBc48Q== X-Received: by 2002:a17:90a:5d09:: with SMTP id s9mr17009472pji.228.1617434641111; Sat, 03 Apr 2021 00:24:01 -0700 (PDT) Received: from localhost ([116.206.101.232]) by smtp.gmail.com with ESMTPSA id w203sm9704435pfc.188.2021.04.03.00.24.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Apr 2021 00:24:00 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , John Garry , Will Deacon , Mathieu Poirier , James Clark , Al Grant , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v2 2/7] perf arm-spe: Store TSC parameters in auxtrace info Date: Sat, 3 Apr 2021 15:23:41 +0800 Message-Id: <20210403072346.30430-3-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210403072346.30430-1-leo.yan@linaro.org> References: <20210403072346.30430-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-20210403_082402_580819_A4DED3F0 X-CRM114-Status: GOOD ( 16.37 ) 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 The TSC parameters are used for conversion between arch timer counter and kernel timestamp, this patch stores the parameters into the struct perf_record_auxtrace_info, and it is saved in perf data file. Signed-off-by: Leo Yan --- tools/perf/arch/arm64/util/arm-spe.c | 23 +++++++++++++++++++++++ tools/perf/util/arm-spe.h | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c index 414c8a5584b1..dd940cf16f49 100644 --- a/tools/perf/arch/arm64/util/arm-spe.c +++ b/tools/perf/arch/arm64/util/arm-spe.c @@ -15,7 +15,9 @@ #include "../../../util/event.h" #include "../../../util/evsel.h" #include "../../../util/evlist.h" +#include "../../../util/mmap.h" #include "../../../util/session.h" +#include "../../../util/tsc.h" #include // page_size #include "../../../util/pmu.h" #include "../../../util/debug.h" @@ -47,6 +49,9 @@ static int arm_spe_info_fill(struct auxtrace_record *itr, struct arm_spe_recording *sper = container_of(itr, struct arm_spe_recording, itr); struct perf_pmu *arm_spe_pmu = sper->arm_spe_pmu; + struct perf_event_mmap_page *pc; + struct perf_tsc_conversion tc = { .time_mult = 0, }; + int err; if (priv_size != ARM_SPE_AUXTRACE_PRIV_SIZE) return -EINVAL; @@ -54,8 +59,26 @@ static int arm_spe_info_fill(struct auxtrace_record *itr, if (!session->evlist->core.nr_mmaps) return -EINVAL; + pc = session->evlist->mmap[0].core.base; + if (pc) { + err = perf_read_tsc_conversion(pc, &tc); + if (err) { + if (err != -EOPNOTSUPP) + return err; + } + + if (!tc.time_mult) + ui__warning("Arm SPE: arch timer not available\n"); + } + auxtrace_info->type = PERF_AUXTRACE_ARM_SPE; auxtrace_info->priv[ARM_SPE_PMU_TYPE] = arm_spe_pmu->type; + auxtrace_info->priv[ARM_SPE_TIME_SHIFT] = tc.time_shift; + auxtrace_info->priv[ARM_SPE_TIME_MULT] = tc.time_mult; + auxtrace_info->priv[ARM_SPE_TIME_ZERO] = tc.time_zero; + auxtrace_info->priv[ARM_SPE_TIME_CYCLES] = tc.time_cycles; + auxtrace_info->priv[ARM_SPE_TIME_MASK] = tc.time_mask; + auxtrace_info->priv[ARM_SPE_CAP_USER_TIME_SHORT] = tc.cap_user_time_short; return 0; } diff --git a/tools/perf/util/arm-spe.h b/tools/perf/util/arm-spe.h index 105ce0ea0a01..5bf3e838d226 100644 --- a/tools/perf/util/arm-spe.h +++ b/tools/perf/util/arm-spe.h @@ -11,6 +11,12 @@ enum { ARM_SPE_PMU_TYPE, + ARM_SPE_TIME_SHIFT, + ARM_SPE_TIME_MULT, + ARM_SPE_TIME_ZERO, + ARM_SPE_TIME_CYCLES, + ARM_SPE_TIME_MASK, + ARM_SPE_CAP_USER_TIME_SHORT, ARM_SPE_AUXTRACE_PRIV_MAX, };