pmu.c (58e16d792a6a8c6b750f637a4649967fcac853dc) | pmu.c (5e51b0bb245d963f5ce750256c504be95201e38c) |
---|---|
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 <sys/types.h> 7#include <errno.h> 8#include <fcntl.h> 9#include <sys/stat.h> 10#include <unistd.h> 11#include <stdio.h> 12#include <stdbool.h> 13#include <stdarg.h> 14#include <dirent.h> 15#include <api/fs/fs.h> 16#include <locale.h> 17#include <regex.h> | 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 <sys/types.h> 7#include <errno.h> 8#include <fcntl.h> 9#include <sys/stat.h> 10#include <unistd.h> 11#include <stdio.h> 12#include <stdbool.h> 13#include <stdarg.h> 14#include <dirent.h> 15#include <api/fs/fs.h> 16#include <locale.h> 17#include <regex.h> |
18#include <perf/cpumap.h> 19#include "debug.h" |
|
18#include "pmu.h" 19#include "parse-events.h" 20#include "cpumap.h" 21#include "header.h" 22#include "pmu-events/pmu-events.h" 23#include "cache.h" 24#include "string2.h" 25 --- 541 unchanged lines hidden (view full) --- 567 continue; 568 /* add to static LIST_HEAD(pmus): */ 569 perf_pmu__find(dent->d_name); 570 } 571 572 closedir(dir); 573} 574 | 20#include "pmu.h" 21#include "parse-events.h" 22#include "cpumap.h" 23#include "header.h" 24#include "pmu-events/pmu-events.h" 25#include "cache.h" 26#include "string2.h" 27 --- 541 unchanged lines hidden (view full) --- 569 continue; 570 /* add to static LIST_HEAD(pmus): */ 571 perf_pmu__find(dent->d_name); 572 } 573 574 closedir(dir); 575} 576 |
575static struct cpu_map *__pmu_cpumask(const char *path) | 577static struct perf_cpu_map *__pmu_cpumask(const char *path) |
576{ 577 FILE *file; | 578{ 579 FILE *file; |
578 struct cpu_map *cpus; | 580 struct perf_cpu_map *cpus; |
579 580 file = fopen(path, "r"); 581 if (!file) 582 return NULL; 583 | 581 582 file = fopen(path, "r"); 583 if (!file) 584 return NULL; 585 |
584 cpus = cpu_map__read(file); | 586 cpus = perf_cpu_map__read(file); |
585 fclose(file); 586 return cpus; 587} 588 589/* 590 * Uncore PMUs have a "cpumask" file under sysfs. CPU PMUs (e.g. on arm/arm64) 591 * may have a "cpus" file. 592 */ 593#define CPUS_TEMPLATE_UNCORE "%s/bus/event_source/devices/%s/cpumask" 594#define CPUS_TEMPLATE_CPU "%s/bus/event_source/devices/%s/cpus" 595 | 587 fclose(file); 588 return cpus; 589} 590 591/* 592 * Uncore PMUs have a "cpumask" file under sysfs. CPU PMUs (e.g. on arm/arm64) 593 * may have a "cpus" file. 594 */ 595#define CPUS_TEMPLATE_UNCORE "%s/bus/event_source/devices/%s/cpumask" 596#define CPUS_TEMPLATE_CPU "%s/bus/event_source/devices/%s/cpus" 597 |
596static struct cpu_map *pmu_cpumask(const char *name) | 598static struct perf_cpu_map *pmu_cpumask(const char *name) |
597{ 598 char path[PATH_MAX]; | 599{ 600 char path[PATH_MAX]; |
599 struct cpu_map *cpus; | 601 struct perf_cpu_map *cpus; |
600 const char *sysfs = sysfs__mountpoint(); 601 const char *templates[] = { 602 CPUS_TEMPLATE_UNCORE, 603 CPUS_TEMPLATE_CPU, 604 NULL 605 }; 606 const char **template; 607 --- 8 unchanged lines hidden (view full) --- 616 } 617 618 return NULL; 619} 620 621static bool pmu_is_uncore(const char *name) 622{ 623 char path[PATH_MAX]; | 602 const char *sysfs = sysfs__mountpoint(); 603 const char *templates[] = { 604 CPUS_TEMPLATE_UNCORE, 605 CPUS_TEMPLATE_CPU, 606 NULL 607 }; 608 const char **template; 609 --- 8 unchanged lines hidden (view full) --- 618 } 619 620 return NULL; 621} 622 623static bool pmu_is_uncore(const char *name) 624{ 625 char path[PATH_MAX]; |
624 struct cpu_map *cpus; | 626 struct perf_cpu_map *cpus; |
625 const char *sysfs = sysfs__mountpoint(); 626 627 snprintf(path, PATH_MAX, CPUS_TEMPLATE_UNCORE, sysfs, name); 628 cpus = __pmu_cpumask(path); | 627 const char *sysfs = sysfs__mountpoint(); 628 629 snprintf(path, PATH_MAX, CPUS_TEMPLATE_UNCORE, sysfs, name); 630 cpus = __pmu_cpumask(path); |
629 cpu_map__put(cpus); | 631 perf_cpu_map__put(cpus); |
630 631 return !!cpus; 632} 633 634/* 635 * PMU CORE devices have different name other than cpu in sysfs on some 636 * platforms. 637 * Looking for possible sysfs files to identify the arm core device. --- 915 unchanged lines hidden --- | 632 633 return !!cpus; 634} 635 636/* 637 * PMU CORE devices have different name other than cpu in sysfs on some 638 * platforms. 639 * Looking for possible sysfs files to identify the arm core device. --- 915 unchanged lines hidden --- |