Provide sf_buf_ref() to optimize refcounting of already allocated
sendfile(2) buffers. Sponsored by: Netflix Sponsored by: Nginx, Inc.
This commit is contained in:
parent
41f23f3992
commit
22028ff4aa
@ -201,6 +201,22 @@ sf_buf_free(struct sf_buf *sf)
|
||||
mtx_unlock(&sf_buf_lock);
|
||||
}
|
||||
|
||||
void
|
||||
sf_buf_ref(struct sf_buf *sf)
|
||||
{
|
||||
|
||||
#ifdef SFBUF_OPTIONAL_DIRECT_MAP
|
||||
if (SFBUF_OPTIONAL_DIRECT_MAP)
|
||||
return;
|
||||
#endif
|
||||
|
||||
KASSERT(sf->ref_count > 0, ("%s: sf %p not allocated", __func__, sf));
|
||||
|
||||
mtx_lock(&sf_buf_lock);
|
||||
sf->ref_count++;
|
||||
mtx_unlock(&sf_buf_lock);
|
||||
}
|
||||
|
||||
#ifdef SFBUF_PROCESS_PAGE
|
||||
/*
|
||||
* Run callback function on sf_buf that holds a certain page.
|
||||
|
@ -1993,8 +1993,7 @@ sf_ext_ref(void *arg1, void *arg2)
|
||||
struct sendfile_sync *sfs = arg2;
|
||||
vm_page_t pg = sf_buf_page(sf);
|
||||
|
||||
/* XXXGL: there should be sf_buf_ref() */
|
||||
sf_buf_alloc(sf_buf_page(sf), SFB_NOWAIT);
|
||||
sf_buf_ref(sf);
|
||||
|
||||
vm_page_lock(pg);
|
||||
vm_page_wire(pg);
|
||||
|
@ -106,6 +106,7 @@ struct sf_buf;
|
||||
#ifdef SFBUF
|
||||
struct sf_buf *sf_buf_alloc(struct vm_page *, int);
|
||||
void sf_buf_free(struct sf_buf *);
|
||||
void sf_buf_ref(struct sf_buf *);
|
||||
|
||||
static inline vm_offset_t
|
||||
sf_buf_kva(struct sf_buf *sf)
|
||||
@ -168,6 +169,11 @@ static inline void
|
||||
sf_buf_free(struct sf_buf *sf)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void
|
||||
sf_buf_ref(struct sf_buf *sf)
|
||||
{
|
||||
}
|
||||
#endif /* SFBUF */
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user