136 lines
3.6 KiB
Diff
136 lines
3.6 KiB
Diff
From 82f05296c7b8e53791047fb1668d4f41149c91d8 Mon Sep 17 00:00:00 2001
|
|
From: Yunfeng Ye <yeyunfeng@huawei.com>
|
|
Date: Wed, 30 Oct 2019 19:55:18 +0800
|
|
Subject: [PATCH 35/53] irqbalance: use g_list_find() instead of the search
|
|
logic for cpu_topo
|
|
|
|
There are some search logic of list can be replaced by g_list_find(),
|
|
which can make the code more simpler. the list to be search is start
|
|
from head, so remove g_list_first().
|
|
|
|
Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
|
|
---
|
|
cputree.c | 40 ++++------------------------------------
|
|
numa.c | 10 +---------
|
|
2 files changed, 5 insertions(+), 45 deletions(-)
|
|
|
|
diff --git a/cputree.c b/cputree.c
|
|
index 97d4a78..c1b4950 100644
|
|
--- a/cputree.c
|
|
+++ b/cputree.c
|
|
@@ -136,33 +136,17 @@ static void add_numa_node_to_topo_obj(struct topo_obj *obj, int nodeid)
|
|
{
|
|
GList *entry;
|
|
struct topo_obj *node;
|
|
- struct topo_obj *cand_node;
|
|
- struct topo_obj *package;
|
|
|
|
node = get_numa_node(nodeid);
|
|
if (!node || (numa_avail && (node->number == -1)))
|
|
return;
|
|
|
|
- entry = g_list_first(obj->numa_nodes);
|
|
- while (entry) {
|
|
- cand_node = entry->data;
|
|
- if (cand_node == node)
|
|
- break;
|
|
- entry = g_list_next(entry);
|
|
- }
|
|
-
|
|
+ entry = g_list_find(obj->numa_nodes, node);
|
|
if (!entry)
|
|
obj->numa_nodes = g_list_append(obj->numa_nodes, node);
|
|
|
|
if (!numa_avail && obj->obj_type == OBJ_TYPE_PACKAGE) {
|
|
- entry = g_list_first(node->children);
|
|
- while (entry) {
|
|
- package = entry->data;
|
|
- if (package == obj)
|
|
- break;
|
|
- entry = g_list_next(entry);
|
|
- }
|
|
-
|
|
+ entry = g_list_find(node->children, obj);
|
|
if (!entry) {
|
|
node->children = g_list_append(node->children, obj);
|
|
obj->parent = node;
|
|
@@ -177,7 +161,6 @@ static struct topo_obj* add_cache_domain_to_package(struct topo_obj *cache,
|
|
{
|
|
GList *entry;
|
|
struct topo_obj *package;
|
|
- struct topo_obj *lcache;
|
|
|
|
entry = g_list_first(packages);
|
|
|
|
@@ -202,14 +185,7 @@ static struct topo_obj* add_cache_domain_to_package(struct topo_obj *cache,
|
|
packages = g_list_append(packages, package);
|
|
}
|
|
|
|
- entry = g_list_first(package->children);
|
|
- while (entry) {
|
|
- lcache = entry->data;
|
|
- if (lcache == cache)
|
|
- break;
|
|
- entry = g_list_next(entry);
|
|
- }
|
|
-
|
|
+ entry = g_list_find(package->children, cache);
|
|
if (!entry) {
|
|
package->children = g_list_append(package->children, cache);
|
|
cache->parent = package;
|
|
@@ -226,7 +202,6 @@ static struct topo_obj* add_cpu_to_cache_domain(struct topo_obj *cpu,
|
|
{
|
|
GList *entry;
|
|
struct topo_obj *cache;
|
|
- struct topo_obj *lcpu;
|
|
|
|
entry = g_list_first(cache_domains);
|
|
|
|
@@ -249,14 +224,7 @@ static struct topo_obj* add_cpu_to_cache_domain(struct topo_obj *cpu,
|
|
cache_domain_count++;
|
|
}
|
|
|
|
- entry = g_list_first(cache->children);
|
|
- while (entry) {
|
|
- lcpu = entry->data;
|
|
- if (lcpu == cpu)
|
|
- break;
|
|
- entry = g_list_next(entry);
|
|
- }
|
|
-
|
|
+ entry = g_list_find(cache->children, cpu);
|
|
if (!entry) {
|
|
cache->children = g_list_append(cache->children, cpu);
|
|
cpu->parent = (struct topo_obj *)cache;
|
|
diff --git a/numa.c b/numa.c
|
|
index f1284da..e76b6e0 100644
|
|
--- a/numa.c
|
|
+++ b/numa.c
|
|
@@ -136,7 +136,6 @@ void connect_cpu_mem_topo(struct topo_obj *p, void *data __attribute__((unused))
|
|
{
|
|
GList *entry;
|
|
struct topo_obj *node;
|
|
- struct topo_obj *lchild;
|
|
int len;
|
|
|
|
len = g_list_length(p->numa_nodes);
|
|
@@ -154,14 +153,7 @@ void connect_cpu_mem_topo(struct topo_obj *p, void *data __attribute__((unused))
|
|
if (p->obj_type == OBJ_TYPE_PACKAGE && !p->parent)
|
|
p->parent = node;
|
|
|
|
- entry = g_list_first(node->children);
|
|
- while (entry) {
|
|
- lchild = entry->data;
|
|
- if (lchild == p)
|
|
- break;
|
|
- entry = g_list_next(entry);
|
|
- }
|
|
-
|
|
+ entry = g_list_find(node->children, p);
|
|
if (!entry)
|
|
node->children = g_list_append(node->children, p);
|
|
}
|
|
--
|
|
2.23.0
|
|
|