Introduce two new options, "CPU private" and "no wait", to sf_buf_alloc().
Change the spelling of the "catch" option to be consistent with the new options. Implement the "no wait" option. An implementation of the "CPU private" for i386 will be committed at a later date.
This commit is contained in:
parent
f3118682aa
commit
d3cb0d99e0
@ -231,7 +231,7 @@ sf_buf_init(void *arg)
|
||||
* Get an sf_buf from the freelist. Will block if none are available.
|
||||
*/
|
||||
struct sf_buf *
|
||||
sf_buf_alloc(struct vm_page *m, int pri)
|
||||
sf_buf_alloc(struct vm_page *m, int flags)
|
||||
{
|
||||
struct sf_head *hash_list;
|
||||
struct sf_buf *sf;
|
||||
@ -251,10 +251,12 @@ sf_buf_alloc(struct vm_page *m, int pri)
|
||||
}
|
||||
}
|
||||
while ((sf = TAILQ_FIRST(&sf_buf_freelist)) == NULL) {
|
||||
if (flags & SFB_NOWAIT)
|
||||
goto done;
|
||||
sf_buf_alloc_want++;
|
||||
mbstat.sf_allocwait++;
|
||||
error = msleep(&sf_buf_freelist, &sf_buf_lock, PVM | pri,
|
||||
"sfbufa", 0);
|
||||
error = msleep(&sf_buf_freelist, &sf_buf_lock,
|
||||
(flags & SFB_CATCH) ? PCATCH | PVM : PVM, "sfbufa", 0);
|
||||
sf_buf_alloc_want--;
|
||||
|
||||
|
||||
|
@ -615,7 +615,7 @@ sf_buf_init(void *arg)
|
||||
* Get an sf_buf from the freelist. Will block if none are available.
|
||||
*/
|
||||
struct sf_buf *
|
||||
sf_buf_alloc(struct vm_page *m, int pri)
|
||||
sf_buf_alloc(struct vm_page *m, int flags)
|
||||
{
|
||||
pt_entry_t opte, *ptep;
|
||||
struct sf_head *hash_list;
|
||||
@ -636,10 +636,12 @@ sf_buf_alloc(struct vm_page *m, int pri)
|
||||
}
|
||||
}
|
||||
while ((sf = TAILQ_FIRST(&sf_buf_freelist)) == NULL) {
|
||||
if (flags & SFB_NOWAIT)
|
||||
goto done;
|
||||
sf_buf_alloc_want++;
|
||||
mbstat.sf_allocwait++;
|
||||
error = msleep(&sf_buf_freelist, &sf_buf_lock, PVM | pri,
|
||||
"sfbufa", 0);
|
||||
error = msleep(&sf_buf_freelist, &sf_buf_lock,
|
||||
(flags & SFB_CATCH) ? PCATCH | PVM : PVM, "sfbufa", 0);
|
||||
sf_buf_alloc_want--;
|
||||
|
||||
/*
|
||||
|
@ -138,7 +138,7 @@ socow_setup(struct mbuf *m0, struct uio *uio)
|
||||
/*
|
||||
* Allocate an sf buf
|
||||
*/
|
||||
sf = sf_buf_alloc(pp, PCATCH);
|
||||
sf = sf_buf_alloc(pp, SFB_CATCH);
|
||||
if (!sf) {
|
||||
vm_page_lock_queues();
|
||||
vm_page_cowclear(pp);
|
||||
|
@ -1953,7 +1953,7 @@ retry_lookup:
|
||||
* Get a sendfile buf. We usually wait as long as necessary,
|
||||
* but this wait can be interrupted.
|
||||
*/
|
||||
if ((sf = sf_buf_alloc(pg, PCATCH)) == NULL) {
|
||||
if ((sf = sf_buf_alloc(pg, SFB_CATCH)) == NULL) {
|
||||
mbstat.sf_allocfail++;
|
||||
vm_page_lock_queues();
|
||||
vm_page_unwire(pg, 0);
|
||||
|
@ -375,17 +375,19 @@ sf_buf_init(void *arg)
|
||||
* Get an sf_buf from the freelist. Will block if none are available.
|
||||
*/
|
||||
struct sf_buf *
|
||||
sf_buf_alloc(struct vm_page *m, int pri)
|
||||
sf_buf_alloc(struct vm_page *m, int flags)
|
||||
{
|
||||
struct sf_buf *sf;
|
||||
int error;
|
||||
|
||||
mtx_lock(&sf_freelist.sf_lock);
|
||||
while ((sf = SLIST_FIRST(&sf_freelist.sf_head)) == NULL) {
|
||||
if (flags & SFB_NOWAIT)
|
||||
goto break;
|
||||
sf_buf_alloc_want++;
|
||||
mbstat.sf_allocwait++;
|
||||
error = msleep(&sf_freelist, &sf_freelist.sf_lock, PVM | pri,
|
||||
"sfbufa", 0);
|
||||
error = msleep(&sf_freelist, &sf_freelist.sf_lock,
|
||||
(flags & SFB_CATCH) ? PCATCH | PVM : PVM, "sfbufa", 0);
|
||||
sf_buf_alloc_want--;
|
||||
|
||||
/*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2003 Alan L. Cox <alc@cs.rice.edu>
|
||||
* Copyright (c) 2003-2004 Alan L. Cox <alc@cs.rice.edu>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -31,6 +31,17 @@
|
||||
|
||||
#include <machine/sf_buf.h>
|
||||
|
||||
/*
|
||||
* Options to sf_buf_alloc() are specified through its flags argument. This
|
||||
* argument's value should be the result of a bitwise or'ing of one or more
|
||||
* of the following values.
|
||||
*/
|
||||
#define SFB_CATCH 1 /* Check signals if the allocation
|
||||
sleeps. */
|
||||
#define SFB_CPUPRIVATE 2 /* Create a CPU private mapping. */
|
||||
#define SFB_DEFAULT 0
|
||||
#define SFB_NOWAIT 4 /* Return NULL if all bufs are used. */
|
||||
|
||||
struct vm_page;
|
||||
|
||||
extern int nsfbufs; /* Number of sendfile(2) bufs alloced */
|
||||
@ -38,7 +49,7 @@ extern int nsfbufspeak; /* Peak of nsfbufsused */
|
||||
extern int nsfbufsused; /* Number of sendfile(2) bufs in use */
|
||||
|
||||
struct sf_buf *
|
||||
sf_buf_alloc(struct vm_page *m, int pri);
|
||||
sf_buf_alloc(struct vm_page *m, int flags);
|
||||
void sf_buf_free(struct sf_buf *sf);
|
||||
void sf_buf_mext(void *addr, void *args);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user