Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 336755
b: refs/heads/master
c: 35a1697
h: refs/heads/master
i:
  336753: cb7412c
  336751: b6d00b6
v: v3
  • Loading branch information
Palmer Cox authored and Rafael J. Wysocki committed Nov 27, 2012
1 parent 9bf2b34 commit d5ae0e5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 53d2000ebe0618219f73ac866701533237180044
refs/heads/master: 35a169737cdf9155e890d60eae2b8fffc16d16ba
17 changes: 9 additions & 8 deletions trunk/tools/power/cpupower/utils/helpers/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ extern int get_cpu_info(unsigned int cpu, struct cpupower_cpu_info *cpu_info);
extern struct cpupower_cpu_info cpupower_cpu_info;
/* cpuid and cpuinfo helpers **************************/

struct cpuid_core_info {
int pkg;
int core;
int cpu;

/* flags */
unsigned int is_online:1;
};

/* CPU topology/hierarchy parsing ******************/
struct cpupower_topology {
Expand All @@ -101,14 +109,7 @@ struct cpupower_topology {
unsigned int threads; /* per core */

/* Array gets mallocated with cores entries, holding per core info */
struct {
int pkg;
int core;
int cpu;

/* flags */
unsigned int is_online:1;
} *core_info;
struct cpuid_core_info *core_info;
};

extern int get_cpu_topology(struct cpupower_topology *cpu_top);
Expand Down
14 changes: 3 additions & 11 deletions trunk/tools/power/cpupower/utils/helpers/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ static int sysfs_topology_read_file(unsigned int cpu, const char *fname, int *re
return 0;
}

struct cpuid_core_info {
unsigned int pkg;
unsigned int thread;
unsigned int cpu;
/* flags */
unsigned int is_online:1;
};

static int __compare(const void *t1, const void *t2)
{
struct cpuid_core_info *top1 = (struct cpuid_core_info *)t1;
Expand All @@ -52,9 +44,9 @@ static int __compare(const void *t1, const void *t2)
return -1;
else if (top1->pkg > top2->pkg)
return 1;
else if (top1->thread < top2->thread)
else if (top1->core < top2->core)
return -1;
else if (top1->thread > top2->thread)
else if (top1->core > top2->core)
return 1;
else if (top1->cpu < top2->cpu)
return -1;
Expand All @@ -74,7 +66,7 @@ int get_cpu_topology(struct cpupower_topology *cpu_top)
{
int cpu, cpus = sysconf(_SC_NPROCESSORS_CONF);

cpu_top->core_info = malloc(sizeof(struct cpupower_topology) * cpus);
cpu_top->core_info = malloc(sizeof(struct cpuid_core_info) * cpus);
if (cpu_top->core_info == NULL)
return -ENOMEM;
cpu_top->pkgs = cpu_top->cores = 0;
Expand Down

0 comments on commit d5ae0e5

Please sign in to comment.