pmu.c (660842e468dcefb5d1d4fb40ed3abe4d1388dff7) pmu.c (1ba3752aec30c04bfb7c82b44332ff98294ec0b8)
1// SPDX-License-Identifier: GPL-2.0
2#include <linux/list.h>
3#include <linux/compiler.h>
4#include <linux/string.h>
5#include <linux/zalloc.h>
6#include <linux/ctype.h>
7#include <subcmd/pager.h>
8#include <sys/types.h>

--- 696 unchanged lines hidden (view full) ---

705
706 if (!printed) {
707 pr_debug("Using CPUID %s\n", cpuid);
708 printed = true;
709 }
710 return cpuid;
711}
712
1// SPDX-License-Identifier: GPL-2.0
2#include <linux/list.h>
3#include <linux/compiler.h>
4#include <linux/string.h>
5#include <linux/zalloc.h>
6#include <linux/ctype.h>
7#include <subcmd/pager.h>
8#include <sys/types.h>

--- 696 unchanged lines hidden (view full) ---

705
706 if (!printed) {
707 pr_debug("Using CPUID %s\n", cpuid);
708 printed = true;
709 }
710 return cpuid;
711}
712
713__weak const struct pmu_event *pmu_events_table__find(void)
713__weak const struct pmu_events_table *pmu_events_table__find(void)
714{
715 return perf_pmu__find_table(NULL);
716}
717
718/*
719 * Suffix must be in form tok_{digits}, or tok{digits}, or same as pmu_name
720 * to be valid.
721 */

--- 72 unchanged lines hidden (view full) ---

794struct pmu_add_cpu_aliases_map_data {
795 struct list_head *head;
796 const char *name;
797 const char *cpu_name;
798 struct perf_pmu *pmu;
799};
800
801static int pmu_add_cpu_aliases_map_callback(const struct pmu_event *pe,
714{
715 return perf_pmu__find_table(NULL);
716}
717
718/*
719 * Suffix must be in form tok_{digits}, or tok{digits}, or same as pmu_name
720 * to be valid.
721 */

--- 72 unchanged lines hidden (view full) ---

794struct pmu_add_cpu_aliases_map_data {
795 struct list_head *head;
796 const char *name;
797 const char *cpu_name;
798 struct perf_pmu *pmu;
799};
800
801static int pmu_add_cpu_aliases_map_callback(const struct pmu_event *pe,
802 const struct pmu_event *table __maybe_unused,
802 const struct pmu_events_table *table __maybe_unused,
803 void *vdata)
804{
805 struct pmu_add_cpu_aliases_map_data *data = vdata;
806 const char *pname = pe->pmu ? pe->pmu : data->cpu_name;
807
808 if (!pe->name)
809 return 0;
810

--- 11 unchanged lines hidden (view full) ---

822}
823
824/*
825 * From the pmu_events_map, find the table of PMU events that corresponds
826 * to the current running CPU. Then, add all PMU events from that table
827 * as aliases.
828 */
829void pmu_add_cpu_aliases_table(struct list_head *head, struct perf_pmu *pmu,
803 void *vdata)
804{
805 struct pmu_add_cpu_aliases_map_data *data = vdata;
806 const char *pname = pe->pmu ? pe->pmu : data->cpu_name;
807
808 if (!pe->name)
809 return 0;
810

--- 11 unchanged lines hidden (view full) ---

822}
823
824/*
825 * From the pmu_events_map, find the table of PMU events that corresponds
826 * to the current running CPU. Then, add all PMU events from that table
827 * as aliases.
828 */
829void pmu_add_cpu_aliases_table(struct list_head *head, struct perf_pmu *pmu,
830 const struct pmu_event *table)
830 const struct pmu_events_table *table)
831{
832 struct pmu_add_cpu_aliases_map_data data = {
833 .head = head,
834 .name = pmu->name,
835 .cpu_name = is_arm_pmu_core(pmu->name) ? pmu->name : "cpu",
836 .pmu = pmu,
837 };
838
839 pmu_events_table_for_each_event(table, pmu_add_cpu_aliases_map_callback, &data);
840}
841
842static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
843{
831{
832 struct pmu_add_cpu_aliases_map_data data = {
833 .head = head,
834 .name = pmu->name,
835 .cpu_name = is_arm_pmu_core(pmu->name) ? pmu->name : "cpu",
836 .pmu = pmu,
837 };
838
839 pmu_events_table_for_each_event(table, pmu_add_cpu_aliases_map_callback, &data);
840}
841
842static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
843{
844 const struct pmu_event *table;
844 const struct pmu_events_table *table;
845
846 table = perf_pmu__find_table(pmu);
847 if (!table)
848 return;
849
850 pmu_add_cpu_aliases_table(head, pmu, table);
851}
852
853struct pmu_sys_event_iter_data {
854 struct list_head *head;
855 struct perf_pmu *pmu;
856};
857
858static int pmu_add_sys_aliases_iter_fn(const struct pmu_event *pe,
845
846 table = perf_pmu__find_table(pmu);
847 if (!table)
848 return;
849
850 pmu_add_cpu_aliases_table(head, pmu, table);
851}
852
853struct pmu_sys_event_iter_data {
854 struct list_head *head;
855 struct perf_pmu *pmu;
856};
857
858static int pmu_add_sys_aliases_iter_fn(const struct pmu_event *pe,
859 const struct pmu_event *table __maybe_unused,
859 const struct pmu_events_table *table __maybe_unused,
860 void *data)
861{
862 struct pmu_sys_event_iter_data *idata = data;
863 struct perf_pmu *pmu = idata->pmu;
864
865 if (!pe->name) {
866 if (pe->metric_group || pe->metric_name)
867 return 0;

--- 1123 unchanged lines hidden ---
860 void *data)
861{
862 struct pmu_sys_event_iter_data *idata = data;
863 struct perf_pmu *pmu = idata->pmu;
864
865 if (!pe->name) {
866 if (pe->metric_group || pe->metric_name)
867 return 0;

--- 1123 unchanged lines hidden ---