1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
<table class="head">
<tr>
<td class="head-ltitle">SF_BUF(9)</td>
<td class="head-vol">Kernel Developer's Manual</td>
<td class="head-rtitle">SF_BUF(9)</td>
</tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">sf_buf</code> — <span class="Nd">manage
temporary kernel address space mapping for memory pages</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<p class="Pp"><code class="In">#include
<<a class="In">sys/sf_buf.h</a>></code></p>
<p class="Pp"><var class="Ft">struct sf_buf *</var>
<br/>
<code class="Fn">sf_buf_alloc</code>(<var class="Fa" style="white-space: nowrap;">struct
vm_page *m</var>, <var class="Fa" style="white-space: nowrap;">int
flags</var>);</p>
<p class="Pp"><var class="Ft">void</var>
<br/>
<code class="Fn">sf_buf_free</code>(<var class="Fa" style="white-space: nowrap;">struct
sf_buf *sf</var>);</p>
<p class="Pp"><var class="Ft">vm_offset_t</var>
<br/>
<code class="Fn">sf_buf_kva</code>(<var class="Fa" style="white-space: nowrap;">struct
sf_buf *sf</var>);</p>
<p class="Pp"><var class="Ft">struct vm_page *</var>
<br/>
<code class="Fn">sf_buf_page</code>(<var class="Fa" style="white-space: nowrap;">struct
sf_buf *sf</var>);</p>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">The <code class="Nm">sf_buf</code> interface, historically the
<a class="Xr">sendfile(2)</a> buffer interface, allows kernel subsystems to
manage temporary kernel address space mappings for physical memory pages. On
systems with a direct memory map region (allowing all physical pages to be
visible in the kernel address space at all times), the
<var class="Vt">struct sf_buf</var> will point to an address in the direct
map region; on systems without a direct memory map region, the
<var class="Vt">struct sf_buf</var> will manage a temporary kernel address
space mapping valid for the lifetime of the <var class="Vt">struct
sf_buf</var>.</p>
<p class="Pp" id="sf_buf_alloc">Call
<a class="permalink" href="#sf_buf_alloc"><code class="Fn">sf_buf_alloc</code></a>()
to allocate a <var class="Vt">struct sf_buf</var> for a physical memory
page. <code class="Fn">sf_buf_alloc</code>() is not responsible for
arranging for the page to be present in physical memory; the caller should
already have arranged for the page to be wired, i.e., by calling
<a class="Xr">vm_page_wire(9)</a>. Several flags may be passed to
<code class="Fn">sf_buf_alloc</code>():</p>
<dl class="Bl-tag">
<dt id="SFB_CATCH"><a class="permalink" href="#SFB_CATCH"><code class="Dv">SFB_CATCH</code></a></dt>
<dd>Cause <code class="Fn">sf_buf_alloc</code>() to abort and return
<code class="Dv">NULL</code> if a signal is received waiting for a
<var class="Vt">struct sf_buf</var> to become available.</dd>
<dt id="SFB_NOWAIT"><a class="permalink" href="#SFB_NOWAIT"><code class="Dv">SFB_NOWAIT</code></a></dt>
<dd>Cause <code class="Fn">sf_buf_alloc</code>() to return
<code class="Dv">NULL</code> rather than sleeping if a
<var class="Vt">struct sf_buf</var> is not immediately available.</dd>
<dt id="SFB_CPUPRIVATE"><a class="permalink" href="#SFB_CPUPRIVATE"><code class="Dv">SFB_CPUPRIVATE</code></a></dt>
<dd>Cause <code class="Fn">sf_buf_alloc</code>() to only arrange that the
temporary mapping be valid on the current CPU, avoiding unnecessary TLB
shootdowns for mappings that will only be accessed on a single CPU at a
time. The caller must ensure that accesses to the virtual address occur
only on the CPU from which <code class="Fn">sf_buf_alloc</code>() was
invoked, perhaps by using
<a class="permalink" href="#sched_pin"><code class="Fn" id="sched_pin">sched_pin</code></a>().</dd>
</dl>
<p class="Pp" id="sf_buf_kva">Call
<a class="permalink" href="#sf_buf_kva"><code class="Fn">sf_buf_kva</code></a>()
to return a kernel mapped address for the page.</p>
<p class="Pp" id="sf_buf_page">Call
<a class="permalink" href="#sf_buf_page"><code class="Fn">sf_buf_page</code></a>()
to return a pointer to the page originally passed into
<code class="Fn">sf_buf_alloc</code>().</p>
<p class="Pp" id="sf_buf_free">Call
<a class="permalink" href="#sf_buf_free"><code class="Fn">sf_buf_free</code></a>()
to release the <var class="Vt">struct sf_buf</var> reference. The caller is
responsible for releasing any wiring they have previously acquired on the
physical page; <code class="Fn">sf_buf_free</code>() releases only the
temporary kernel address space mapping, not the page itself.</p>
<p class="Pp">Uses of this interface include managing mappings of borrowed pages
from user memory, such as in zero-copy socket I/O, or pages of memory from
the buffer cache referenced by mbuf external storage for
<a class="Xr">sendfile(2)</a>.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
ALSO</a></h1>
<p class="Pp"><a class="Xr">sendfile(2)</a>,
<a class="Xr">vm_page_wire(9)</a></p>
</section>
<section class="Sh">
<h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
<p class="Pp">The <var class="Vt">struct sf_buf</var> API was designed and
implemented by <span class="An">Alan L. Cox</span>. This manual page was
written by <span class="An">Robert N. M. Watson</span>.</p>
</section>
</div>
<table class="foot">
<tr>
<td class="foot-date">January 28, 2007</td>
<td class="foot-os">FreeBSD 15.0</td>
</tr>
</table>
|