~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/util/env.c

Version: ~ [ linux-5.2-rc1 ] ~ [ linux-5.1.2 ] ~ [ linux-5.0.16 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.43 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.119 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.176 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.179 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.139 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.67 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #include "cpumap.h"
  2 #include "env.h"
  3 #include "util.h"
  4 
  5 struct perf_env perf_env;
  6 
  7 void perf_env__exit(struct perf_env *env)
  8 {
  9         int i;
 10 
 11         zfree(&env->hostname);
 12         zfree(&env->os_release);
 13         zfree(&env->version);
 14         zfree(&env->arch);
 15         zfree(&env->cpu_desc);
 16         zfree(&env->cpuid);
 17         zfree(&env->cmdline);
 18         zfree(&env->cmdline_argv);
 19         zfree(&env->sibling_cores);
 20         zfree(&env->sibling_threads);
 21         zfree(&env->numa_nodes);
 22         zfree(&env->pmu_mappings);
 23         zfree(&env->cpu);
 24 
 25         for (i = 0; i < env->caches_cnt; i++)
 26                 cpu_cache_level__free(&env->caches[i]);
 27         zfree(&env->caches);
 28 }
 29 
 30 int perf_env__set_cmdline(struct perf_env *env, int argc, const char *argv[])
 31 {
 32         int i;
 33 
 34         /* do not include NULL termination */
 35         env->cmdline_argv = calloc(argc, sizeof(char *));
 36         if (env->cmdline_argv == NULL)
 37                 goto out_enomem;
 38 
 39         /*
 40          * Must copy argv contents because it gets moved around during option
 41          * parsing:
 42          */
 43         for (i = 0; i < argc ; i++) {
 44                 env->cmdline_argv[i] = argv[i];
 45                 if (env->cmdline_argv[i] == NULL)
 46                         goto out_free;
 47         }
 48 
 49         env->nr_cmdline = argc;
 50 
 51         return 0;
 52 out_free:
 53         zfree(&env->cmdline_argv);
 54 out_enomem:
 55         return -ENOMEM;
 56 }
 57 
 58 int perf_env__read_cpu_topology_map(struct perf_env *env)
 59 {
 60         int cpu, nr_cpus;
 61 
 62         if (env->cpu != NULL)
 63                 return 0;
 64 
 65         if (env->nr_cpus_avail == 0)
 66                 env->nr_cpus_avail = sysconf(_SC_NPROCESSORS_CONF);
 67 
 68         nr_cpus = env->nr_cpus_avail;
 69         if (nr_cpus == -1)
 70                 return -EINVAL;
 71 
 72         env->cpu = calloc(nr_cpus, sizeof(env->cpu[0]));
 73         if (env->cpu == NULL)
 74                 return -ENOMEM;
 75 
 76         for (cpu = 0; cpu < nr_cpus; ++cpu) {
 77                 env->cpu[cpu].core_id   = cpu_map__get_core_id(cpu);
 78                 env->cpu[cpu].socket_id = cpu_map__get_socket_id(cpu);
 79         }
 80 
 81         env->nr_cpus_avail = nr_cpus;
 82         return 0;
 83 }
 84 
 85 void cpu_cache_level__free(struct cpu_cache_level *cache)
 86 {
 87         free(cache->type);
 88         free(cache->map);
 89         free(cache->size);
 90 }
 91 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp