Skip to content

Commit

Permalink
ovs-numa: Don't use hmap_first_with_hash().
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ddiproietto committed Jan 16, 2017
1 parent dbedeb9 commit 0900ca8
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions lib/ovs-numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down

0 comments on commit 0900ca8

Please sign in to comment.