summaryrefslogtreecommitdiffstats
path: root/sys/net/bpf_buffer.c
diff options
context:
space:
mode:
authorloos <loos@FreeBSD.org>2015-08-17 18:43:39 +0000
committerloos <loos@FreeBSD.org>2015-08-17 18:43:39 +0000
commit21e0cf5c4b7fda90cdb022c7c0494cf099287f59 (patch)
tree6b69779dcbaa864c776085f468c6706ab8b317ef /sys/net/bpf_buffer.c
parente0546eb073d88557cb55c31dee20e398cb858e34 (diff)
downloadFreeBSD-src-21e0cf5c4b7fda90cdb022c7c0494cf099287f59.zip
FreeBSD-src-21e0cf5c4b7fda90cdb022c7c0494cf099287f59.tar.gz
MFC r286140:
Remove the sleep from the buffer allocation routine. The buffer must be allocated (or even changed) before the interface is set and thus, there is no need to verify if the buffer is in use. MFC r286142: Remove two unnecessary sleeps from the hot path in bpf(4). The first one never triggers because bpf_canfreebuf() can only be true for zero-copy buffers and zero-copy buffers are not read with read(2). The second also never triggers, because we check the free buffer before calling ROTATE_BUFFERS(). If the hold buffer is in use the free buffer will be NULL and there is nothing else to do besides drop the packet. If the free buffer isn't NULL the hold buffer _is_ free and it is safe to rotate the buffers. Update the comment in ROTATE_BUFFERS macro to match the logic described here. While here fix a few typos in comments. MFC r286243: Add a KASSERT() to make sure we wont rotate the buffers twice (rotate the buffers while the hold buffer is in use). Sponsored by: Rubicon Communications (Netgate)
Diffstat (limited to 'sys/net/bpf_buffer.c')
-rw-r--r--sys/net/bpf_buffer.c5
1 files changed, 0 insertions, 5 deletions
diff --git a/sys/net/bpf_buffer.c b/sys/net/bpf_buffer.c
index 74e1ae4..64bb982 100644
--- a/sys/net/bpf_buffer.c
+++ b/sys/net/bpf_buffer.c
@@ -79,8 +79,6 @@ __FBSDID("$FreeBSD$");
#include <net/bpf_buffer.h>
#include <net/bpfdesc.h>
-#define PRINET 26 /* interruptible */
-
/*
* Implement historical kernel memory buffering model for BPF: two malloc(9)
* kernel buffers are hung off of the descriptor. The size is fixed prior to
@@ -191,9 +189,6 @@ bpf_buffer_ioctl_sblen(struct bpf_d *d, u_int *i)
return (EINVAL);
}
- while (d->bd_hbuf_in_use)
- mtx_sleep(&d->bd_hbuf_in_use, &d->bd_lock,
- PRINET, "bd_hbuf", 0);
/* Free old buffers if set */
if (d->bd_fbuf != NULL)
free(d->bd_fbuf, M_BPF);
OpenPOWER on IntegriCloud