perf env: Add routine to read the env->cpuid from the running machine
In 'perf top' we use that cpuid when initializing the per arch annotation init routines (e.g. x86__annotate_init()) and in that case (live mode, 'perf top') we need to obtain it from the running machine, not from a perf.data file header. Provide a means to do that. Will be used by 'perf top' in a followup patch. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lkml.kernel.org/n/tip-h2wb3sx7u7znx6lqfezrh7ca@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
f733c6b508
commit
f1cedfb828
@ -2,6 +2,7 @@
|
|||||||
#include "cpumap.h"
|
#include "cpumap.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "env.h"
|
#include "env.h"
|
||||||
|
#include "util/header.h"
|
||||||
#include <linux/ctype.h>
|
#include <linux/ctype.h>
|
||||||
#include <linux/zalloc.h>
|
#include <linux/zalloc.h>
|
||||||
#include "bpf-event.h"
|
#include "bpf-event.h"
|
||||||
@ -256,6 +257,21 @@ int perf_env__read_cpu_topology_map(struct perf_env *env)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int perf_env__read_cpuid(struct perf_env *env)
|
||||||
|
{
|
||||||
|
char cpuid[128];
|
||||||
|
int err = get_cpuid(cpuid, sizeof(cpuid));
|
||||||
|
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
free(env->cpuid);
|
||||||
|
env->cpuid = strdup(cpuid);
|
||||||
|
if (env->cpuid == NULL)
|
||||||
|
return ENOMEM;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int perf_env__read_arch(struct perf_env *env)
|
static int perf_env__read_arch(struct perf_env *env)
|
||||||
{
|
{
|
||||||
struct utsname uts;
|
struct utsname uts;
|
||||||
|
@ -104,6 +104,7 @@ void perf_env__exit(struct perf_env *env);
|
|||||||
|
|
||||||
int perf_env__set_cmdline(struct perf_env *env, int argc, const char *argv[]);
|
int perf_env__set_cmdline(struct perf_env *env, int argc, const char *argv[]);
|
||||||
|
|
||||||
|
int perf_env__read_cpuid(struct perf_env *env);
|
||||||
int perf_env__read_cpu_topology_map(struct perf_env *env);
|
int perf_env__read_cpu_topology_map(struct perf_env *env);
|
||||||
|
|
||||||
void cpu_cache_level__free(struct cpu_cache_level *cache);
|
void cpu_cache_level__free(struct cpu_cache_level *cache);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user