From f31f3a01ccc2e78c49fc8b61a1c95ec94236bfb8 Mon Sep 17 00:00:00 2001 From: Yunfeng Ye Date: Sun, 3 Nov 2019 21:56:53 +0800 Subject: [PATCH] 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 --- classify.c | 2 +- cputree.c | 8 ++++---- irqbalance.h | 2 ++ numa.c | 4 ++-- placement.c | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/classify.c b/classify.c index b999cab..5fb8233 100644 --- a/classify.c +++ b/classify.c @@ -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"); diff --git a/cputree.c b/cputree.c index 6bbc2cb..69f4c6d 100644 --- a/cputree.c +++ b/cputree.c @@ -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; diff --git a/irqbalance.h b/irqbalance.h index 79f5450..61d7550 100644 --- a/irqbalance.h +++ b/irqbalance.h @@ -29,6 +29,8 @@ #include #endif +#define NUMA_NO_NODE (-1) + extern int core_count; extern char *classes[]; diff --git a/numa.c b/numa.c index 9d55784..a2f99e2 100644 --- a/numa.c +++ b/numa.c @@ -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; diff --git a/placement.c b/placement.c index efa8c57..17a9f2e 100644 --- a/placement.c +++ b/placement.c @@ -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