Pass the vm_page's address to sf_buf_alloc(); map the vm_page as part
of sf_buf_alloc() instead of expecting sf_buf_alloc()'s caller to map it. The ultimate reason for this change is to enable two optimizations: (1) that there never be more than one sf_buf mapping a vm_page at a time and (2) 64-bit architectures can transparently use their 1-1 virtual to physical mapping (e.g., "K0SEG") avoiding the overhead of pmap_qenter() and pmap_qremove().
This commit is contained in:
parent
7d7faf316e
commit
6f59be774d
@ -144,9 +144,7 @@ socow_setup(struct mbuf *m0, struct uio *uio)
|
||||
/*
|
||||
* Allocate an sf buf
|
||||
*/
|
||||
sf = sf_buf_alloc();
|
||||
sf->m = pp;
|
||||
pmap_qenter(sf->kva, &pp, 1);
|
||||
sf = sf_buf_alloc(pp);
|
||||
|
||||
/*
|
||||
* attach to mbuf
|
||||
|
@ -1637,7 +1637,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()
|
||||
sf_buf_alloc(struct vm_page *m)
|
||||
{
|
||||
struct sf_buf *sf;
|
||||
int error;
|
||||
@ -1655,8 +1655,11 @@ sf_buf_alloc()
|
||||
if (error)
|
||||
break;
|
||||
}
|
||||
if (sf != NULL)
|
||||
if (sf != NULL) {
|
||||
SLIST_REMOVE_HEAD(&sf_freelist.sf_head, free_list);
|
||||
sf->m = m;
|
||||
pmap_qenter(sf->kva, &sf->m, 1);
|
||||
}
|
||||
mtx_unlock(&sf_freelist.sf_lock);
|
||||
return (sf);
|
||||
}
|
||||
@ -1930,7 +1933,7 @@ do_sendfile(struct thread *td, struct sendfile_args *uap, int compat)
|
||||
* Get a sendfile buf. We usually wait as long as necessary,
|
||||
* but this wait can be interrupted.
|
||||
*/
|
||||
if ((sf = sf_buf_alloc()) == NULL) {
|
||||
if ((sf = sf_buf_alloc(pg)) == NULL) {
|
||||
vm_page_lock_queues();
|
||||
vm_page_unwire(pg, 0);
|
||||
if (pg->wire_count == 0 && pg->object == NULL)
|
||||
@ -1941,12 +1944,6 @@ do_sendfile(struct thread *td, struct sendfile_args *uap, int compat)
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a kernel virtual page and insert the physical page
|
||||
* into it.
|
||||
*/
|
||||
sf->m = pg;
|
||||
pmap_qenter(sf->kva, &pg, 1);
|
||||
/*
|
||||
* Get an mbuf header and set it up as having external storage.
|
||||
*/
|
||||
|
@ -371,7 +371,7 @@ int sbreserve(struct sockbuf *sb, u_long cc, struct socket *so,
|
||||
void sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb);
|
||||
int sbwait(struct sockbuf *sb);
|
||||
struct sf_buf *
|
||||
sf_buf_alloc(void);
|
||||
sf_buf_alloc(struct vm_page *m);
|
||||
void sf_buf_free(void *addr, void *args);
|
||||
int sb_lock(struct sockbuf *sb);
|
||||
int soabort(struct socket *so);
|
||||
|
Loading…
Reference in New Issue
Block a user