Commit 587ba2f4 authored by Neil Horman's avatar Neil Horman

Rename common_obj_data to topo_obj

Since consolodating the topology objects to a single structure, it seems
Better to rename it to something more descriptive
parent decce934
......@@ -55,12 +55,12 @@ cpumask_t cpu_possible_map;
*/
static cpumask_t unbanned_cpus;
static struct common_obj_data* add_cache_domain_to_package(struct common_obj_data *cache,
static struct topo_obj* add_cache_domain_to_package(struct topo_obj *cache,
cpumask_t package_mask)
{
GList *entry;
struct common_obj_data *package;
struct common_obj_data *lcache;
struct topo_obj *package;
struct topo_obj *lcache;
entry = g_list_first(packages);
......@@ -72,7 +72,7 @@ static struct common_obj_data* add_cache_domain_to_package(struct common_obj_dat
}
if (!entry) {
package = calloc(sizeof(struct common_obj_data), 1);
package = calloc(sizeof(struct topo_obj), 1);
if (!package)
return NULL;
package->mask = package_mask;
......@@ -95,12 +95,12 @@ static struct common_obj_data* add_cache_domain_to_package(struct common_obj_dat
return package;
}
static struct common_obj_data* add_cpu_to_cache_domain(struct common_obj_data *cpu,
static struct topo_obj* add_cpu_to_cache_domain(struct topo_obj *cpu,
cpumask_t cache_mask)
{
GList *entry;
struct common_obj_data *cache;
struct common_obj_data *lcpu;
struct topo_obj *cache;
struct topo_obj *lcpu;
entry = g_list_first(cache_domains);
......@@ -112,7 +112,7 @@ static struct common_obj_data* add_cpu_to_cache_domain(struct common_obj_data *c
}
if (!entry) {
cache = calloc(sizeof(struct common_obj_data), 1);
cache = calloc(sizeof(struct topo_obj), 1);
if (!cache)
return NULL;
cache->mask = cache_mask;
......@@ -131,7 +131,7 @@ static struct common_obj_data* add_cpu_to_cache_domain(struct common_obj_data *c
if (!entry) {
cache->children = g_list_append(cache->children, cpu);
cpu->parent = (struct common_obj_data *)cache;
cpu->parent = (struct topo_obj *)cache;
}
return cache;
......@@ -139,12 +139,12 @@ static struct common_obj_data* add_cpu_to_cache_domain(struct common_obj_data *c
static void do_one_cpu(char *path)
{
struct common_obj_data *cpu;
struct topo_obj *cpu;
FILE *file;
char new_path[PATH_MAX];
cpumask_t cache_mask, package_mask;
struct common_obj_data *cache;
struct common_obj_data *package;
struct topo_obj *cache;
struct topo_obj *package;
DIR *dir;
struct dirent *entry;
int nodeid;
......@@ -165,7 +165,7 @@ static void do_one_cpu(char *path)
free(line);
}
cpu = calloc(sizeof(struct common_obj_data), 1);
cpu = calloc(sizeof(struct topo_obj), 1);
if (!cpu)
return;
......@@ -258,26 +258,26 @@ static void dump_irq(struct irq_info *info, void *data)
printf("Interrupt %i node_num is %d (%s/%u) \n", info->irq, irq_numa_node(info)->number, classes[info->class], (unsigned int)info->load);
}
static void dump_common_obj_data(struct common_obj_data *d, void *data __attribute__((unused)))
static void dump_topo_obj(struct topo_obj *d, void *data __attribute__((unused)))
{
struct common_obj_data *c = (struct common_obj_data *)d;
struct topo_obj *c = (struct topo_obj *)d;
printf(" CPU number %i numa_node is %d (load %lu)\n", c->number, cpu_numa_node(c)->number , (unsigned long)c->load);
if (c->interrupts)
for_each_irq(c->interrupts, dump_irq, (void *)18);
}
static void dump_cache_domain(struct common_obj_data *d, void *data)
static void dump_cache_domain(struct topo_obj *d, void *data)
{
char *buffer = data;
cpumask_scnprintf(buffer, 4095, d->mask);
printf(" Cache domain %i: numa_node is %d cpu mask is %s (load %lu) \n", d->number, cache_domain_numa_node(d)->number, buffer, (unsigned long)d->load);
if (d->children)
for_each_cpu_core(d->children, dump_common_obj_data, NULL);
for_each_cpu_core(d->children, dump_topo_obj, NULL);
if (d->interrupts)
for_each_irq(d->interrupts, dump_irq, (void *)10);
}
static void dump_package(struct common_obj_data *d, void *data)
static void dump_package(struct topo_obj *d, void *data)
{
char *buffer = data;
cpumask_scnprintf(buffer, 4096, d->mask);
......@@ -294,25 +294,25 @@ void dump_tree(void)
for_each_package(NULL, dump_package, buffer);
}
static void clear_cpu_stats(struct common_obj_data *d, void *data __attribute__((unused)))
static void clear_cpu_stats(struct topo_obj *d, void *data __attribute__((unused)))
{
struct common_obj_data *c = (struct common_obj_data *)d;
struct topo_obj *c = (struct topo_obj *)d;
c->load = 0;
}
static void clear_cd_stats(struct common_obj_data *d, void *data __attribute__((unused)))
static void clear_cd_stats(struct topo_obj *d, void *data __attribute__((unused)))
{
d->load = 0;
for_each_cpu_core(d->children, clear_cpu_stats, NULL);
}
static void clear_package_stats(struct common_obj_data *d, void *data __attribute__((unused)))
static void clear_package_stats(struct topo_obj *d, void *data __attribute__((unused)))
{
d->load = 0;
for_each_cache_domain(d->children, clear_cd_stats, NULL);
}
static void clear_node_stats(struct common_obj_data *d, void *data __attribute__((unused)))
static void clear_node_stats(struct topo_obj *d, void *data __attribute__((unused)))
{
d->load = 0;
for_each_package(d->children, clear_package_stats, NULL);
......@@ -374,9 +374,9 @@ void parse_cpu_tree(void)
void clear_cpu_tree(void)
{
GList *item;
struct common_obj_data *cpu;
struct common_obj_data *cache_domain;
struct common_obj_data *package;
struct topo_obj *cpu;
struct topo_obj *cache_domain;
struct topo_obj *package;
while (packages) {
item = g_list_first(packages);
......@@ -411,7 +411,7 @@ void clear_cpu_tree(void)
}
void for_each_package(GList *list, void (*cb)(struct common_obj_data *p, void *data), void *data)
void for_each_package(GList *list, void (*cb)(struct topo_obj *p, void *data), void *data)
{
GList *entry = g_list_first(list ? list : packages);
GList *next;
......@@ -423,7 +423,7 @@ void for_each_package(GList *list, void (*cb)(struct common_obj_data *p, void *d
}
}
void for_each_cache_domain(GList *list, void (*cb)(struct common_obj_data *c, void *data), void *data)
void for_each_cache_domain(GList *list, void (*cb)(struct topo_obj *c, void *data), void *data)
{
GList *entry = g_list_first(list ? list : cache_domains);
GList *next;
......@@ -435,7 +435,7 @@ void for_each_cache_domain(GList *list, void (*cb)(struct common_obj_data *c, vo
}
}
void for_each_cpu_core(GList *list, void (*cb)(struct common_obj_data *c, void *data), void *data)
void for_each_cpu_core(GList *list, void (*cb)(struct topo_obj *c, void *data), void *data)
{
GList *entry = g_list_first(list ? list : cpus);
GList *next;
......@@ -449,16 +449,16 @@ void for_each_cpu_core(GList *list, void (*cb)(struct common_obj_data *c, void *
static gint compare_cpus(gconstpointer a, gconstpointer b)
{
const struct common_obj_data *ai = a;
const struct common_obj_data *bi = b;
const struct topo_obj *ai = a;
const struct topo_obj *bi = b;
return ai->number - bi->number;
}
struct common_obj_data *find_cpu_core(int cpunr)
struct topo_obj *find_cpu_core(int cpunr)
{
GList *entry;
struct common_obj_data find;
struct topo_obj find;
find.number = cpunr;
entry = g_list_find_custom(cpus, &find, compare_cpus);
......
......@@ -57,23 +57,23 @@ extern enum hp_e hint_policy;
*/
extern void build_numa_node_list(void);
extern void free_numa_node_list(void);
extern void dump_numa_node_info(struct common_obj_data *node, void *data);
extern void for_each_numa_node(GList *list, void (*cb)(struct common_obj_data *node, void *data), void *data);
extern void add_package_to_node(struct common_obj_data *p, int nodeid);
extern struct common_obj_data *get_numa_node(int nodeid);
extern void dump_numa_node_info(struct topo_obj *node, void *data);
extern void for_each_numa_node(GList *list, void (*cb)(struct topo_obj *node, void *data), void *data);
extern void add_package_to_node(struct topo_obj *p, int nodeid);
extern struct topo_obj *get_numa_node(int nodeid);
/*
* Package functions
*/
#define package_numa_node(p) ((p)->parent)
extern void for_each_package(GList *list, void (*cb)(struct common_obj_data *p, void *data), void *data);
extern void for_each_package(GList *list, void (*cb)(struct topo_obj *p, void *data), void *data);
/*
* cache_domain functions
*/
#define cache_domain_package(c) ((c)->parent)
#define cache_domain_numa_node(c) (package_numa_node(cache_domain_package((c))))
extern void for_each_cache_domain(GList *list, void (*cb)(struct common_obj_data *c, void *data), void *data);
extern void for_each_cache_domain(GList *list, void (*cb)(struct topo_obj *c, void *data), void *data);
/*
* cpu core functions
......@@ -81,8 +81,8 @@ extern void for_each_cache_domain(GList *list, void (*cb)(struct common_obj_data
#define cpu_cache_domain(cpu) ((cpu)->parent)
#define cpu_package(cpu) (cache_domain_package(cpu_cache_domain((cpu))))
#define cpu_numa_node(cpu) (package_numa_node(cache_domain_package(cpu_cache_domain((cpu)))))
extern void for_each_cpu_core(GList *list, void (*cb)(struct common_obj_data *c, void *data), void *data);
extern struct common_obj_data *find_cpu_core(int cpunr);
extern void for_each_cpu_core(GList *list, void (*cb)(struct topo_obj *c, void *data), void *data);
extern struct topo_obj *find_cpu_core(int cpunr);
extern int get_cpu_count(void);
/*
......
......@@ -44,7 +44,7 @@ struct load_balance_info {
long double std_deviation;
};
static void gather_load_stats(struct common_obj_data *obj, void *data)
static void gather_load_stats(struct topo_obj *obj, void *data)
{
struct load_balance_info *info = data;
......@@ -52,7 +52,7 @@ static void gather_load_stats(struct common_obj_data *obj, void *data)
info->load_sources += 1;
}
static void compute_deviations(struct common_obj_data *obj, void *data)
static void compute_deviations(struct topo_obj *obj, void *data)
{
struct load_balance_info *info = data;
unsigned long long int deviation;
......@@ -94,7 +94,7 @@ static void move_candidate_irqs(struct irq_info *info, void *data)
info->assigned_obj = NULL;
}
static void migrate_overloaded_irqs(struct common_obj_data *obj, void *data)
static void migrate_overloaded_irqs(struct topo_obj *obj, void *data)
{
struct load_balance_info *info = data;
int deviation;
......
......@@ -37,7 +37,7 @@
GList *numa_nodes = NULL;
struct common_obj_data unspecified_node = {
struct topo_obj unspecified_node = {
.load = 0,
.number = -1,
.mask = CPU_MASK_ALL,
......@@ -49,13 +49,13 @@ struct common_obj_data unspecified_node = {
static void add_one_node(const char *nodename)
{
char *path = alloca(strlen(SYSFS_NODE_PATH) + strlen(nodename) + 1);
struct common_obj_data *new;
struct topo_obj *new;
char *cpustr;
FILE *f;
if (!path)
return;
new = calloc(1, sizeof(struct common_obj_data));
new = calloc(1, sizeof(struct topo_obj));
if (!new)
return;
sprintf(path, "%s/%s/cpumap", SYSFS_NODE_PATH, nodename);
......@@ -104,15 +104,15 @@ void free_numa_node_list(void)
static gint compare_node(gconstpointer a, gconstpointer b)
{
const struct common_obj_data *ai = a;
const struct common_obj_data *bi = b;
const struct topo_obj *ai = a;
const struct topo_obj *bi = b;
return (ai->number == bi->number) ? 0 : 1;
}
void add_package_to_node(struct common_obj_data *p, int nodeid)
void add_package_to_node(struct topo_obj *p, int nodeid)
{
struct common_obj_data find, *node;
struct topo_obj find, *node;
find.number = nodeid;
GList *entry;
......@@ -131,7 +131,7 @@ void add_package_to_node(struct common_obj_data *p, int nodeid)
p->parent = node;
}
void dump_numa_node_info(struct common_obj_data *d, void *unused __attribute__((unused)))
void dump_numa_node_info(struct topo_obj *d, void *unused __attribute__((unused)))
{
char buffer[4096];
......@@ -141,7 +141,7 @@ void dump_numa_node_info(struct common_obj_data *d, void *unused __attribute__((
printf("\n");
}
void for_each_numa_node(GList *list, void(*cb)(struct common_obj_data *node, void *data), void *data)
void for_each_numa_node(GList *list, void(*cb)(struct topo_obj *node, void *data), void *data)
{
GList *entry, *next;
......@@ -154,9 +154,9 @@ void for_each_numa_node(GList *list, void(*cb)(struct common_obj_data *node, voi
}
}
struct common_obj_data *get_numa_node(int nodeid)
struct topo_obj *get_numa_node(int nodeid)
{
struct common_obj_data find;
struct topo_obj find;
GList *entry;
if (nodeid == -1)
......
......@@ -33,13 +33,13 @@ int power_mode;
GList *rebalance_irq_list;
struct obj_placement {
struct common_obj_data *best;
struct common_obj_data *least_irqs;
struct topo_obj *best;
struct topo_obj *least_irqs;
uint64_t best_cost;
struct irq_info *info;
};
static void find_best_object(struct common_obj_data *d, void *data)
static void find_best_object(struct topo_obj *d, void *data)
{
struct obj_placement *best = (struct obj_placement *)data;
uint64_t newload;
......@@ -73,9 +73,9 @@ static void find_best_object(struct common_obj_data *d, void *data)
static void place_irq_in_cache_domain(struct irq_info *info, void *data)
{
struct common_obj_data *p = data;
struct topo_obj *p = data;
struct obj_placement place;
struct common_obj_data *asign;
struct topo_obj *asign;
if (!info->moved)
return;
......@@ -100,7 +100,7 @@ static void place_irq_in_cache_domain(struct irq_info *info, void *data)
}
static void place_cache_domain(struct common_obj_data *d, void *data __attribute__((unused)))
static void place_cache_domain(struct topo_obj *d, void *data __attribute__((unused)))
{
if (d->interrupts)
for_each_irq(d->interrupts, place_irq_in_cache_domain, d);
......@@ -108,9 +108,9 @@ static void place_cache_domain(struct common_obj_data *d, void *data __attribute
static void place_core(struct irq_info *info, void *data)
{
struct common_obj_data *c = data;
struct topo_obj *c = data;
struct obj_placement place;
struct common_obj_data *asign;
struct topo_obj *asign;
if (!info->moved)
return;
......@@ -136,7 +136,7 @@ static void place_core(struct irq_info *info, void *data)
}
static void place_cores(struct common_obj_data *d, void *data __attribute__((unused)))
static void place_cores(struct topo_obj *d, void *data __attribute__((unused)))
{
if (d->interrupts)
for_each_irq(d->interrupts, place_core, d);
......@@ -145,8 +145,8 @@ static void place_cores(struct common_obj_data *d, void *data __attribute__((unu
static void place_irq_in_package(struct irq_info *info, void *data)
{
struct obj_placement place;
struct common_obj_data *n = data;
struct common_obj_data *asign;
struct topo_obj *n = data;
struct topo_obj *asign;
if (!info->moved)
return;
......@@ -170,7 +170,7 @@ static void place_irq_in_package(struct irq_info *info, void *data)
}
}
static void place_packages(struct common_obj_data *d, void *data __attribute__((unused)))
static void place_packages(struct topo_obj *d, void *data __attribute__((unused)))
{
if (d->interrupts)
for_each_irq(d->interrupts, place_irq_in_package, d);
......@@ -179,7 +179,7 @@ static void place_packages(struct common_obj_data *d, void *data __attribute__((
static void place_irq_in_node(struct irq_info *info, void *data __attribute__((unused)))
{
struct obj_placement place;
struct common_obj_data *asign;
struct topo_obj *asign;
if( info->level == BALANCE_NONE)
return;
......@@ -190,7 +190,7 @@ static void place_irq_in_node(struct irq_info *info, void *data __attribute__((u
* put it on that node
*/
migrate_irq(&rebalance_irq_list, &irq_numa_node(info)->interrupts, info);
info->assigned_obj = (struct common_obj_data *)irq_numa_node(info);
info->assigned_obj = (struct topo_obj *)irq_numa_node(info);
irq_numa_node(info)->load += info->load + 1;
return;
}
......@@ -218,7 +218,7 @@ static void validate_irq(struct irq_info *info, void *data)
info->irq, info->assigned_obj, data);
}
static void validate_object(struct common_obj_data *d, void *data __attribute__((unused)))
static void validate_object(struct topo_obj *d, void *data __attribute__((unused)))
{
if (d->interrupts)
for_each_irq(d->interrupts, validate_irq, d);
......
......@@ -128,7 +128,7 @@ static void assign_load_slice(struct irq_info *info, void *data)
info->load = (info->irq_count - info->last_irq_count) * *load_slice;
}
static void compute_irq_load_share(struct common_obj_data *d, void *data __attribute__((unused)))
static void compute_irq_load_share(struct topo_obj *d, void *data __attribute__((unused)))
{
uint64_t total_irq_counts = 0;
uint64_t load_slice;
......@@ -146,7 +146,7 @@ void parse_proc_stat()
char *line = NULL;
size_t size = 0;
int cpunr, rc, cpucount;
struct common_obj_data *cpu;
struct topo_obj *cpu;
int irq_load, softirq_load;
file = fopen("/proc/stat", "r");
......
......@@ -26,12 +26,12 @@
#define IRQ_TYPE_MSI 1
#define IRQ_TYPE_MSIX 2
struct common_obj_data {
struct topo_obj {
uint64_t load;
int number;
cpumask_t mask;
GList *interrupts;
struct common_obj_data *parent;
struct topo_obj *parent;
GList *children;
};
......@@ -40,14 +40,14 @@ struct irq_info {
int class;
int type;
int level;
struct common_obj_data *numa_node;
struct topo_obj *numa_node;
cpumask_t cpumask;
cpumask_t affinity_hint;
uint64_t irq_count;
uint64_t last_irq_count;
uint64_t load;
int moved;
struct common_obj_data *assigned_obj;
struct topo_obj *assigned_obj;
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment