Debian Codegraph @

libibverbs/man/ibv_fork_init.3.md

raw symbols SCIP
1 ---
2 date: 2006-10-31
3 footer: libibverbs
4 header: "Libibverbs Programmer's Manual"
5 layout: page
6 license: 'Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md'
7 section: 3
8 title: IBV_FORK_INIT
9 ---
10
11 # NAME
12
13 ibv_fork_init - initialize libibverbs to support fork()
14
15 # SYNOPSIS
16
17 ```c
18 #include <infiniband/verbs.h>
19
20 int ibv_fork_init(void);
21 ```
22
23 # DESCRIPTION
24
25 **ibv_fork_init()** initializes libibverbs's data structures to handle
26 **fork()** function calls correctly and avoid data corruption, whether
27 **fork()** is called explicitly or implicitly (such as in **system()**).
28
29 It is not necessary to use this function if all parent process threads are
30 always blocked until all child processes end or change address spaces via an
31 **exec()** operation.
32
33 # RETURN VALUE
34
35 **ibv_fork_init()** returns 0 on success, or the value of errno on failure
36 (which indicates the failure reason). An error value of EINVAL indicates that
37 there had been RDMA memory registration already and it is therefore not
38 safe anymore to fork.
39
40 # NOTES
41
42 **ibv_fork_init()** works on Linux kernels supporting the **MADV_DONTFORK**
43 flag for **madvise()** (2.6.17 and higher).
44
45 Setting the environment variable **RDMAV_FORK_SAFE** or **IBV_FORK_SAFE** has
46 the same effect as calling **ibv_fork_init()**.
47
48 Setting the environment variable **RDMAV_HUGEPAGES_SAFE** tells the library to
49 check the underlying page size used by the kernel for memory regions. This is
50 required if an application uses huge pages either directly or indirectly via a
51 library such as libhugetlbfs.
52
53 Calling **ibv_fork_init()** will reduce performance due to an extra system
54 call for every memory registration, and the additional memory allocated to
55 track memory regions. The precise performance impact depends on the workload
56 and usually will not be significant.
57
58 Setting **RDMAV_HUGEPAGES_SAFE** adds further overhead to all memory
59 registrations.
60
61 # SEE ALSO
62
63 **exec**(3),
64 **fork**(2),
65 **ibv_get_device_list**(3),
66 **system**(3),
67 **wait**(2)
68
69 # AUTHOR
70
71 Dotan Barak <[email protected]>