From owner-p4-projects@FreeBSD.ORG Sun Dec 23 22:50:56 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E66F816A41B; Sun, 23 Dec 2007 22:50:55 +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 8C5B616A417 for ; Sun, 23 Dec 2007 22:50:55 +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 93FDA13C43E for ; Sun, 23 Dec 2007 22:50:55 +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 lBNMotDl007893 for ; Sun, 23 Dec 2007 22:50:55 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 lBNMotY8007879 for perforce@freebsd.org; Sun, 23 Dec 2007 22:50:55 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Sun, 23 Dec 2007 22:50:55 GMT Message-Id: <200712232250.lBNMotY8007879@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 131494 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: Sun, 23 Dec 2007 22:50:56 -0000 http://perforce.freebsd.org/chv.cgi?CH=131494 Change 131494 by rwatson@rwatson_cinnamon on 2007/12/23 22:50:15 Only check whether zerocopy has picked up a userspace free notification if (a) there is a buffer we might want to free, and (b) we need to free the buffer in order to handle the arriving packet data. Affected files ... .. //depot/projects/zcopybpf/src/sys/net/bpf.c#30 edit Differences ... ==== //depot/projects/zcopybpf/src/sys/net/bpf.c#30 (text+ko) ==== @@ -1757,19 +1757,6 @@ 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 @@ -1785,9 +1772,18 @@ curlen = BPF_WORDALIGN(d->bd_slen); if (curlen + totlen > d->bd_bufsize) { /* - * This packet will overflow the storage buffer. - * Rotate the buffers if we can, then wakeup any - * pending reads. + * 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. */ if (d->bd_fbuf == NULL) { /*