diff options
author | Daniele Di Proietto <diproiettod@vmware.com> | 2016-11-29 14:51:03 -0800 |
---|---|---|
committer | Daniele Di Proietto <diproiettod@vmware.com> | 2017-01-15 19:25:12 -0800 |
commit | 0900ca8e6447baa0c06ccbe25fa1948f88224948 (patch) | |
tree | 7587e0250fb09537c7341a6ac1f4a5f336e4f817 | |
parent | dbedeb9dd4cc799a2f2097457f73e7f1922bc8a4 (diff) | |
download | openvswitch-0900ca8e6447baa0c06ccbe25fa1948f88224948.tar.gz |
ovs-numa: Don't use hmap_first_with_hash().
I think it's better to iterate the hmap than to use
hmap_first_with_hash(), because it handles hash collisions.
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: Ilya Maximets <i.maximets@samsung.com>
-rw-r--r-- | lib/ovs-numa.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/ovs-numa.c b/lib/ovs-numa.c index 7d34c6744..785987ced 100644 --- a/lib/ovs-numa.c +++ b/lib/ovs-numa.c @@ -242,30 +242,32 @@ discover_numa_and_core(void) static struct cpu_core* get_core_by_core_id(unsigned core_id) { - struct cpu_core *core = NULL; + struct cpu_core *core; - if (ovs_numa_core_id_is_valid(core_id)) { - core = CONTAINER_OF(hmap_first_with_hash(&all_cpu_cores, - hash_int(core_id, 0)), - struct cpu_core, hmap_node); + HMAP_FOR_EACH_WITH_HASH (core, hmap_node, hash_int(core_id, 0), + &all_cpu_cores) { + if (core->core_id == core_id) { + return core; + } } - return core; + return NULL; } /* Gets 'struct numa_node' by 'numa_id'. */ static struct numa_node* get_numa_by_numa_id(int numa_id) { - struct numa_node *numa = NULL; + struct numa_node *numa; - if (ovs_numa_numa_id_is_valid(numa_id)) { - numa = CONTAINER_OF(hmap_first_with_hash(&all_numa_nodes, - hash_int(numa_id, 0)), - struct numa_node, hmap_node); + HMAP_FOR_EACH_WITH_HASH (numa, hmap_node, hash_int(numa_id, 0), + &all_numa_nodes) { + if (numa->numa_id == numa_id) { + return numa; + } } - return numa; + return NULL; } |