1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2acbe613eSJiri Olsa #ifndef __PERF_MEM_EVENTS_H 3acbe613eSJiri Olsa #define __PERF_MEM_EVENTS_H 4acbe613eSJiri Olsa 5acbe613eSJiri Olsa #include <stdbool.h> 6aadddd68SJiri Olsa #include <stdint.h> 7aadddd68SJiri Olsa #include <stdio.h> 8aadddd68SJiri Olsa #include <linux/types.h> 9d3300a3cSArnaldo Carvalho de Melo #include <linux/refcount.h> 10d3300a3cSArnaldo Carvalho de Melo #include <linux/perf_event.h> 11aadddd68SJiri Olsa #include "stat.h" 122a57d408SKan Liang #include "evsel.h" 13acbe613eSJiri Olsa 14acbe613eSJiri Olsa struct perf_mem_event { 15acbe613eSJiri Olsa bool record; 1654fbad54SJiri Olsa bool supported; 17ce1e22b0SJiri Olsa const char *tag; 18acbe613eSJiri Olsa const char *name; 1954fbad54SJiri Olsa const char *sysfs_name; 20acbe613eSJiri Olsa }; 21acbe613eSJiri Olsa 22d3300a3cSArnaldo Carvalho de Melo struct mem_info { 23d3300a3cSArnaldo Carvalho de Melo struct addr_map_symbol iaddr; 24d3300a3cSArnaldo Carvalho de Melo struct addr_map_symbol daddr; 25d3300a3cSArnaldo Carvalho de Melo union perf_mem_data_src data_src; 26d3300a3cSArnaldo Carvalho de Melo refcount_t refcnt; 27d3300a3cSArnaldo Carvalho de Melo }; 28d3300a3cSArnaldo Carvalho de Melo 29acbe613eSJiri Olsa enum { 30acbe613eSJiri Olsa PERF_MEM_EVENTS__LOAD, 31acbe613eSJiri Olsa PERF_MEM_EVENTS__STORE, 324ba2452cSLeo Yan PERF_MEM_EVENTS__LOAD_STORE, 33acbe613eSJiri Olsa PERF_MEM_EVENTS__MAX, 34acbe613eSJiri Olsa }; 35acbe613eSJiri Olsa 36b0d745b3SJiri Olsa extern unsigned int perf_mem_events__loads_ldlat; 37acbe613eSJiri Olsa 38ce1e22b0SJiri Olsa int perf_mem_events__parse(const char *str); 3954fbad54SJiri Olsa int perf_mem_events__init(void); 40ce1e22b0SJiri Olsa 41*c091ee90SIan Rogers const char *perf_mem_events__name(int i, const char *pmu_name); 42eaf6aaeeSLeo Yan struct perf_mem_event *perf_mem_events__ptr(int i); 432a57d408SKan Liang bool is_mem_loads_aux_event(struct evsel *leader); 440c877d75SJiri Olsa 45b027cc6fSIan Rogers void perf_mem_events__list(void); 464a9086adSJin Yao int perf_mem_events__record_args(const char **rec_argv, int *argv_nr, 474a9086adSJin Yao char **rec_tmp, int *tmp_nr); 48b027cc6fSIan Rogers 49b1a5fbeaSJiri Olsa int perf_mem__tlb_scnprintf(char *out, size_t sz, struct mem_info *mem_info); 5096907563SJiri Olsa int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info); 51149d7507SJiri Olsa int perf_mem__snp_scnprintf(char *out, size_t sz, struct mem_info *mem_info); 528b0819c8SJiri Olsa int perf_mem__lck_scnprintf(char *out, size_t sz, struct mem_info *mem_info); 53a054c298SKan Liang int perf_mem__blk_scnprintf(char *out, size_t sz, struct mem_info *mem_info); 5469a77275SJiri Olsa 55c19ac912SJiri Olsa int perf_script__meminfo_scnprintf(char *bf, size_t size, struct mem_info *mem_info); 56c19ac912SJiri Olsa 57aadddd68SJiri Olsa struct c2c_stats { 58aadddd68SJiri Olsa u32 nr_entries; 59aadddd68SJiri Olsa 60aadddd68SJiri Olsa u32 locks; /* count of 'lock' transactions */ 61aadddd68SJiri Olsa u32 store; /* count of all stores in trace */ 62aadddd68SJiri Olsa u32 st_uncache; /* stores to uncacheable address */ 63aadddd68SJiri Olsa u32 st_noadrs; /* cacheable store with no address */ 64aadddd68SJiri Olsa u32 st_l1hit; /* count of stores that hit L1D */ 65aadddd68SJiri Olsa u32 st_l1miss; /* count of stores that miss L1D */ 6698450637SLeo Yan u32 st_na; /* count of stores with memory level is not available */ 67aadddd68SJiri Olsa u32 load; /* count of all loads in trace */ 68aadddd68SJiri Olsa u32 ld_excl; /* exclusive loads, rmt/lcl DRAM - snp none/miss */ 69aadddd68SJiri Olsa u32 ld_shared; /* shared loads, rmt/lcl DRAM - snp hit */ 70aadddd68SJiri Olsa u32 ld_uncache; /* loads to uncacheable address */ 71aadddd68SJiri Olsa u32 ld_io; /* loads to io address */ 72aadddd68SJiri Olsa u32 ld_miss; /* loads miss */ 73aadddd68SJiri Olsa u32 ld_noadrs; /* cacheable load with no address */ 74aadddd68SJiri Olsa u32 ld_fbhit; /* count of loads hitting Fill Buffer */ 75aadddd68SJiri Olsa u32 ld_l1hit; /* count of loads that hit L1D */ 76aadddd68SJiri Olsa u32 ld_l2hit; /* count of loads that hit L2D */ 77aadddd68SJiri Olsa u32 ld_llchit; /* count of loads that hit LLC */ 78aadddd68SJiri Olsa u32 lcl_hitm; /* count of loads with local HITM */ 79aadddd68SJiri Olsa u32 rmt_hitm; /* count of loads with remote HITM */ 80dba8ab93SJiri Olsa u32 tot_hitm; /* count of loads with local and remote HITM */ 81e843dec5SLeo Yan u32 lcl_peer; /* count of loads with local peer cache */ 82e843dec5SLeo Yan u32 rmt_peer; /* count of loads with remote peer cache */ 83e843dec5SLeo Yan u32 tot_peer; /* count of loads with local and remote peer cache */ 84aadddd68SJiri Olsa u32 rmt_hit; /* count of loads with remote hit clean; */ 85aadddd68SJiri Olsa u32 lcl_dram; /* count of loads miss to local DRAM */ 86aadddd68SJiri Olsa u32 rmt_dram; /* count of loads miss to remote DRAM */ 87d9d5d767SKan Liang u32 blk_data; /* count of loads blocked by data */ 88d9d5d767SKan Liang u32 blk_addr; /* count of loads blocked by address conflict */ 894d39c89fSIngo Molnar u32 nomap; /* count of load/stores with no phys addrs */ 90aadddd68SJiri Olsa u32 noparse; /* count of unparsable data sources */ 91aadddd68SJiri Olsa }; 92aadddd68SJiri Olsa 93aadddd68SJiri Olsa struct hist_entry; 94aadddd68SJiri Olsa int c2c_decode_stats(struct c2c_stats *stats, struct mem_info *mi); 950a9a24ccSJiri Olsa void c2c_add_stats(struct c2c_stats *stats, struct c2c_stats *add); 96aadddd68SJiri Olsa 97acbe613eSJiri Olsa #endif /* __PERF_MEM_EVENTS_H */ 98