Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1562566pxk; Tue, 1 Sep 2020 01:40:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuiF46HFy4Zhs0X8HYHXx+F8WASMq4/mnrtGR6N1+evLhMJQq2mVhGKVJpwc5yo97FZwi8 X-Received: by 2002:a50:bb26:: with SMTP id y35mr839711ede.234.1598949650959; Tue, 01 Sep 2020 01:40:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598949650; cv=none; d=google.com; s=arc-20160816; b=Mnvmj8uFoWyVaydZQWNCsYDXDaPsB333lJXYZ/k0utFy9dQzxjZkvoygbRapig2uPB ItPnYjK3MHey/Nizn+DqEULQE75zSjLNatgY78OMHyscKlW/tnSRmS+77zzEjpZVRCsJ Iol8MhHUb4+ef7A3lRqutUYtVH+JEQxGrdWDIT2KHvcmbf/eRcYOUwYbcztFC97VXSt5 yOmZBF58HC+oiEJ3n5BkRTJkUD6GY8CJuPBYKbvdhDPkPVaMojlB+gZ6rZfn3g8eiK1M NKigQJ00ffHf8yCftW8o5mCNtQ34dz9G+/p1YJ0gr8zdtaKz/zNb+cCCA/Eh07Fp+E2K bmcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=T4gvXc12qVIjgGy8JvwWEOwfpDxFdYPq0XNHLJKuwBc=; b=NE+tQzL6UXeRKH++nG3646qPwDnUjBV6AA0Tvs7UJ9Cok2FkzNrrG6WG4GR/kaq7cb v9RyUsdKqF/1BMQto3ei2j/9vG8+DJfVgCjtz8W6b6/oZNh21zMriSZ6H2+e/2MSbdJ4 07mBIkDzSn0gOaM6OO2vHIUrX7vBduSsbdjL9MB/3YcsQemlhMQ6B+AOgRRZXR+uyGJR GxiMnmG00plG7o1WJHA49Zw7nt3JI99+3UmHugDw8yP8Jfwk1wIbiXQ1FniiHWHEfybJ Pmle1Fh/BXI9xzQBpX9WAJHJnpqGC/sn5Knug17Sd74lADUzCuK5Vr/f9BCfb3hCBo/X tzGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bv76ZB9k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v4si287746eji.300.2020.09.01.01.40.27; Tue, 01 Sep 2020 01:40:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bv76ZB9k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727946AbgIAIjT (ORCPT + 99 others); Tue, 1 Sep 2020 04:39:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727792AbgIAIir (ORCPT ); Tue, 1 Sep 2020 04:38:47 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 297FCC061245 for ; Tue, 1 Sep 2020 01:38:47 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id e16so540475wrm.2 for ; Tue, 01 Sep 2020 01:38:47 -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; bh=T4gvXc12qVIjgGy8JvwWEOwfpDxFdYPq0XNHLJKuwBc=; b=Bv76ZB9k6IQ9u20oZwBRN0DhH3ss88u1vysr96Hh6+mrLd16Ket25CqLL3l5sskH76 PrvqWZ4lmIVzk4dG/orpdGv9vhEZ9mWmM3f0dmSgf3zj3EHC/ChFUIBS4wKlm9ndCRA7 EonVgFD/6E1G9yqDv78+GKCqFXnAtpgU3++zjxqYv0Ltm/VV5UDUeLAdLUskDECOXP5L x7MagC8fQ5FKdARnrl49wO/GEfJ0slgqWXQtmIrazaxZpHz1IbEy2wRcgcoZqhM6iwa4 YFIbNAINME9w+czDQMpK0lgvynan4ROFFsH93gsB2b7NERSqP3kCnxSEXX3+pv/UsU+A ykRg== 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; bh=T4gvXc12qVIjgGy8JvwWEOwfpDxFdYPq0XNHLJKuwBc=; b=S3jY8KJwIp2Tn5XzptbjrBGjU2Qe5xcIC3J4RlV7wT82jzSFLheKcYKKnV5LKVZybA R3Gfs9sqd94JYchupiYqR2C6VlKfm3A0MiqL2c8/CqogApKwgcfPPZ+jy2WuMw+eO390 smX9axfBYzS9psvxrJj/Q8shsd5fOVgTwbFCyGnnwQ8z+4Xb/Fid40RZlDL6KXuqHeIv /DjFLlTYoyBLGg+JY+Pft2jLVYPJGMP2oOqeQWT60flzsdTJZvkV7ax6D9nZYCM5Uwfk d8h3emVN0xK8nWQlrFkOI7/PK7Ol1JdkvOl+n8c9vKg7jFVZcfj8ASQVu4kswK3Mihkr Yw8g== X-Gm-Message-State: AOAM532Nq01s/dJyn8wPYGcd+fw5HzVd0sfg/qN0Tn5P2AfQ9/KyvxoN LzSuej2TMYo2Udu8rveVi4kAxw== X-Received: by 2002:a05:6000:118e:: with SMTP id g14mr676475wrx.139.1598949525489; Tue, 01 Sep 2020 01:38:45 -0700 (PDT) Received: from hackbox2.linaro.org ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id d190sm911260wmd.23.2020.09.01.01.38.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 01:38:44 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Andi Kleen , Ian Rogers , Nick Desaulniers , "Naveen N. Rao" , Kemeng Shi , James Clark , Wei Li , Al Grant , Will Deacon , Mathieu Poirier , Mike Leach , linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v2 11/14] perf arm-spe: Fill address info for samples Date: Tue, 1 Sep 2020 09:38:12 +0100 Message-Id: <20200901083815.13755-12-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901083815.13755-1-leo.yan@linaro.org> References: <20200901083815.13755-1-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since the Arm SPE backend decoder has passed virtual and physical addresses info through packet, these addresses info can be filled into the synthesize samples, finally the address info can be used for memory profiling. This patch divides into two functions for generating samples: - arm_spe__synth_mem_sample() is for synthesizing memory accessing and TLB related samples; - arm_spe__synth_branch_sample() is to synthesize branch samples which is mainly for branch miss prediction. Signed-off-by: Leo Yan --- tools/perf/util/arm-spe.c | 52 +++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 305ab725b3ba..44e73e0ff4e7 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -238,7 +238,6 @@ static void arm_spe_prep_sample(struct arm_spe *spe, sample->cpumode = arm_spe_cpumode(spe, sample->ip); sample->pid = speq->pid; sample->tid = speq->tid; - sample->addr = record->to_ip; sample->period = 1; sample->cpu = speq->cpu; @@ -262,18 +261,37 @@ arm_spe_deliver_synth_event(struct arm_spe *spe, return ret; } -static int -arm_spe_synth_spe_events_sample(struct arm_spe_queue *speq, - u64 spe_events_id) +static int arm_spe__synth_mem_sample(struct arm_spe_queue *speq, + u64 spe_events_id) { struct arm_spe *spe = speq->spe; + struct arm_spe_record *record = &speq->decoder->record; + union perf_event *event = speq->event_buf; + struct perf_sample sample = { 0 }; + + arm_spe_prep_sample(spe, speq, event, &sample); + + sample.id = spe_events_id; + sample.stream_id = spe_events_id; + sample.addr = record->addr; + sample.phys_addr = record->phys_addr; + + return arm_spe_deliver_synth_event(spe, speq, event, &sample); +} + +static int arm_spe__synth_branch_sample(struct arm_spe_queue *speq, + u64 spe_events_id) +{ + struct arm_spe *spe = speq->spe; + struct arm_spe_record *record = &speq->decoder->record; union perf_event *event = speq->event_buf; - struct perf_sample sample = { .ip = 0, }; + struct perf_sample sample = { 0 }; arm_spe_prep_sample(spe, speq, event, &sample); sample.id = spe_events_id; sample.stream_id = spe_events_id; + sample.addr = record->to_ip; return arm_spe_deliver_synth_event(spe, speq, event, &sample); } @@ -286,15 +304,13 @@ static int arm_spe_sample(struct arm_spe_queue *speq) if (spe->sample_flc) { if (record->type & ARM_SPE_L1D_MISS) { - err = arm_spe_synth_spe_events_sample( - speq, spe->l1d_miss_id); + err = arm_spe__synth_mem_sample(speq, spe->l1d_miss_id); if (err) return err; } if (record->type & ARM_SPE_L1D_ACCESS) { - err = arm_spe_synth_spe_events_sample( - speq, spe->l1d_access_id); + err = arm_spe__synth_mem_sample(speq, spe->l1d_access_id); if (err) return err; } @@ -302,15 +318,13 @@ static int arm_spe_sample(struct arm_spe_queue *speq) if (spe->sample_llc) { if (record->type & ARM_SPE_LLC_MISS) { - err = arm_spe_synth_spe_events_sample( - speq, spe->llc_miss_id); + err = arm_spe__synth_mem_sample(speq, spe->llc_miss_id); if (err) return err; } if (record->type & ARM_SPE_LLC_ACCESS) { - err = arm_spe_synth_spe_events_sample( - speq, spe->llc_access_id); + err = arm_spe__synth_mem_sample(speq, spe->llc_access_id); if (err) return err; } @@ -318,31 +332,27 @@ static int arm_spe_sample(struct arm_spe_queue *speq) if (spe->sample_tlb) { if (record->type & ARM_SPE_TLB_MISS) { - err = arm_spe_synth_spe_events_sample( - speq, spe->tlb_miss_id); + err = arm_spe__synth_mem_sample(speq, spe->tlb_miss_id); if (err) return err; } if (record->type & ARM_SPE_TLB_ACCESS) { - err = arm_spe_synth_spe_events_sample( - speq, spe->tlb_access_id); + err = arm_spe__synth_mem_sample(speq, spe->tlb_access_id); if (err) return err; } } if (spe->sample_branch && (record->type & ARM_SPE_BRANCH_MISS)) { - err = arm_spe_synth_spe_events_sample(speq, - spe->branch_miss_id); + err = arm_spe__synth_branch_sample(speq, spe->branch_miss_id); if (err) return err; } if (spe->sample_remote_access && (record->type & ARM_SPE_REMOTE_ACCESS)) { - err = arm_spe_synth_spe_events_sample(speq, - spe->remote_access_id); + err = arm_spe__synth_mem_sample(speq, spe->remote_access_id); if (err) return err; } -- 2.20.1