FreeBSD kernel kern code
subr_sfbuf.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/sf_buf.h>
#include <sys/smp.h>
#include <sys/sysctl.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>
#include <vm/vm_page.h>
Include dependency graph for subr_sfbuf.c:

Go to the source code of this file.

Macros

#define NSFBUFS   (512 + maxusers * 16)
 
#define SF_BUF_HASH(m)   (((m) - vm_page_array) & sf_buf_hashmask)
 

Functions

 __FBSDID ("$FreeBSD$")
 
 SYSCTL_INT (_kern_ipc, OID_AUTO, nsfbufs, CTLFLAG_RDTUN, &nsfbufs, 0, "Maximum number of sendfile(2) sf_bufs available")
 
 SYSCTL_INT (_kern_ipc, OID_AUTO, nsfbufspeak, CTLFLAG_RD, &nsfbufspeak, 0, "Number of sendfile(2) sf_bufs at peak usage")
 
 SYSCTL_INT (_kern_ipc, OID_AUTO, nsfbufsused, CTLFLAG_RD, &nsfbufsused, 0, "Number of sendfile(2) sf_bufs in use")
 
static void sf_buf_init (void *arg)
 
 SYSINIT (sock_sf, SI_SUB_MBUF, SI_ORDER_ANY, sf_buf_init, NULL)
 
 LIST_HEAD (sf_head, sf_buf)
 
static TAILQ_HEAD (sf_buf)
 
struct sf_buf * sf_buf_alloc (struct vm_page *m, int flags)
 
void sf_buf_free (struct sf_buf *sf)
 
void sf_buf_ref (struct sf_buf *sf)
 

Variables

static int nsfbufs
 
static int nsfbufspeak
 
static int nsfbufsused
 
static struct sf_head * sf_buf_active
 
static u_long sf_buf_hashmask
 

Macro Definition Documentation

◆ NSFBUFS

#define NSFBUFS   (512 + maxusers * 16)

Definition at line 46 of file subr_sfbuf.c.

◆ SF_BUF_HASH

#define SF_BUF_HASH (   m)    (((m) - vm_page_array) & sf_buf_hashmask)

Definition at line 71 of file subr_sfbuf.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ LIST_HEAD()

LIST_HEAD ( sf_head  ,
sf_buf   
)

◆ sf_buf_alloc()

struct sf_buf * sf_buf_alloc ( struct vm_page *  m,
int  flags 
)

Definition at line 114 of file subr_sfbuf.c.

References flags, nsfbufspeak, nsfbufsused, sf_buf_active, and SF_BUF_HASH.

Referenced by _mb_unmapped_to_ext(), exec_map_first_page(), and vn_sendfile().

Here is the caller graph for this function:

◆ sf_buf_free()

void sf_buf_free ( struct sf_buf *  sf)

Definition at line 177 of file subr_sfbuf.c.

References nsfbufsused, and wakeup().

Referenced by exec_unmap_first_page(), mb_unmapped_free_mext(), and sendfile_free_mext().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sf_buf_init()

static void sf_buf_init ( void *  arg)
static

◆ sf_buf_ref()

void sf_buf_ref ( struct sf_buf *  sf)

Definition at line 199 of file subr_sfbuf.c.

◆ SYSCTL_INT() [1/3]

SYSCTL_INT ( _kern_ipc  ,
OID_AUTO  ,
nsfbufs  ,
CTLFLAG_RDTUN  ,
nsfbufs,
,
"Maximum number of sendfile(2) sf_bufs available"   
)

◆ SYSCTL_INT() [2/3]

SYSCTL_INT ( _kern_ipc  ,
OID_AUTO  ,
nsfbufspeak  ,
CTLFLAG_RD  ,
nsfbufspeak,
,
"Number of sendfile(2) sf_bufs at peak usage"   
)

◆ SYSCTL_INT() [3/3]

SYSCTL_INT ( _kern_ipc  ,
OID_AUTO  ,
nsfbufsused  ,
CTLFLAG_RD  ,
nsfbufsused,
,
"Number of sendfile(2) sf_bufs in use"   
)

◆ SYSINIT()

SYSINIT ( sock_sf  ,
SI_SUB_MBUF  ,
SI_ORDER_ANY  ,
sf_buf_init  ,
NULL   
)

◆ TAILQ_HEAD()

static TAILQ_HEAD ( sf_buf  )
static

Definition at line 73 of file subr_sfbuf.c.

Variable Documentation

◆ nsfbufs

int nsfbufs
static

Definition at line 49 of file subr_sfbuf.c.

◆ nsfbufspeak

int nsfbufspeak
static

Definition at line 50 of file subr_sfbuf.c.

Referenced by sf_buf_alloc().

◆ nsfbufsused

int nsfbufsused
static

Definition at line 51 of file subr_sfbuf.c.

Referenced by sf_buf_alloc(), and sf_buf_free().

◆ sf_buf_active

struct sf_head* sf_buf_active
static

Definition at line 68 of file subr_sfbuf.c.

Referenced by sf_buf_alloc().

◆ sf_buf_hashmask

u_long sf_buf_hashmask
static

Definition at line 69 of file subr_sfbuf.c.