tracefs_instance_get_affinity_raw - Sets or retrieves the
affinity for an instance or top level for what CPUs enable
These functions set or retrieve the CPU affinity that limits what
CPUs will have tracing enabled for a given instance defined by
the instance parameter. If instance is NULL, then the top level
instance is affected.
The tracefs_instance_set_affinity() function takes a string
cpu_str that is a list of CPUs to set the affinity for. If
cpu_str is NULL, then all the CPUs in the system will be set. The
format of cpu_str is a comma delimited string of decimal numbers
with no spaces. A range may be specified by a hyphen.
For example: "1,4,6-8"
The numbers do not need to be in order except for ranges, where
the second number must be equal to or greater than the first.
The tracefs_instance_set_affinity_set() function takes a CPU set
defined by CPU_SET(3). The size of the set defined by set_size is
the size in bytes of set. If set is NULL then all the CPUs on the
system will be set, and set_size is ignored.
The tracefs_instance_set_affinity_raw() function takes a string
that holds a hexidecimal bitmask, where each 32 bits is separated
by a comma. For a machine with more that 32 CPUs, to set CPUS
1-10 and CPU 40:
Where the above is a hex representation of bits 1-10 and bit 40
The tracefs_instance_get_affinity() will retrieve the affinity in
a human readable form.
For example: "1,4,6-8"
The string returned must be freed with free(3).
The tracefs_instance_get_affinity_set() will set all the bits in
the passed in cpu set (from CPU_SET(3)). Note it will not clear
any bits that are already set in the set but the CPUs are not. If
only the bits for the CPUs that are enabled should be set, a
CPU_ZERO_S() should be performed on the set before calling this
The tracefs_instance_get_affinity_raw() will simply read the
instance tracing_cpumask and return that string. The returned
string must be freed with free(3).
All the set functions return 0 on success and -1 on error.
The functions tracefs_instance_get_affinity() and
tracefs_instance_get_affinity_raw() returns an allocated string
that must be freed with free(3), or NULL on error.
The function tracefs_instance_get_affinity_set() returns the
number of CPUs that were found set, or -1 on error.
The following errors are for all the above calls:
EFBIG if a CPU is set that is greater than what is in the system.
EINVAL One of the parameters was invalid.
The following errors are for tracefs_instance_set_affinity() and
ENOMEM Memory allocation error.
ENODEV dynamic events of requested type are not configured for
the running kernel.
The following errors are just for tracefs_instance_set_affinity()
EACCES The cpu_str was modified by another thread when processing
This page is part of the libtracefs (Linux kernel trace file
system library) project. Information about the project can be
found at ⟨https://www.trace-cmd.org/⟩. If you have a bug report
for this manual page, see ⟨https://www.trace-cmd.org/⟩. This
page was obtained from the project's upstream Git repository
2023-12-22. (At that time, the date of the most recent commit
that was found in the repository was 2023-07-05.) If you
discover any rendering problems in this HTML version of the page,
or you believe there is a better or more up-to-date source for
the page, or you have corrections or improvements to the
information in this COLOPHON (which is not part of the original
manual page), send a mail to email@example.com
libtracefs 1.7.0 12/22/2023 LIBTRACEFS(3)