freebsd-src/lib/libutil/cpuset.3
Bojan Novković aae23170c8 libutil: Move cpuset(1) domain policy parsing code into libutil
cpuset(1) implements a domainset(9) policy parser that is used to
translate a <policy>:<domain_list> string into a domainset_t mask
and a valid domainset policy. This change moves the domainset parsing
code into a new cpuset.c function - 'domainset_parselist'.

The existing cpuset.c code was refactored into a generalized list
parsing function which is now used to parse both CPU sets and domain
sets. This is the same approach used in cpuset(1).

Reviewed by:	markj, ziaee (manpages)
Differential Revision:	https://reviews.freebsd.org/D46607
2025-07-27 18:31:48 +02:00

111 lines
3 KiB
Groff

.\" Copyright (c) 2017 Baptiste Daroussin <bapt@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd June 24, 2025
.Dt CPUSET 3
.Os
.Sh NAME
.Nm cpuset_parselist ,
.Nm domainset_parselist
.Nd utility functions for cpuset(2) handling
.Sh LIBRARY
.Lb libutil
.Sh SYNOPSIS
.In sys/cpuset.h
.In libutil.h
.Ft int
.Fn cpuset_parselist "const char *cpu_list" "cpuset_t *mask"
.Ft int
.Fn domainset_parselist "const char *domain_policy" "domainset_t *domain_mask" "int *policyp"
.Sh DESCRIPTION
The
.Fn cpuset_parselist
function parses a
.Va cpu-list
filling the
.Va mask .
.Pp
The
.Va cpu-list
may include numbers separated by '-' for ranges and commas separating individual
numbers.
A special list of
.Dq all
may be specified in which case the list includes all CPUs from the root set.
.Pp
The
.Fn domainset_parselist
function parses a
.Xr domainset 9
memory domain allocation policy
specified by
.Va domain_policy
filling the
.Va domain_mask
and the
.Va policyp .
A valid
.Va domain_policy
is formatted as
.Ar policy:domain-list .
See the
.Ar -n
flag in
.Xr cpuset 1
for a list of valid domain policies.
.Sh RETURN VALUES
Return values can be the following
.Bl -tag -width Er
.It Dv CPUSET_PARSE_OK
The parsing was successful
.It Dv CPUSET_PARSE_ERROR
The
.Va cpu-list
or
.Va domain-policy
format is invalid
.It Dv CPUSET_PARSE_GETAFFINITY
The
.Xr cpuset_getaffinity 2
call has failed
.It Dv CPUSET_PARSE_INVALID_CPU
The number of supported CPUs or NUMA domains has been exceeded.
The maximum number being
.Va CPU_SETSIZE
and
.Va DOMAINSET_SETSIZE
respectively.
.It Dv CPUSET_PARSE_GETDOMAIN
The
.Xr cpuset_getdomain 2
call has failed
.El
.Sh SEE ALSO
.Xr cpuset 1 ,
.Xr cpuset 2 ,
.Xr numa 4 ,
.Xr cpuset 9 ,
.Xr domainset 9
.Sh AUTHORS
.An Jeffrey Roberson Aq Mt jeff@FreeBSD.org