svn commit: r269807 - in head/sys: kern sys
Konstantin Belousov
kostikbel at gmail.com
Mon Aug 11 13:47:38 UTC 2014
On Mon, Aug 11, 2014 at 12:59:55PM +0000, Gleb Smirnoff wrote:
> Author: glebius
> Date: Mon Aug 11 12:59:55 2014
> New Revision: 269807
> URL: http://svnweb.freebsd.org/changeset/base/269807
>
> Log:
> Provide sf_buf_ref() to optimize refcounting of already allocated
> sendfile(2) buffers.
>
> Sponsored by: Netflix
> Sponsored by: Nginx, Inc.
>
> Modified:
> head/sys/kern/subr_sfbuf.c
> head/sys/kern/uipc_syscalls.c
> head/sys/sys/sf_buf.h
>
> Modified: head/sys/kern/subr_sfbuf.c
> ==============================================================================
> --- head/sys/kern/subr_sfbuf.c Mon Aug 11 12:26:48 2014 (r269806)
> +++ head/sys/kern/subr_sfbuf.c Mon Aug 11 12:59:55 2014 (r269807)
> @@ -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);
> +}
I think assert could be usefully moved under the mutex protected region.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20140811/64f5bef0/attachment.sig>
More information about the svn-src-head
mailing list