irqbalance: use NUMA_NO_NODE macro instead of -1 for numa

node id -1 is stand for no specific numa, and is used in many place, so
using NUMA_NO_NODE macro instead is better readability.

Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
This commit is contained in:
Yunfeng Ye 2019-11-03 21:56:53 +08:00
parent b159851da0
commit f31f3a01cc
5 changed files with 11 additions and 9 deletions

View file

@ -391,7 +391,7 @@ static struct irq_info *add_one_irq_to_db(const char *devpath, struct irq_info *
new->level = map_class_to_level[new->class];
get_numa_node:
numa_node = -1;
numa_node = NUMA_NO_NODE;
if (devpath != NULL && numa_avail) {
sprintf(path, "%s/numa_node", devpath);
fd = fopen(path, "r");

View file

@ -138,7 +138,7 @@ static void add_numa_node_to_topo_obj(struct topo_obj *obj, int nodeid)
struct topo_obj *node;
node = get_numa_node(nodeid);
if (!node || (numa_avail && (node->number == -1)))
if (!node || (numa_avail && (node->number == NUMA_NO_NODE)))
return;
entry = g_list_find(obj->numa_nodes, node);
@ -193,7 +193,7 @@ static struct topo_obj* add_cache_domain_to_package(struct topo_obj *cache,
cache->parent = package;
}
if (!numa_avail || (nodeid > -1))
if (!numa_avail || (nodeid > NUMA_NO_NODE))
add_numa_node_to_topo_obj(package, nodeid);
return package;
@ -234,7 +234,7 @@ static struct topo_obj* add_cpu_to_cache_domain(struct topo_obj *cpu,
cpu->parent = (struct topo_obj *)cache;
}
if (!numa_avail || (nodeid > -1))
if (!numa_avail || (nodeid > NUMA_NO_NODE))
add_numa_node_to_topo_obj(cache, nodeid);
return cache;
@ -340,7 +340,7 @@ static void do_one_cpu(char *path)
process_one_line(new_path, get_mask_from_bitmap, &cache_mask);
}
nodeid=-1;
nodeid = NUMA_NO_NODE;
if (numa_avail) {
struct topo_obj *node;

View file

@ -29,6 +29,8 @@
#include <systemd/sd-journal.h>
#endif
#define NUMA_NO_NODE (-1)
extern int core_count;
extern char *classes[];

4
numa.c
View file

@ -41,7 +41,7 @@ GList *numa_nodes = NULL;
static struct topo_obj unspecified_node_template = {
.load = 0,
.number = -1,
.number = NUMA_NO_NODE,
.obj_type = OBJ_TYPE_NODE,
.mask = CPU_MASK_ALL,
.interrupts = NULL,
@ -178,7 +178,7 @@ struct topo_obj *get_numa_node(int nodeid)
if (!numa_avail)
return &unspecified_node;
if (nodeid == -1)
if (nodeid == NUMA_NO_NODE)
return &unspecified_node;
find.number = nodeid;

View file

@ -45,7 +45,7 @@ static void find_best_object(struct topo_obj *d, void *data)
/*
* Don't consider the unspecified numa node here
*/
if (numa_avail && (d->obj_type == OBJ_TYPE_NODE) && (d->number == -1))
if (numa_avail && (d->obj_type == OBJ_TYPE_NODE) && (d->number == NUMA_NO_NODE))
return;
/*
@ -130,7 +130,7 @@ static void place_irq_in_node(struct irq_info *info, void *data __attribute__((u
if ((info->level == BALANCE_NONE) && cpus_empty(banned_cpus))
return;
if (irq_numa_node(info)->number != -1 || !numa_avail) {
if (irq_numa_node(info)->number != NUMA_NO_NODE || !numa_avail) {
/*
* Need to make sure this node is elligible for migration
* given the banned cpu list