From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5115EC433F5 for ; Wed, 13 Apr 2022 07:51:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233502AbiDMHyK (ORCPT ); Wed, 13 Apr 2022 03:54:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233491AbiDMHyG (ORCPT ); Wed, 13 Apr 2022 03:54:06 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E767035ABF for ; Wed, 13 Apr 2022 00:51:45 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id c64so1316190edf.11 for ; Wed, 13 Apr 2022 00:51:45 -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:mime-version :content-transfer-encoding; bh=/lSayVPsdaIcAWY+f+5xyOZsGygWFB8bqZXV5zFL3Io=; b=y4XcoZfN/r7PCh4ltBhjmsoiZHDaSBYRYuN+dYYTnz0dfhgPUQ6RFeudoMmeZ6syBv moC6eYs1Xvff4ljD3tJdk7b82FscaAImj+DC/EbR+oa0yOEY1sTppOIuLg/yAGfJEeWc LqUFgrfcdPRGvdEZdn5+vwaU91NwW4YUIVFyccZUyoPk7gOfbS01o6Ggj9DIH+qNcaKR 4C8t/s6/aEl/lldPy6kkhUcU0v0xrlP6EOH1xfIBgOfthRfPmUmZml1G5MCVogls5vbF Whyac6B+ZFXjsLP0kxTrpnSjZF0dIDhEmRxSuE8l7/RvLtSKgVrzLPW0TOGMVAJoVxtL JTLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/lSayVPsdaIcAWY+f+5xyOZsGygWFB8bqZXV5zFL3Io=; b=hSkk0Xlqg3EHC0Tx0uTrxJTJQmHpC7H02ic87OlWnQXT/XRDo9xj3TIn3CJmJZIam+ uDSRfP87s+NsSsaV/M9TQekqcgZdYa/tLQa7eYAkLaQ+hHJ5/j1Tun3bUrBCictDygYd 8REnJf39HfWKP6D+9pcaR8rbFSk2yufZqXC89bJ/BiGoByutIvcEuraSQzMW9nj1NX40 9InyjQkESoApJMPlwCVSJ8tBISosj10M0rjo/eSFoD18UZNzCDWFlBe8KNhbhQPc4VMX Rh1vzPAWc391vKUUmMzpuacVlQlvY249dKpU1mTiK5tDGWwAA9m9nYKnU3uJLMkliBuh /paA== X-Gm-Message-State: AOAM530307+XQtOfFX0kASIdQyUK1yVhBo5+DnJqaIgVwXZYMAwXNsKf Yp29/w8+y5Ct73JjUHs2uoxyrQ== X-Google-Smtp-Source: ABdhPJz3nSRQgubW9eqDEo2Z4fWQix1t+Kq8Ei7ICr3dHau8fFoHwd0FdbdWKbEFa8TDDwFnCJL/1g== X-Received: by 2002:a05:6402:e96:b0:41d:1a0f:e70a with SMTP id h22-20020a0564020e9600b0041d1a0fe70amr27233192eda.411.1649836304304; Wed, 13 Apr 2022 00:51:44 -0700 (PDT) Received: from localhost.localdomain (111-250-44-108.dynamic-ip.hinet.net. [111.250.44.108]) by smtp.gmail.com with ESMTPSA id t14-20020a170906608e00b006d1455acc62sm14035390ejj.74.2022.04.13.00.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Apr 2022 00:51:43 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ravi Bangoria , James Clark , German Gomez , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH] perf report: Set PERF_SAMPLE_DATA_SRC bit for Arm SPE event Date: Wed, 13 Apr 2022 15:51:24 +0800 Message-Id: <20220413075124.635589-1-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since commit bb30acae4c4d ("perf report: Bail out --mem-mode if mem info is not available") "perf mem report" and "perf report --mem-mode" don't report result if the PERF_SAMPLE_DATA_SRC bit is missed in sample type. The commit ffab48705205 ("perf: arm-spe: Fix perf report --mem-mode") partially fixes the issue. It adds PERF_SAMPLE_DATA_SRC bit for Arm SPE event, this allows the perf data file generated by kernel v5.18-rc1 or later version can be reported properly. On the other hand, perf tool still fails to be backward compatibility for a data file recorded by an older version's perf which contains Arm SPE trace data. This patch is a workaround in reporting phase, when detects ARM SPE PMU event and without PERF_SAMPLE_DATA_SRC bit, it will force to set the bit in the sample type and give a warning info. Fixes: bb30acae4c4d ("perf report: Bail out --mem-mode if mem info is not available") Signed-off-by: Leo Yan --- tools/perf/builtin-report.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 1ad75c7ba074..f26dd14eb852 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -353,6 +353,7 @@ static int report__setup_sample_type(struct report *rep) struct perf_session *session = rep->session; u64 sample_type = evlist__combined_sample_type(session->evlist); bool is_pipe = perf_data__is_pipe(session->data); + struct evsel *evsel; if (session->itrace_synth_opts->callchain || session->itrace_synth_opts->add_callchain || @@ -407,6 +408,21 @@ static int report__setup_sample_type(struct report *rep) } if (sort__mode == SORT_MODE__MEMORY) { + /* + * FIXUP: prior to kernel 5.18, Arm SPE missed to set + * PERF_SAMPLE_DATA_SRC bit in sample type. For backward + * compatibility, set the bit if it's an old perf data file. + */ + evlist__for_each_entry(session->evlist, evsel) { + if (strstr(evsel->name, "arm_spe_") && + !(sample_type & PERF_SAMPLE_DATA_SRC)) { + ui__warning("PERF_SAMPLE_DATA_SRC bit is not set " + "for Arm SPE event.\n"); + evsel->core.attr.sample_type |= PERF_SAMPLE_DATA_SRC; + sample_type |= PERF_SAMPLE_DATA_SRC; + } + } + if (!is_pipe && !(sample_type & PERF_SAMPLE_DATA_SRC)) { ui__error("Selected --mem-mode but no mem data. " "Did you call perf record without -d?\n"); -- 2.25.1