seccomp_unotify.2: EXAMPLE: Improve allocation of response buffer
[man-pages.git] / man2 / spu_create.2
blobd192eb0255a789948ef8283e0e4113e7f1a3cd74
1 .\" Copyright (c) International Business Machines Corp., 2006
2 .\"
3 .\" %%%LICENSE_START(GPLv2+_SW_3_PARA)
4 .\" This program is free software; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
8 .\"
9 .\" This program is distributed in the hope that it will be useful,
10 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
11 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
12 .\" the GNU General Public License for more details.
13 .\"
14 .\" You should have received a copy of the GNU General Public
15 .\" License along with this manual; if not, see
16 .\" <http://www.gnu.org/licenses/>.
17 .\" %%%LICENSE_END
18 .\"
19 .\" HISTORY:
20 .\" 2005-09-28, created by Arnd Bergmann <arndb@de.ibm.com>
21 .\" 2006-06-16, revised by Eduardo M. Fleury <efleury@br.ibm.com>
22 .\" 2007-07-10, some polishing by mtk
23 .\" 2007-09-28, updates for newer kernels by Jeremy Kerr <jk@ozlabs.org>
24 .\"
25 .TH SPU_CREATE 2 2021-03-22 Linux "Linux Programmer's Manual"
26 .SH NAME
27 spu_create \- create a new spu context
28 .SH SYNOPSIS
29 .nf
30 .B #include <sys/types.h>
31 .B #include <sys/spu.h>
32 .PP
33 .BI "int spu_create(const char *" pathname ", unsigned int " flags \
34 ", mode_t " mode ,
35 .BI "               int " neighbor_fd ");"
36 .fi
37 .PP
38 .IR Note :
39 There is no glibc wrapper for this system call; see NOTES.
40 .SH DESCRIPTION
41 The
42 .BR spu_create ()
43 system call is used on PowerPC machines that implement the
44 Cell Broadband Engine Architecture in order to access Synergistic
45 Processor Units (SPUs).
46 It creates a new logical context for an SPU in
47 .I pathname
48 and returns a file descriptor associated with it.
49 .I pathname
50 must refer to a nonexistent directory in the mount point of
51 the SPU filesystem
52 .RB ( spufs ).
54 .BR spu_create ()
55 is successful, a directory is created at
56 .I pathname
57 and it is populated with the files described in
58 .BR spufs (7).
59 .PP
60 When a context is created,
61 the returned file descriptor can only be passed to
62 .BR spu_run (2),
63 used as the
64 .I dirfd
65 argument to the
66 .B *at
67 family of system calls (e.g.,
68 .BR openat (2)),
69 or closed;
70 other operations are not defined.
71 A logical SPU
72 context is destroyed (along with all files created within the context's
73 .I pathname
74 directory) once the last reference to the context has gone;
75 this usually occurs when the file descriptor returned by
76 .BR spu_create ()
77 is closed.
78 .PP
79 The
80 .I mode
81 argument (minus any bits set in the process's
82 .BR umask (2))
83 specifies the permissions used for creating the new directory in
84 .BR spufs .
85 See
86 .BR stat (2)
87 for a full list of the possible
88 .I mode
89 values.
90 .PP
91 The
92 .I neighbor_fd
93 is used only when the
94 .B SPU_CREATE_AFFINITY_SPU
95 flag is specified; see below.
96 .PP
97 The
98 .I flags
99 argument can be zero or any bitwise OR-ed
100 combination of the following constants:
102 .B SPU_CREATE_EVENTS_ENABLED
103 Rather than using signals for reporting DMA errors, use the
104 .I event
105 argument to
106 .BR spu_run (2).
108 .B SPU_CREATE_GANG
109 Create an SPU gang instead of a context.
110 (A gang is a group of SPU contexts that are
111 functionally related to each other and which share common scheduling
112 parameters\(empriority and policy.
113 In the future, gang scheduling may be implemented causing
114 the group to be switched in and out as a single unit.)
116 A new directory will be created at the location specified by the
117 .I pathname
118 argument.
119 This gang may be used to hold other SPU contexts, by providing
120 a pathname that is within the gang directory to further calls to
121 .BR spu_create ().
123 .B SPU_CREATE_NOSCHED
124 Create a context that is not affected by the SPU scheduler.
125 Once the context is run,
126 it will not be scheduled out until it is destroyed by
127 the creating process.
129 Because the context cannot be removed from the SPU, some functionality
130 is disabled for
131 .BR SPU_CREATE_NOSCHED
132 contexts.
133 Only a subset of the files will be
134 available in this context directory in
135 .BR spufs .
136 Additionally,
137 .BR SPU_CREATE_NOSCHED
138 contexts cannot dump a core file when crashing.
140 Creating
141 .BR SPU_CREATE_NOSCHED
142 contexts requires the
143 .B CAP_SYS_NICE
144 capability.
146 .B SPU_CREATE_ISOLATE
147 Create an isolated SPU context.
148 Isolated contexts are protected from some
149 PPE (PowerPC Processing Element)
150 operations,
151 such as access to the SPU local store and the NPC register.
153 Creating
154 .B SPU_CREATE_ISOLATE
155 contexts also requires the
156 .B SPU_CREATE_NOSCHED
157 flag.
159 .BR SPU_CREATE_AFFINITY_SPU " (since Linux 2.6.23)"
160 .\" commit 8e68e2f248332a9c3fd4f08258f488c209bd3e0c
161 Create a context with affinity to another SPU context.
162 This affinity information is used within the SPU scheduling algorithm.
163 Using this flag requires that a file descriptor referring to
164 the other SPU context be passed in the
165 .I neighbor_fd
166 argument.
168 .BR SPU_CREATE_AFFINITY_MEM " (since Linux 2.6.23)"
169 .\" commit 8e68e2f248332a9c3fd4f08258f488c209bd3e0c
170 Create a context with affinity to system memory.
171 This affinity information
172 is used within the SPU scheduling algorithm.
173 .SH RETURN VALUE
174 On success,
175 .BR spu_create ()
176 returns a new file descriptor.
177 On failure, \-1 is returned, and
178 .I errno
179 is set to indicate the error.
180 .SH ERRORS
182 .B EACCES
183 The current user does not have write access to the
184 .BR spufs (7)
185 mount point.
187 .B EEXIST
188 An SPU context already exists at the given pathname.
190 .B EFAULT
191 .I pathname
192 is not a valid string pointer in the
193 calling process's address space.
195 .B EINVAL
196 .I pathname
197 is not a directory in the
198 .BR spufs (7)
199 mount point, or invalid flags have been provided.
201 .B ELOOP
202 Too many symbolic links were found while resolving
203 .IR pathname .
205 .B EMFILE
206 The per-process limit on the number of open file descriptors has been reached.
208 .B ENAMETOOLONG
209 .I pathname
210 is too long.
212 .B ENFILE
213 The system-wide limit on the total number of open files has been reached.
215 .B ENODEV
216 An isolated context was requested, but the hardware does not support
217 SPU isolation.
219 .B ENOENT
220 Part of
221 .I pathname
222 could not be resolved.
224 .B ENOMEM
225 The kernel could not allocate all resources required.
227 .B ENOSPC
228 There are not enough SPU resources available to create
229 a new context or the user-specific limit for the number
230 of SPU contexts has been reached.
232 .B ENOSYS
233 The functionality is not provided by the current system, because
234 either the hardware does not provide SPUs or the spufs module is not
235 loaded.
237 .B ENOTDIR
238 A part of
239 .I pathname
240 is not a directory.
242 .B EPERM
244 .B SPU_CREATE_NOSCHED
245 flag has been given, but the user does not have the
246 .B CAP_SYS_NICE
247 capability.
248 .SH FILES
249 .I pathname
250 must point to a location beneath the mount point of
251 .BR spufs .
252 By convention, it gets mounted in
253 .IR /spu .
254 .SH VERSIONS
256 .BR spu_create ()
257 system call was added to Linux in kernel 2.6.16.
258 .SH CONFORMING TO
259 This call is Linux-specific and implemented only on the PowerPC
260 architecture.
261 Programs using this system call are not portable.
262 .SH NOTES
263 Glibc does not provide a wrapper for this system call; call it using
264 .BR syscall (2).
265 Note however, that
266 .BR spu_create ()
267 is meant to be used from libraries that implement a more abstract
268 interface to SPUs, not to be used from regular applications.
270 .UR http://www.bsc.es\:/projects\:/deepcomputing\:/linuxoncell/
272 for the recommended libraries.
274 Prior to the addition of the
275 .B SPU_CREATE_AFFINITY_SPU
276 flag in Linux 2.6.23, the
277 .BR spu_create ()
278 system call took only three arguments (i.e., there was no
279 .I neighbor_fd
280 argument).
281 .SH EXAMPLES
283 .BR spu_run (2)
284 for an example of the use of
285 .BR spu_create ()
286 .SH SEE ALSO
287 .BR close (2),
288 .BR spu_run (2),
289 .BR capabilities (7),
290 .BR spufs (7)