Date: Sun, 23 Dec 2007 22:50:55 GMT From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 131494 for review Message-ID: <200712232250.lBNMotY8007879@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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) { /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200712232250.lBNMotY8007879>