From owner-p4-projects@FreeBSD.ORG Tue Dec 25 11:44:14 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 55D0416A41B; Tue, 25 Dec 2007 11:44:14 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8C79D16A419 for ; Tue, 25 Dec 2007 11:44:13 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 8D4D613C4E3 for ; Tue, 25 Dec 2007 11:44:13 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id lBPBiDDd015169 for ; Tue, 25 Dec 2007 11:44:13 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id lBPBiDuK015166 for perforce@freebsd.org; Tue, 25 Dec 2007 11:44:13 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Tue, 25 Dec 2007 11:44:13 GMT Message-Id: <200712251144.lBPBiDuK015166@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 131578 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Dec 2007 11:44:14 -0000 http://perforce.freebsd.org/chv.cgi?CH=131578 Change 131578 by rwatson@rwatson_cinnamon on 2007/12/25 11:44:08 Minor style tweaks. Affected files ... .. //depot/projects/zcopybpf/src/sys/net/bpf_zerocopy.c#27 edit Differences ... ==== //depot/projects/zcopybpf/src/sys/net/bpf_zerocopy.c#27 (text+ko) ==== @@ -140,8 +140,8 @@ /* * Given a user pointer to a page of user memory, return an sf_buf for the - * page. Because we may be requesting quite a few sf_bufs, prefer failure - * to deadlock and use SFB_NOWAIT. + * page. Because we may be requesting quite a few sf_bufs, prefer failure to + * deadlock and use SFB_NOWAIT. */ static struct sf_buf * zbuf_sfbuf_get(struct vm_map *map, vm_offset_t uaddr) @@ -149,20 +149,17 @@ struct sf_buf *sf; vm_page_t pp; - if (vm_fault_quick((caddr_t) uaddr, VM_PROT_READ | VM_PROT_WRITE) - < 0) + if (vm_fault_quick((caddr_t) uaddr, VM_PROT_READ | VM_PROT_WRITE) < + 0) return (NULL); - - pp = pmap_extract_and_hold(map->pmap, uaddr, - VM_PROT_READ | VM_PROT_WRITE); + pp = pmap_extract_and_hold(map->pmap, uaddr, VM_PROT_READ | + VM_PROT_WRITE); if (pp == NULL) return (NULL); - vm_page_lock_queues(); vm_page_wire(pp); vm_page_unhold(pp); vm_page_unlock_queues(); - sf = sf_buf_alloc(pp, SFB_NOWAIT); if (sf == NULL) { zbuf_page_free(pp); @@ -197,6 +194,9 @@ if ((len / PAGE_SIZE) > BPF_MAX_PAGES) return (EINVAL); + /* + * Allocate the buffer and set up each page with is own sf_buf. + */ error = 0; zb = malloc(sizeof(*zb), M_BPF, M_ZERO | M_WAITOK); zb->zb_uaddr = uaddr; @@ -240,7 +240,6 @@ ("bpf_zerocopy_append_bytes: not in zbuf mode")); KASSERT(buf != NULL, ("bpf_zerocopy_append_bytes: NULL buf")); - src_bytes = (u_char *)src; zb = (struct zbuf *)buf; @@ -258,7 +257,6 @@ count = min(len, PAGE_SIZE - poffset); bcopy(src_bytes, ((u_char *)sf_buf_kva(zb->zb_pages[page])) + poffset, count); - poffset += count; if (poffset == PAGE_SIZE) { poffset = 0; @@ -317,7 +315,6 @@ bcopy(mtod(m, u_char *) + moffset, ((u_char *)sf_buf_kva(zb->zb_pages[page])) + poffset, count); - poffset += count; if (poffset == PAGE_SIZE) { poffset = 0; @@ -507,10 +504,8 @@ * held buffer. */ BPFD_LOCK(d); - if (d->bd_immediate && d->bd_hbuf == NULL - && d->bd_slen != 0) { + if (d->bd_immediate && d->bd_hbuf == NULL && d->bd_slen != 0) ROTATE_BUFFERS(d); - } bzero(bz, sizeof(*bz)); if (d->bd_hbuf != NULL) { zb = (struct zbuf *)d->bd_hbuf; @@ -538,6 +533,7 @@ BPFD_UNLOCK(d); return (0); } + /* * Ioctl to configure zero-copy buffers -- may be done only once. */