Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1563942pxk; Tue, 1 Sep 2020 01:43:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdvsiMQzP/9/bfRlyN46O8RY0xRNR9zv6s915MsnObxUQSngOJQayUlQYWDAuQhg174XJn X-Received: by 2002:a17:906:a1c2:: with SMTP id bx2mr565416ejb.426.1598949833325; Tue, 01 Sep 2020 01:43:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598949833; cv=none; d=google.com; s=arc-20160816; b=0Vj6BKGlueWt6b21euXOpzmX+0wNFqFiREI3V7nEsXZIRPndT9XdTgNC8jdVFI/U/I hsumCD2auLcf2wYSxtWWiWoWwLE3BzFqzR8eRCCE9P8hshMqPfacJAx52+XD4pZis0ZD nt/sZAVB4wyu9wpkd8p1/Ty+Y4wrb5D4k+vuLE+W51DfcJ4g9P8gskFD0r2hT+6Q1QJ1 NI6u0aGXkxOEPWvRMFlA9Z8t7QETMvhDygYBvODlUl6fXuUO0NubPPyzH03gagTSQOMP z2EA4Cu2NbvQNeKV1FugphA80p5VgmW6b65UtA69tRX4/kasnhorpqYLJBuu8G38yYkC nQeA== 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=LGZEMSAJ/+KpI41IbIOIytfHUTobv/W7rivd/M7D32g=; b=jhm/e4cYVUfJgqvnx1qJT/3xFCH2EzLWrB7goF4TN3o+DuDjj569JrZMy3+3K5NmV0 +zj568OTSaBQ1ghCnAdlSowXSS0Cv2c3+WeVeFOtaVjc2qNHl4dtKxKbpH+tim7JGnNV JQvaO4K4xYW9pM0+p5eGxx24Iz0cg9d0+ga/sOdg5IalsVlmnBGL6RL3w8sON2Mxjp9G hDBFkpURrWZKgb3FciCOaenqA2BZxYG0qEK0Cv4NSYHczrtldOgmRHH0kp7eYP2+e5Lh 2AXh++ETiZ0krVvLIUKrQ9tz1h2W42+AN9fcfFGyEZzSOK2BU/Mxlb+UvJaL17+jYRQ8 sATA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="u5E/IDtl"; 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 a15si204328edn.264.2020.09.01.01.43.30; Tue, 01 Sep 2020 01:43:53 -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="u5E/IDtl"; 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 S1727889AbgIAIjL (ORCPT + 99 others); Tue, 1 Sep 2020 04:39:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727800AbgIAIiu (ORCPT ); Tue, 1 Sep 2020 04:38:50 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E1A9C061247 for ; Tue, 1 Sep 2020 01:38:49 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id o21so325610wmc.0 for ; Tue, 01 Sep 2020 01:38:49 -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=LGZEMSAJ/+KpI41IbIOIytfHUTobv/W7rivd/M7D32g=; b=u5E/IDtl6chlv/wJnDGBg5rc3mCp9iSXOSB1XSzeG9juqKnnqifBHvEQeI0eO9rMML PfPFlP4lfpqm4+c5ky4mMfuXnq0k3+YSSj7bmYs+N9Q/CXwyF1jMV0c4NANYOJOevpp4 Ep3LArmn+GBktLaxxXpy/+SDlkvw+k4Lu2U9JMAvJdqWVBmLNW6ysQflShARQxvbyGpZ bGCURT6f0YwIH1/pFHP46mJLD14ScezF0ftxjGB93w5FJom+EkgXJQ7I64vKZXi5S3u2 GmKWvT5NHyBO/Qsa2vpj7Cm9D7UZTuKclRLTfrYdnDN9C+mDRCOVMDYsRwLXCv39LkQZ afuQ== 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=LGZEMSAJ/+KpI41IbIOIytfHUTobv/W7rivd/M7D32g=; b=kdrT4GMqZvtwRpT37mWwmM9djfzOJx5zsEiDsoJSBpaEyPiBZjZSl3vxxG5z1ETL2h X64y/XbHCD1LVmfNWDphmdkjL265EQ5Ju7SXgvmWGWPOWYNfb6Ld1tOEITcgVht3w3vB aY/OyL/aerkch/Q2K/w7WV1R0FLFTNtuaALo4G8Q4IQo0ML5UrVRch5bR9tErOCU/Chi T0fVAVuLkNSg4poYow/FWdVJx25XrYPJ7JgZrLRidNiSk/MlokmpFCw4x34FAJpEPpLN taOIY+NVfPYDvMjLXHBM3FLGj6tMK/p5xsZerpqmiTNiyUvXtfZqE5DFQPbbkwV4K8a5 hCfg== X-Gm-Message-State: AOAM533aNYVla72lzLSvRWGx//tM69ZLAOPqEyuhZ4CzW6c0lzt5ByBW kSR71gtk9HnGce8S/fGr6XkZRg== X-Received: by 2002:a1c:bdd4:: with SMTP id n203mr663202wmf.119.1598949528226; Tue, 01 Sep 2020 01:38:48 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 01:38:47 -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 13/14] perf arm-spe: Set sample's data source field Date: Tue, 1 Sep 2020 09:38:14 +0100 Message-Id: <20200901083815.13755-14-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 The sample structure contains the field 'data_src' which is used to tell the detailed info for data operations, e.g. this field indicates the data operation is loading or storing, on which cache level, it's snooping or remote accessing, etc. At the end, the 'data_src' will be parsed by perf memory tool to display human readable strings. This patch is to fill the 'data_src' field in the synthesized samples base on different types. Now support types for Level 1 dcache miss, Level 1 dcache hit, Last level cache miss, Last level cache access, TLB miss, TLB hit, remote access for other socket. Note, current perf tool can display statistics for L1/L2/L3 caches but it doesn't support the 'last level cache'. To fit into current implementation, 'data_src' field uses L3 cache for last level cache. Signed-off-by: Leo Yan --- tools/perf/util/arm-spe.c | 63 +++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 7f44ef8c89f1..142149f732b3 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -264,7 +264,7 @@ arm_spe_deliver_synth_event(struct arm_spe *spe, } static int arm_spe__synth_mem_sample(struct arm_spe_queue *speq, - u64 spe_events_id) + u64 spe_events_id, u64 data_src) { struct arm_spe *spe = speq->spe; struct arm_spe_record *record = &speq->decoder->record; @@ -277,6 +277,7 @@ static int arm_spe__synth_mem_sample(struct arm_spe_queue *speq, sample.stream_id = spe_events_id; sample.addr = record->addr; sample.phys_addr = record->phys_addr; + sample.data_src = data_src; return arm_spe_deliver_synth_event(spe, speq, event, &sample); } @@ -311,21 +312,60 @@ static bool arm_spe__is_memory_event(enum arm_spe_sample_type type) return false; } +static u64 arm_spe__synth_data_source(const struct arm_spe_record *record) +{ + union perf_mem_data_src data_src = { 0 }; + + if (record->op == ARM_SPE_LD) + data_src.mem_op = PERF_MEM_OP_LOAD; + else + data_src.mem_op = PERF_MEM_OP_STORE; + + if (record->type & ARM_SPE_L1D_MISS) { + data_src.mem_lvl_num = PERF_MEM_LVLNUM_L1; + data_src.mem_lvl = PERF_MEM_LVL_MISS | PERF_MEM_LVL_L1; + } else if (record->type & ARM_SPE_L1D_ACCESS) { + data_src.mem_lvl_num = PERF_MEM_LVLNUM_L1; + data_src.mem_lvl = PERF_MEM_LVL_HIT | PERF_MEM_LVL_L1; + } else if (record->type & ARM_SPE_LLC_MISS) { + data_src.mem_lvl_num = PERF_MEM_LVLNUM_L3; + data_src.mem_lvl = PERF_MEM_LVL_MISS | PERF_MEM_LVL_L3; + } else if (record->type & ARM_SPE_LLC_ACCESS) { + data_src.mem_lvl_num = PERF_MEM_LVLNUM_L3; + data_src.mem_lvl = PERF_MEM_LVL_HIT | PERF_MEM_LVL_L3; + } else if (record->type & ARM_SPE_REMOTE_ACCESS) { + data_src.mem_lvl_num = PERF_MEM_LVLNUM_ANY_CACHE; + data_src.mem_lvl = PERF_MEM_LVL_HIT | PERF_MEM_LVL_REM_CCE1; + } + + if (record->type & ARM_SPE_TLB_MISS) + data_src.mem_dtlb = PERF_MEM_TLB_WK | PERF_MEM_TLB_MISS; + else if (record->type & ARM_SPE_TLB_ACCESS) + data_src.mem_dtlb = PERF_MEM_TLB_WK | PERF_MEM_TLB_HIT; + + return data_src.val; +} + static int arm_spe_sample(struct arm_spe_queue *speq) { const struct arm_spe_record *record = &speq->decoder->record; struct arm_spe *spe = speq->spe; + u64 data_src; int err; + data_src = arm_spe__synth_data_source(record); + if (spe->sample_flc) { if (record->type & ARM_SPE_L1D_MISS) { - err = arm_spe__synth_mem_sample(speq, spe->l1d_miss_id); + err = arm_spe__synth_mem_sample(speq, spe->l1d_miss_id, + data_src); if (err) return err; } if (record->type & ARM_SPE_L1D_ACCESS) { - err = arm_spe__synth_mem_sample(speq, spe->l1d_access_id); + err = arm_spe__synth_mem_sample(speq, spe->l1d_access_id, + data_src); if (err) return err; } @@ -333,13 +373,15 @@ 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_mem_sample(speq, spe->llc_miss_id); + err = arm_spe__synth_mem_sample(speq, spe->llc_miss_id, + data_src); if (err) return err; } if (record->type & ARM_SPE_LLC_ACCESS) { - err = arm_spe__synth_mem_sample(speq, spe->llc_access_id); + err = arm_spe__synth_mem_sample(speq, spe->llc_access_id, + data_src); if (err) return err; } @@ -347,13 +389,15 @@ 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_mem_sample(speq, spe->tlb_miss_id); + err = arm_spe__synth_mem_sample(speq, spe->tlb_miss_id, + data_src); if (err) return err; } if (record->type & ARM_SPE_TLB_ACCESS) { - err = arm_spe__synth_mem_sample(speq, spe->tlb_access_id); + err = arm_spe__synth_mem_sample(speq, spe->tlb_access_id, + data_src); if (err) return err; } @@ -367,13 +411,14 @@ static int arm_spe_sample(struct arm_spe_queue *speq) if (spe->sample_remote_access && (record->type & ARM_SPE_REMOTE_ACCESS)) { - err = arm_spe__synth_mem_sample(speq, spe->remote_access_id); + err = arm_spe__synth_mem_sample(speq, spe->remote_access_id, + data_src); if (err) return err; } if (spe->sample_memory && arm_spe__is_memory_event(record->type)) { - err = arm_spe__synth_mem_sample(speq, spe->memory_id); + err = arm_spe__synth_mem_sample(speq, spe->memory_id, data_src); if (err) return err; } -- 2.20.1