xref: /freebsd/share/man/man9/domainset.9 (revision 9978bd996b69dc6b320efce25e9d42dbdb25ac8c)
1e5818a53SJeff Roberson.\" Copyright (c) 2018 Jeffrey Roberson <jeff@FreeBSD.org>
2e5818a53SJeff Roberson.\" All rights reserved.
3e5818a53SJeff Roberson.\"
4e5818a53SJeff Roberson.\" Redistribution and use in source and binary forms, with or without
5e5818a53SJeff Roberson.\" modification, are permitted provided that the following conditions
6e5818a53SJeff Roberson.\" are met:
7e5818a53SJeff Roberson.\" 1. Redistributions of source code must retain the above copyright
8e5818a53SJeff Roberson.\"    notice, this list of conditions and the following disclaimer.
9e5818a53SJeff Roberson.\" 2. Redistributions in binary form must reproduce the above copyright
10e5818a53SJeff Roberson.\"    notice, this list of conditions and the following disclaimer in the
11e5818a53SJeff Roberson.\"    documentation and/or other materials provided with the distribution.
12e5818a53SJeff Roberson.\"
13e5818a53SJeff Roberson.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
14e5818a53SJeff Roberson.\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
15e5818a53SJeff Roberson.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16e5818a53SJeff Roberson.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
17e5818a53SJeff Roberson.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18e5818a53SJeff Roberson.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19e5818a53SJeff Roberson.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20e5818a53SJeff Roberson.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21e5818a53SJeff Roberson.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22e5818a53SJeff Roberson.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23e5818a53SJeff Roberson.\" POSSIBILITY OF SUCH DAMAGE.
24e5818a53SJeff Roberson.\"
25e5818a53SJeff Roberson.\" $FreeBSD$
26e5818a53SJeff Roberson.\"
27*9978bd99SMark Johnston.Dd October 30, 2018
28e5818a53SJeff Roberson.Dt DOMAINSET 9
29e5818a53SJeff Roberson.Os
30e5818a53SJeff Roberson.Sh NAME
31e5818a53SJeff Roberson.Nm domainset(9)
32e5818a53SJeff Roberson.Nd domainset functions and operation
33e5818a53SJeff Roberson.Sh SYNOPSIS
34e5818a53SJeff Roberson.In sys/_domainset.h
35e5818a53SJeff Roberson.In sys/domainset.h
36e5818a53SJeff Roberson.\"
37e5818a53SJeff Roberson.Bd -literal -offset indent
38e5818a53SJeff Robersonstruct domainset {
39e5818a53SJeff Roberson        domainset_t     ds_mask;
40e5818a53SJeff Roberson        uint16_t        ds_policy;
41e5818a53SJeff Roberson        domainid_t      ds_prefer;
42e5818a53SJeff Roberson	...
43e5818a53SJeff Roberson};
44e5818a53SJeff Roberson.Ed
45e5818a53SJeff Roberson.Pp
46*9978bd99SMark Johnston.Ft struct domainset *
47*9978bd99SMark Johnston.Fn DOMAINSET_FIXED domain
48*9978bd99SMark Johnston.Ft struct domainset *
49662e7fa8SMark Johnston.Fn DOMAINSET_RR
50*9978bd99SMark Johnston.Ft struct domainset *
51662e7fa8SMark Johnston.Fn DOMAINSET_PREF domain
52e5818a53SJeff Roberson.Ft struct domainset *
53e5818a53SJeff Roberson.Fn domainset_create "const struct domainset *key"
54e5818a53SJeff Roberson.Ft int
55e5818a53SJeff Roberson.Fn sysctl_handle_domainset "SYSCTL_HANDLER_ARGS"
56e5818a53SJeff Roberson.Sh DESCRIPTION
57e5818a53SJeff RobersonThe
58e5818a53SJeff Roberson.Nm
59e5818a53SJeff RobersonAPI provides memory domain allocation policy for NUMA machines.
60e5818a53SJeff RobersonEach
61e5818a53SJeff Roberson.Vt domainset
62e5818a53SJeff Robersoncontains a bitmask of allowed domains, an integer policy, and an optional
63e5818a53SJeff Robersonpreferred domain.
64e5818a53SJeff RobersonTogether, these specify a search order for memory allocations as well as
65e5818a53SJeff Robersonthe ability to restrict threads and objects to a subset of available
66e5818a53SJeff Robersonmemory domains for system partitioning and resource management.
67e5818a53SJeff Roberson.Pp
68e5818a53SJeff RobersonEvery thread in the system and optionally every
69e5818a53SJeff Roberson.Vt vm_object_t ,
70e5818a53SJeff Robersonwhich is used to represent files and other memory sources, has
71e5818a53SJeff Robersona reference to a
72e5818a53SJeff Roberson.Vt struct domainset .
73e5818a53SJeff RobersonThe domainset associated with the object is consulted first and the system
74e5818a53SJeff Robersonfalls back to the thread policy if none exists.
75e5818a53SJeff Roberson.Pp
76e5818a53SJeff RobersonThe allocation policy has the following possible values:
77e5818a53SJeff Roberson.Bl -tag -width "foo"
78e5818a53SJeff Roberson.It Dv DOMAINSET_POLICY_ROUNDROBIN
79e5818a53SJeff RobersonMemory is allocated from each domain in the mask in a round-robin fashion.
80e5818a53SJeff RobersonThis distributes bandwidth evenly among available domains.
81e5818a53SJeff RobersonThis policy can specify a single domain for a fixed allocation.
82e5818a53SJeff Roberson.It Dv DOMAINSET_POLICY_FIRSTTOUCH
83e5818a53SJeff RobersonMemory is allocated from the node that it is first accessed on.
84e5818a53SJeff RobersonAllocation falls back to round-robin if the current domain is not in the
85e5818a53SJeff Robersonallowed set or is out of memory.
86e5818a53SJeff RobersonThis policy optimizes for locality but may give pessimal results if the
87e5818a53SJeff Robersonmemory is accessed from many CPUs that are not in the local domain.
88e5818a53SJeff Roberson.It Dv DOMAINSET_POLICY_PREFER
89e5818a53SJeff RobersonMemory is allocated from the node in the
90e5818a53SJeff Roberson.Vt prefer
91e5818a53SJeff Robersonmember.  The preferred node must be set in the allowed mask.
92e5818a53SJeff RobersonIf the preferred node is out of memory the allocation falls back to
93e5818a53SJeff Robersonround-robin among allowed sets.
94e5818a53SJeff Roberson.It Dv DOMAINSET_POLICY_INTERLEAVE
95e5818a53SJeff RobersonMemory is allocated in a striped fashion with multiple pages
96e5818a53SJeff Robersonallocated to each domain in the set according to the offset within
97e5818a53SJeff Robersonthe object.
98e5818a53SJeff RobersonThe strip width is object dependent and may be as large as a
99e5818a53SJeff Robersonsuper-page (2MB on amd64).
100e5818a53SJeff RobersonThis gives good distribution among memory domains while keeping system
101e5818a53SJeff Robersonefficiency higher and is preferential to round-robin for general use.
102e5818a53SJeff Roberson.El
103e5818a53SJeff Roberson.Pp
104e5818a53SJeff RobersonThe
105*9978bd99SMark Johnston.Fn DOMAINSET_FIXED ,
106662e7fa8SMark Johnston.Fn DOMAINSET_RR
107662e7fa8SMark Johnstonand
108662e7fa8SMark Johnston.Fn DOMAINSET_PREF
109*9978bd99SMark Johnstonmacros provide pointers to global pre-defined policies for use when the
110662e7fa8SMark Johnstondesired policy is known at compile time.
111*9978bd99SMark Johnston.Fn DOMAINSET_FIXED
112*9978bd99SMark Johnstonis a policy which only permits allocations from the specified domain.
113*9978bd99SMark Johnston.Fn DOMAINSET_RR
114*9978bd99SMark Johnstonprovides round-robin selection among all domains in the system.
115*9978bd99SMark JohnstonThe
116*9978bd99SMark Johnston.Fn DOMAINSET_PREF
117*9978bd99SMark Johnstonpolicies attempt allocation from the specified domain, but unlike
118*9978bd99SMark Johnston.Fn DOMAINSET_FIXED
119*9978bd99SMark Johnstonwill fall back to other domains to satisfy the request.
120*9978bd99SMark JohnstonThese policies should be used in preference to
121*9978bd99SMark Johnston.Fn DOMAINSET_FIXED
122*9978bd99SMark Johnstonto avoid blocking indefinitely on a
123*9978bd99SMark Johnston.Dv M_WAITOK
124*9978bd99SMark Johnstonrequest.
125662e7fa8SMark JohnstonThe
126e5818a53SJeff Roberson.Fn domainset_create
127e5818a53SJeff Robersonfunction takes a partially filled in domainset as a key and returns a
128e5818a53SJeff Robersonvalid domainset or NULL.
129e5818a53SJeff RobersonIt is critical that consumers not use domainsets that have not been
130e5818a53SJeff Robersonreturned by this function.
131e5818a53SJeff Roberson.Vt
132e5818a53SJeff Robersondomainset
133e5818a53SJeff Robersonis an immutable type that is shared among all matching keys and must
134e5818a53SJeff Robersonnot be modified after return.
135e5818a53SJeff Roberson.Pp
136e5818a53SJeff RobersonThe
137e5818a53SJeff Roberson.Fn sysctl_handle_domainset
138e5818a53SJeff Robersonfunction is provided as a convenience for modifying or viewing domainsets
139e5818a53SJeff Robersonthat are not accessible via
140e5818a53SJeff Roberson.Xr cpuset 2 .
141e5818a53SJeff RobersonIt is intended for use with
142e5818a53SJeff Roberson.Xr sysctl 9 .
143e5818a53SJeff Roberson.Pp
144e5818a53SJeff Roberson.Sh SEE ALSO
145e5818a53SJeff Roberson.Xr cpuset 1 ,
146e5818a53SJeff Roberson.Xr cpuset 2 ,
147e5818a53SJeff Roberson.Xr cpuset_setdomain 2 ,
148e5818a53SJeff Roberson.Xr bitset 9
149e5818a53SJeff Roberson.Sh HISTORY
150e5818a53SJeff Roberson.In sys/domainset.h
151e5818a53SJeff Robersonfirst appeared in
152e5818a53SJeff Roberson.Fx 12.0 .
153