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 F05C1C433EF for ; Sun, 24 Apr 2022 13:00:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231431AbiDXNDE (ORCPT ); Sun, 24 Apr 2022 09:03:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230198AbiDXNDC (ORCPT ); Sun, 24 Apr 2022 09:03:02 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EEFA15A09 for ; Sun, 24 Apr 2022 06:00:00 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id k27so352265edk.4 for ; Sun, 24 Apr 2022 06:00:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=xiS7jXTGQnjBRoWj5ugUGTqfRqlbiuFUwXWLNi1EeJU=; b=SoA9P8/6lxB7hLukKtbzsp9CZjR0hxa/1dGYCHYuHry7e1fzAxQ6TYBM8js3bDZUdT iOm61Ysfp+VWCcf+9mqf0kUzLrJUYw7YuJ15uXa1Qg/j5yGudMfYL9/jYojurUwjC/PT EF4eq9ZGJxtYkojhD+sVMg2nwuFOqrgxJSR6D5TaQWwjSD288Y4Ge6oKuMs4n8E7w6aM xlBuR90SsvtbwqDUVbaqEvYNuhXy9uc6zPZnL2UfwXO7tlG42uwMzk9iwiMgihzm2CQo Q3x7R66oab/+2CtRiaVN33ycNZmpYEmz8Y7GZZ01aEkb9YareOofyAESNR8hK7Nytuwx horA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=xiS7jXTGQnjBRoWj5ugUGTqfRqlbiuFUwXWLNi1EeJU=; b=o8Mi9jhJnln2d20TTieAViwRLDSNqiqqI4ViWbCZbY8OcfNmH55kD8aPgNv+VmSK42 NyznSEtpKMOIEIRZhHQ0xvf2q4gYn0l1pfckucPZ6VrOh6/K7xd+oZAg+m37NjDZFXrY KlT8HBSETdAkslYOWdbUl2bkgsaEvXcIXkZFXgaynH6mOEvpETk9rlpGN1VCJ/l22kk0 kz2HmeaijvY19MRtaZv56snNxKTujLEbW4x2bt1639otGHA6wNxIVDVhmIvQK7G8BTjZ 4p3rO4uFF+r4wYE8B9YWCSZyqNoUTetUacwKpU8AZ/vMEX/OldQ3RKTMGY6xv3yWsRFW yaNw== X-Gm-Message-State: AOAM533HaMzmYTeXf6wrZbCTsg0wMMoUs4sALwFB8pDpJKhzh53p3Fdl 2YoFlHIUOPoogn1BGm4hruo3+g== X-Google-Smtp-Source: ABdhPJzWd6TnX8cfWuoEpPnonVAdlLmH1faYJGpdsybfh5SgAIg5RUp8Wh3mjpXz0jixZJTcziCJFw== X-Received: by 2002:a05:6402:2985:b0:425:d51f:ae4 with SMTP id eq5-20020a056402298500b00425d51f0ae4mr6102711edb.379.1650805198838; Sun, 24 Apr 2022 05:59:58 -0700 (PDT) Received: from leoy-ThinkPad-X240s ([104.245.96.34]) by smtp.gmail.com with ESMTPSA id y14-20020a056402440e00b00416046b623csm3408984eda.2.2022.04.24.05.59.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Apr 2022 05:59:58 -0700 (PDT) Date: Sun, 24 Apr 2022 20:59:51 +0800 From: Leo Yan To: Timothy Hayes Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, acme@kernel.org, John Garry , Will Deacon , Mathieu Poirier , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH 2/3] perf: arm-spe: Fix SPE events with phys addresses Message-ID: <20220424125951.GD978927@leoy-ThinkPad-X240s> References: <20220421165205.117662-1-timothy.hayes@arm.com> <20220421165205.117662-3-timothy.hayes@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220421165205.117662-3-timothy.hayes@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Timothy, On Thu, Apr 21, 2022 at 05:52:04PM +0100, Timothy Hayes wrote: > This patch corrects a bug whereby SPE collection is invoked with > pa_enable=1 but synthesized events fail to show physical addresses. > > Signed-off-by: Timothy Hayes > --- > tools/perf/arch/arm64/util/arm-spe.c | 10 ++++++++++ > tools/perf/util/arm-spe.c | 3 ++- > 2 files changed, 12 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c > index af4d63af8072..e8b577d33e53 100644 > --- a/tools/perf/arch/arm64/util/arm-spe.c > +++ b/tools/perf/arch/arm64/util/arm-spe.c > @@ -148,6 +148,7 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, > bool privileged = perf_event_paranoid_check(-1); > struct evsel *tracking_evsel; > int err; > + u64 bit; > > sper->evlist = evlist; > > @@ -245,6 +246,15 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, > */ > evsel__set_sample_bit(arm_spe_evsel, DATA_SRC); > > + /* > + * The PHYS_ADDR flag does not affect the driver behaviour, it is used to > + * inform that the resulting output's SPE samples contain physical addresses > + * where applicable. > + */ > + bit = perf_pmu__format_bits(&arm_spe_pmu->format, "pa_enable"); > + if (arm_spe_evsel->core.attr.config & bit) > + evsel__set_sample_bit(arm_spe_evsel, PHYS_ADDR); > + > /* Add dummy event to keep tracking */ > err = parse_events(evlist, "dummy:u", NULL); > if (err) > diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c > index 151cc38a171c..1a80151baed9 100644 > --- a/tools/perf/util/arm-spe.c > +++ b/tools/perf/util/arm-spe.c > @@ -1033,7 +1033,8 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) > memset(&attr, 0, sizeof(struct perf_event_attr)); > attr.size = sizeof(struct perf_event_attr); > attr.type = PERF_TYPE_HARDWARE; > - attr.sample_type = evsel->core.attr.sample_type & PERF_SAMPLE_MASK; > + attr.sample_type = evsel->core.attr.sample_type & > + (PERF_SAMPLE_MASK | PERF_SAMPLE_PHYS_ADDR); I verified this patch and I can confirm the physical address can be dumped successfully. I have a more general question, seems to me, we need to change the macro PERF_SAMPLE_MASK in the file util/event.h as below, so here doesn't need to 'or' the flag PERF_SAMPLE_PHYS_ADDR anymore. @Arnaldo, @Jiri, could you confirm if this is the right way to move forward? I am not sure why PERF_SAMPLE_MASK doesn't contain the bit PERF_SAMPLE_PHYS_ADDR in current code. diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index cdd72e05fd28..c905ac32ebad 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -39,7 +39,7 @@ struct perf_event_attr; PERF_SAMPLE_TIME | PERF_SAMPLE_ADDR | \ PERF_SAMPLE_ID | PERF_SAMPLE_STREAM_ID | \ PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD | \ - PERF_SAMPLE_IDENTIFIER) + PERF_SAMPLE_IDENTIFIER | PERF_SAMPLE_PHYS_ADDR) Thanks, Leo > attr.sample_type |= PERF_SAMPLE_IP | PERF_SAMPLE_TID | > PERF_SAMPLE_PERIOD | PERF_SAMPLE_DATA_SRC | > PERF_SAMPLE_WEIGHT | PERF_SAMPLE_ADDR; > -- > 2.25.1 > 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 036FEC433F5 for ; Sun, 24 Apr 2022 13:01:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PGtvr/rU8YtF3uIqKYnzQR3ONiUef6HBw5rmY+LQaiE=; b=ZxpfkVZcbmaNpU EQDN5bH1jKuaoP8FxXgGKLSnsN/LjfBqs3d2V/MlO9r6lh6i1dZvfbd0ktg5ZeiJ97iehqmIWXCAK 83kp4aMIwKnrYBHsv4d11jzZXmmyxU2fqbSCJwsp4Ajk3ockZBbirkC3WGbi8sif1wJww1z8qwGV9 imO3Z58Lb0NsHlHJI2aXSZt2U9RHOzYAptcWh6mpab5W/ZgmNc+ng8HLT5xWixLdUBNs3MoQWTyAX sDv0E132P/TxbtdNoHWyqu+g7nyTaS38tpoJKI64kyxZhQTUa/TRPfAIvyKdNAFRDhR63NgcmJan2 RNshOKAEa03UDR0uX/hw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nibqP-006bRy-65; Sun, 24 Apr 2022 13:00:05 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nibqL-006bRE-9N for linux-arm-kernel@lists.infradead.org; Sun, 24 Apr 2022 13:00:02 +0000 Received: by mail-ed1-x536.google.com with SMTP id p18so10354852edr.7 for ; Sun, 24 Apr 2022 06:00:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=xiS7jXTGQnjBRoWj5ugUGTqfRqlbiuFUwXWLNi1EeJU=; b=SoA9P8/6lxB7hLukKtbzsp9CZjR0hxa/1dGYCHYuHry7e1fzAxQ6TYBM8js3bDZUdT iOm61Ysfp+VWCcf+9mqf0kUzLrJUYw7YuJ15uXa1Qg/j5yGudMfYL9/jYojurUwjC/PT EF4eq9ZGJxtYkojhD+sVMg2nwuFOqrgxJSR6D5TaQWwjSD288Y4Ge6oKuMs4n8E7w6aM xlBuR90SsvtbwqDUVbaqEvYNuhXy9uc6zPZnL2UfwXO7tlG42uwMzk9iwiMgihzm2CQo Q3x7R66oab/+2CtRiaVN33ycNZmpYEmz8Y7GZZ01aEkb9YareOofyAESNR8hK7Nytuwx horA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=xiS7jXTGQnjBRoWj5ugUGTqfRqlbiuFUwXWLNi1EeJU=; b=Rowu5WI58skWxO3VUjvEZgCfr/hLY89/Dnqrv10zAyntKu+M9eazY64YD9qW4Yb3AU Ws8j6h84nqLaLqqQHLTA76bfVZi99VChZbB8tNIC7592Tx3sjmZdGZH1hWOqlI2q6zJF fJ272iL6kixjzRA+wMyFm3y9TW4uVLl5sUUnfMcF6CJUEU/5VBcx5nIEQNG8GkzRALIU wChdeSDCCdg8SnsEy2S+kPLcT6op7Miaxe6ywtMCKLC6n7WPFwDLqG0JDTWTkt/9y0lo 7eypEFen2Ck+4Fq1ZBTRJ3YgkiXNiVgSnWlUmFZzsxJPlC0mbgzrbnh0zdbMDQ7RhzWl glwQ== X-Gm-Message-State: AOAM531t9nT05UYCb3BryiBwigvIgC5W1p7LrkDhyrV+Urm9+34ipD/P sMkkyORXNrmQ/DtRak4c1jS9Sw== X-Google-Smtp-Source: ABdhPJzWd6TnX8cfWuoEpPnonVAdlLmH1faYJGpdsybfh5SgAIg5RUp8Wh3mjpXz0jixZJTcziCJFw== X-Received: by 2002:a05:6402:2985:b0:425:d51f:ae4 with SMTP id eq5-20020a056402298500b00425d51f0ae4mr6102711edb.379.1650805198838; Sun, 24 Apr 2022 05:59:58 -0700 (PDT) Received: from leoy-ThinkPad-X240s ([104.245.96.34]) by smtp.gmail.com with ESMTPSA id y14-20020a056402440e00b00416046b623csm3408984eda.2.2022.04.24.05.59.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Apr 2022 05:59:58 -0700 (PDT) Date: Sun, 24 Apr 2022 20:59:51 +0800 From: Leo Yan To: Timothy Hayes Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, acme@kernel.org, John Garry , Will Deacon , Mathieu Poirier , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH 2/3] perf: arm-spe: Fix SPE events with phys addresses Message-ID: <20220424125951.GD978927@leoy-ThinkPad-X240s> References: <20220421165205.117662-1-timothy.hayes@arm.com> <20220421165205.117662-3-timothy.hayes@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220421165205.117662-3-timothy.hayes@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220424_060001_421389_78BBBB17 X-CRM114-Status: GOOD ( 24.53 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Timothy, On Thu, Apr 21, 2022 at 05:52:04PM +0100, Timothy Hayes wrote: > This patch corrects a bug whereby SPE collection is invoked with > pa_enable=1 but synthesized events fail to show physical addresses. > > Signed-off-by: Timothy Hayes > --- > tools/perf/arch/arm64/util/arm-spe.c | 10 ++++++++++ > tools/perf/util/arm-spe.c | 3 ++- > 2 files changed, 12 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c > index af4d63af8072..e8b577d33e53 100644 > --- a/tools/perf/arch/arm64/util/arm-spe.c > +++ b/tools/perf/arch/arm64/util/arm-spe.c > @@ -148,6 +148,7 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, > bool privileged = perf_event_paranoid_check(-1); > struct evsel *tracking_evsel; > int err; > + u64 bit; > > sper->evlist = evlist; > > @@ -245,6 +246,15 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, > */ > evsel__set_sample_bit(arm_spe_evsel, DATA_SRC); > > + /* > + * The PHYS_ADDR flag does not affect the driver behaviour, it is used to > + * inform that the resulting output's SPE samples contain physical addresses > + * where applicable. > + */ > + bit = perf_pmu__format_bits(&arm_spe_pmu->format, "pa_enable"); > + if (arm_spe_evsel->core.attr.config & bit) > + evsel__set_sample_bit(arm_spe_evsel, PHYS_ADDR); > + > /* Add dummy event to keep tracking */ > err = parse_events(evlist, "dummy:u", NULL); > if (err) > diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c > index 151cc38a171c..1a80151baed9 100644 > --- a/tools/perf/util/arm-spe.c > +++ b/tools/perf/util/arm-spe.c > @@ -1033,7 +1033,8 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) > memset(&attr, 0, sizeof(struct perf_event_attr)); > attr.size = sizeof(struct perf_event_attr); > attr.type = PERF_TYPE_HARDWARE; > - attr.sample_type = evsel->core.attr.sample_type & PERF_SAMPLE_MASK; > + attr.sample_type = evsel->core.attr.sample_type & > + (PERF_SAMPLE_MASK | PERF_SAMPLE_PHYS_ADDR); I verified this patch and I can confirm the physical address can be dumped successfully. I have a more general question, seems to me, we need to change the macro PERF_SAMPLE_MASK in the file util/event.h as below, so here doesn't need to 'or' the flag PERF_SAMPLE_PHYS_ADDR anymore. @Arnaldo, @Jiri, could you confirm if this is the right way to move forward? I am not sure why PERF_SAMPLE_MASK doesn't contain the bit PERF_SAMPLE_PHYS_ADDR in current code. diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index cdd72e05fd28..c905ac32ebad 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -39,7 +39,7 @@ struct perf_event_attr; PERF_SAMPLE_TIME | PERF_SAMPLE_ADDR | \ PERF_SAMPLE_ID | PERF_SAMPLE_STREAM_ID | \ PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD | \ - PERF_SAMPLE_IDENTIFIER) + PERF_SAMPLE_IDENTIFIER | PERF_SAMPLE_PHYS_ADDR) Thanks, Leo > attr.sample_type |= PERF_SAMPLE_IP | PERF_SAMPLE_TID | > PERF_SAMPLE_PERIOD | PERF_SAMPLE_DATA_SRC | > PERF_SAMPLE_WEIGHT | PERF_SAMPLE_ADDR; > -- > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel