From owner-p4-projects@FreeBSD.ORG Mon Dec 24 22:25:02 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id CAE5516A46B; Mon, 24 Dec 2007 22:25:01 +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 8E18316A419 for ; Mon, 24 Dec 2007 22:25:01 +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 76BB713C461 for ; Mon, 24 Dec 2007 22:25:01 +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 lBOMP1Hk037851 for ; Mon, 24 Dec 2007 22:25:01 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 lBOMP1Qw037848 for perforce@freebsd.org; Mon, 24 Dec 2007 22:25:01 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Mon, 24 Dec 2007 22:25:01 GMT Message-Id: <200712242225.lBOMP1Qw037848@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 131547 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: Mon, 24 Dec 2007 22:25:02 -0000 http://perforce.freebsd.org/chv.cgi?CH=131547 Change 131547 by rwatson@rwatson_cinnamon on 2007/12/24 22:24:44 Revert @131494 -- while we don't need the free buffer immediately, we do have to rotate the held buffer to the free buffer quickly or we won't be able to push the next buffer from store to held, leading new packet data not being exposed if the buffer wasn't completely filled. I'll have to rethink how to optimize this. Affected files ... .. //depot/projects/zcopybpf/src/sys/net/bpf.c#33 edit Differences ... ==== //depot/projects/zcopybpf/src/sys/net/bpf.c#33 (text+ko) ==== @@ -1753,6 +1753,19 @@ BPFD_LOCK_ASSERT(d); /* + * Detect whether user space has released a buffer back to us, and if + * so, move it from being a hold buffer to a free buffer. This may + * not be the best place to do it (for example, we might only want to + * run this check if we need the space), but for now it's a reliable + * spot to do it. + */ + if (bpf_canfreebuf(d)) { + d->bd_fbuf = d->bd_hbuf; + d->bd_hbuf = NULL; + d->bd_hlen = 0; + } + + /* * Figure out how many bytes to move. If the packet is * greater or equal to the snapshot length, transfer that * much. Otherwise, transfer the whole packet (unless @@ -1768,18 +1781,9 @@ curlen = BPF_WORDALIGN(d->bd_slen); if (curlen + totlen > d->bd_bufsize) { /* - * This packet will overflow the storage buffer. If - * userspace has notified us via shared memory that a buffer - * can be freed, do so. - */ - if (d->bd_hbuf != NULL && bpf_canfreebuf(d)) { - d->bd_fbuf = d->bd_hbuf; - d->bd_hbuf = NULL; - d->bd_hlen = 0; - } - - /* - * Rotate buffers if we can, then wakeup any pending reads. + * This packet will overflow the storage buffer. + * Rotate the buffers if we can, then wakeup any + * pending reads. */ if (d->bd_fbuf == NULL) { /*