From 6f59be774d7b820d9fc3ec62a551dbb881c00d04 Mon Sep 17 00:00:00 2001 From: alc Date: Sat, 29 Mar 2003 06:14:14 +0000 Subject: 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(). --- sys/kern/uipc_cow.c | 4 +--- sys/kern/uipc_syscalls.c | 15 ++++++--------- sys/sys/socketvar.h | 2 +- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/sys/kern/uipc_cow.c b/sys/kern/uipc_cow.c index 26b3f4c..6dc23d1 100644 --- a/sys/kern/uipc_cow.c +++ b/sys/kern/uipc_cow.c @@ -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 diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 6773452..bbd2992 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -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 @@ retry_lookup: * 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) @@ -1942,12 +1945,6 @@ retry_lookup: } /* - * 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. */ MGETHDR(m, M_TRYWAIT, MT_DATA); diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h index a2e2ab6..e5f8756 100644 --- a/sys/sys/socketvar.h +++ b/sys/sys/socketvar.h @@ -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); -- cgit v1.1