From patchwork Wed May 18 22:47:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 12854203 X-Patchwork-Delegate: bpf@iogearbox.net 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 97939C433F5 for ; Wed, 18 May 2022 22:47:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230243AbiERWrk (ORCPT ); Wed, 18 May 2022 18:47:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230268AbiERWre (ORCPT ); Wed, 18 May 2022 18:47:34 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 094C616D4A5; Wed, 18 May 2022 15:47:29 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id nk9-20020a17090b194900b001df2fcdc165so7060470pjb.0; Wed, 18 May 2022 15:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5k+UAQBgaQSFvof05RgSIz5e6L+wrYZgJDsxYwQlz4Q=; b=hVxIHikvxUPAAmOD/wRvVA384X/YFMiIJbmleOFQvgg+XaXFD+Gc7ZBYbp9TsRSxtD mICvQ4a/8++UAcjAXI6j0qRZdX+Sty4ojBibKQtrqtj1lEQInKAMtgEcdrb07DPdmyFL c/pSl464X0I1gVYmLgYSVlHHUqbKhkTnd3ykN0WE6zG0rGattoiZP2h86CElaAZ6pY3n zrsNjJvN4Ju7YlguLgqe+nBMIiOQ+YDuYfCPnnnTXjob8C/qYOapoEZav8z68nbhQkK9 EfvS1zGAAVJxAFYO7mPLEY/qtaSFadVVsxufAA/BZK/B+4tjG0pHxBJHhWppPgcgpNZ0 lfdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=5k+UAQBgaQSFvof05RgSIz5e6L+wrYZgJDsxYwQlz4Q=; b=W5T5mfGJtE063d+Pn9pZz7eMi2x24OKOU19Phu9yulc5ZMKUmGY1EIE5GzkuHxoq/V efSchN2bDsxeoeb8YT3xJAq+Qwh3r02Fz8GeTTueLibHr/lQjJpZWil/vX22diCCRtXU a45+9uwskj+GBO4ar7mrAlJygGo2KieO+eKuRzEkKrlmfFNlU8pBmHA5NhzrpKJ9Qxdf YfSqpWX0NwaVfRLPACyh9GVcwaD7tahj8F+jtjor2Bc7cgDzEnpYTaw0ukLyUU8s0kmX YZ6sLgXHamZ3OMNyhSUuHghdIEXw7Pd/YnST4tSZZs9lV1HTRTPHkyLxXKbsGSR+E9SD J98w== X-Gm-Message-State: AOAM533VJdg/dLPTXA4BykwFgelJcnmxt2/6doIxdlmv7n6o3tQ4Yfma /yId/hGoOR8mim/A5cSzb+k= X-Google-Smtp-Source: ABdhPJzbYzjCT1gW3ilXdnX3/GctK0XISfQyTjracq66aaKXBPShW0zidNoWF2zkjNY+/uV2XEolKw== X-Received: by 2002:a17:90b:17c1:b0:1dc:a6e6:ef26 with SMTP id me1-20020a17090b17c100b001dca6e6ef26mr2406476pjb.22.1652914048988; Wed, 18 May 2022 15:47:28 -0700 (PDT) Received: from balhae.corp.google.com ([2620:15c:2c1:200:a718:cbfe:31cb:3a04]) by smtp.gmail.com with ESMTPSA id d23-20020a170902aa9700b0015e8d4eb2besm2214100plr.264.2022.05.18.15.47.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 15:47:28 -0700 (PDT) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Andi Kleen , Ian Rogers , Song Liu , Hao Luo , Milian Wolff , bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, Blake Jones Subject: [PATCH 1/6] perf report: Do not extend sample type of bpf-output event Date: Wed, 18 May 2022 15:47:20 -0700 Message-Id: <20220518224725.742882-2-namhyung@kernel.org> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog In-Reply-To: <20220518224725.742882-1-namhyung@kernel.org> References: <20220518224725.742882-1-namhyung@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org Currently evsel__new_idx() sets more sample_type bits when it finds a BPF-output event. But it should honor what's recorded in the perf data file rather than blindly sets the bits. Otherwise it could lead to a parse error when it recorded with a modified sample_type. Signed-off-by: Namhyung Kim --- tools/perf/util/evsel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 1cf967d689aa..d3c8ebdc6d43 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -296,8 +296,8 @@ struct evsel *evsel__new_idx(struct perf_event_attr *attr, int idx) return NULL; evsel__init(evsel, attr, idx); - if (evsel__is_bpf_output(evsel)) { - evsel->core.attr.sample_type |= (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | + if (evsel__is_bpf_output(evsel) && !attr->sample_type) { + evsel->core.attr.sample_type = (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD), evsel->core.attr.sample_period = 1; }