Allow sends sent from non page-aligned userspace addresses to be

considered for zero-copy sends.

Reviewed by: alc
Submitted by: Romer Gil at Rice University
This commit is contained in:
Andrew Gallatin 2005-06-05 17:13:23 +00:00
parent 8cb62f3fd6
commit 92dd256bd4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=147009
2 changed files with 13 additions and 15 deletions

View file

@ -102,12 +102,13 @@ socow_setup(struct mbuf *m0, struct uio *uio)
struct iovec *iov;
struct vmspace *vmspace;
struct vm_map *map;
vm_offset_t uva;
vm_offset_t offset, uva;
int s;
vmspace = curproc->p_vmspace;
map = &vmspace->vm_map;
uva = (vm_offset_t) uio->uio_iov->iov_base;
offset = uva & PAGE_MASK;
s = splvm();
@ -158,22 +159,22 @@ socow_setup(struct mbuf *m0, struct uio *uio)
/*
* attach to mbuf
*/
m0->m_data = (caddr_t)sf_buf_kva(sf);
m0->m_len = PAGE_SIZE;
MEXTADD(m0, sf_buf_kva(sf), PAGE_SIZE, socow_iodone, sf, M_RDONLY,
EXT_SFBUF);
m0->m_len = PAGE_SIZE - offset;
m0->m_data = (caddr_t)sf_buf_kva(sf) + offset;
socow_stats.success++;
iov = uio->uio_iov;
iov->iov_base = (char *)iov->iov_base + PAGE_SIZE;
iov->iov_len -= PAGE_SIZE;
uio->uio_resid -= PAGE_SIZE;
uio->uio_offset += PAGE_SIZE;
iov->iov_base = (char *)iov->iov_base + m0->m_len;
iov->iov_len -= m0->m_len;
uio->uio_resid -= m0->m_len;
uio->uio_offset += m0->m_len;
if (iov->iov_len == 0) {
uio->uio_iov++;
uio->uio_iovcnt--;
}
splx(s);
return(1);
return(m0->m_len);
}

View file

@ -742,11 +742,9 @@ sosend(so, addr, uio, top, control, flags, td)
space>=PAGE_SIZE &&
uio->uio_iov->iov_len>=PAGE_SIZE) {
so_zerocp_stats.size_ok++;
if (!((vm_offset_t)
uio->uio_iov->iov_base & PAGE_MASK)){
so_zerocp_stats.align_ok++;
cow_send = socow_setup(m, uio);
}
so_zerocp_stats.align_ok++;
cow_send = socow_setup(m, uio);
len = cow_send;
}
if (!cow_send) {
MCLGET(m, M_TRYWAIT);
@ -756,8 +754,7 @@ sosend(so, addr, uio, top, control, flags, td)
} else {
len = min(min(MCLBYTES, resid), space);
}
} else
len = PAGE_SIZE;
}
#else /* ZERO_COPY_SOCKETS */
if (top == NULL) {
m = m_getcl(M_TRYWAIT, MT_DATA, M_PKTHDR);