PERFORCE change 131547 for review
Robert Watson
rwatson at FreeBSD.org
Mon Dec 24 14:25:02 PST 2007
http://perforce.freebsd.org/chv.cgi?CH=131547
Change 131547 by rwatson at 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) {
/*
More information about the p4-projects
mailing list