Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Apr 2015 10:44:47 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r281765 - head/sys/net
Message-ID:  <201504201044.t3KAilfq065078@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Mon Apr 20 10:44:46 2015
New Revision: 281765
URL: https://svnweb.freebsd.org/changeset/base/281765

Log:
  Activate write-only optimization if bpf device opened with O_WRONLY.
  
  dhclient opens bpf as write-only to send packets. It never reads received
  packets from that descriptor, but processing them in kernel takes time.
  Especially much time takes packet timestamping on systems with expensive
  timecounter, such as bhyve guest, where network speed dropped in half.
  
  MFC after:	2 weeks
  Sponsored by:	iXsystems, Inc.

Modified:
  head/sys/net/bpf.c

Modified: head/sys/net/bpf.c
==============================================================================
--- head/sys/net/bpf.c	Mon Apr 20 10:29:42 2015	(r281764)
+++ head/sys/net/bpf.c	Mon Apr 20 10:44:46 2015	(r281765)
@@ -601,7 +601,7 @@ bpf_attachd(struct bpf_d *d, struct bpf_
 	 * Save sysctl value to protect from sysctl change
 	 * between reads
 	 */
-	op_w = V_bpf_optimize_writers;
+	op_w = V_bpf_optimize_writers || d->bd_writer;
 
 	if (d->bd_bif != NULL)
 		bpf_detachd_locked(d);
@@ -864,6 +864,8 @@ bpfopen(struct cdev *dev, int flags, int
 	 * particular buffer method.
 	 */
 	bpf_buffer_init(d);
+	if ((flags & FREAD) == 0)
+		d->bd_writer = 2;
 	d->bd_hbuf_in_use = 0;
 	d->bd_bufmode = BPF_BUFMODE_BUFFER;
 	d->bd_sig = SIGIO;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201504201044.t3KAilfq065078>