Skip to content

numa_preferred returns unexpected result #19

@angainor

Description

@angainor

On two systems I tested, numa_preferred always returns 0 if not explicitly initialized. That means that even when I start a process explicitly on some processor on NUMA node ~= 0, using the default memory allocation policy (local alloc), numa_preferred will return 0. The memory will be allocated correctly on the local numa node.

https://gist.github.com/angainor/d09c367631880ae99e1acf7f6653128b

I suggest we add the following function to numa_tools:

numa_tools::index_type
numa_tools::local_node() const noexcept
{
    return numa_node_of_cpu(sched_getcpu());
}

While this will not return the preferred node, it will return the thread-local node id, which is often what we want.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions