---
name: "hwlocality_linux"
section: "3"
platform: "linux"
package: "hwloc"
version: "2.15.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/hwlocality_linux"
---

# hwlocality\_linux(3)

Linux-specific helpers

## NAME

hwlocality\_linux - Linux-specific helpers

## SYNOPSIS

### Functions

int **hwloc\_linux\_set\_tid\_cpubind** (**hwloc\_topology\_t** topology, pid\_t tid, **hwloc\_const\_cpuset\_t** set)\
 int **hwloc\_linux\_get\_tid\_cpubind** (**hwloc\_topology\_t** topology, pid\_t tid, **hwloc\_cpuset\_t** set)\
 int **hwloc\_linux\_get\_tid\_last\_cpu\_location** (**hwloc\_topology\_t** topology, pid\_t tid, **hwloc\_bitmap\_t** set)\
 int **hwloc\_linux\_read\_path\_as\_cpumask** (const char \*path, **hwloc\_bitmap\_t** set)\

## Detailed Description

This includes helpers for manipulating Linux kernel cpumap files, and hwloc equivalents of the Linux sched\_setaffinity and sched\_getaffinity system calls.

## Function Documentation

### int hwloc\_linux\_get\_tid\_cpubind (hwloc\_topology\_t topology, pid\_t tid, hwloc\_cpuset\_t set)

Get the current binding of thread tid. The CPU-set set (previously allocated by the caller) is filled with the list of PUs which the thread was last bound to.

The behavior is exactly the same as the Linux sched\_getaffinity system call, but uses a hwloc cpuset.

**Returns**

0 on success, -1 on error.

**Note**

This is equivalent to calling **hwloc\_get\_proc\_cpubind()** with **HWLOC\_CPUBIND\_THREAD** as flags.

### int hwloc\_linux\_get\_tid\_last\_cpu\_location (hwloc\_topology\_t topology, pid\_t tid, hwloc\_bitmap\_t set)

Get the last physical CPU where thread tid ran. The CPU-set set (previously allocated by the caller) is filled with the PU which the thread last ran on.

**Returns**

0 on success, -1 on error.

**Note**

This is equivalent to calling **hwloc\_get\_proc\_last\_cpu\_location()** with **HWLOC\_CPUBIND\_THREAD** as flags.

### int hwloc\_linux\_read\_path\_as\_cpumask (const char \* path, hwloc\_bitmap\_t set)

Convert a linux kernel cpumask file path into a hwloc bitmap set. Might be used when reading CPU set from sysfs attributes such as topology and caches for processors, or local\_cpus for devices.

**Returns**

0 on success, -1 on error.

**Note**

This function ignores the HWLOC\_FSROOT environment variable.

### int hwloc\_linux\_set\_tid\_cpubind (hwloc\_topology\_t topology, pid\_t tid, hwloc\_const\_cpuset\_t set)

Bind a thread tid on cpus given in cpuset set. The behavior is exactly the same as the Linux sched\_setaffinity system call, but uses a hwloc cpuset.

**Returns**

0 on success, -1 on error.

**Note**

This is equivalent to calling **hwloc\_set\_proc\_cpubind()** with HWLOC\_CPUBIND\_THREAD as flags.

## Author

Generated automatically by Doxygen for Hardware Locality (hwloc) from the source code.
