From owner-svn-src-all@freebsd.org Tue Nov 29 13:11:01 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CEF25C5ADEA; Tue, 29 Nov 2016 13:11:01 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8576112EB; Tue, 29 Nov 2016 13:11:01 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uATDB0TR058191; Tue, 29 Nov 2016 13:11:00 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uATDB05i058190; Tue, 29 Nov 2016 13:11:00 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201611291311.uATDB05i058190@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Tue, 29 Nov 2016 13:11:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r309295 - head/usr.sbin/bhyve X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Nov 2016 13:11:01 -0000 Author: avg Date: Tue Nov 29 13:11:00 2016 New Revision: 309295 URL: https://svnweb.freebsd.org/changeset/base/309295 Log: bhyve: stability and performance improvement for dbgport The TCP server implementation in dbgport does not track clients, so it may try to write to a disconected socket resulting in SIGPIPE. Avoid that by setting SO_NOSIGPIPE socket option. Because dbgport emulates an I/O port to guest, the communication is done byte by byte. Reduce latency of the TCP/IP transfers by using TCP_NODELAY option. In my tests that change improves performance of kgdb commands with lots of output (e.g. info threads) by two orders of magnitude. A general note. Since we have a uart emulation in bhyve, that can be used for the console and gdb access to guests. So, bvmconsole and bvmdebug could be de-orbited now. But there are many existing deployments that still dependend on those. Discussed with: julian, jhb MFC after: 2 weeks Sponsored by: Panzura Modified: head/usr.sbin/bhyve/dbgport.c Modified: head/usr.sbin/bhyve/dbgport.c ============================================================================== --- head/usr.sbin/bhyve/dbgport.c Tue Nov 29 13:05:43 2016 (r309294) +++ head/usr.sbin/bhyve/dbgport.c Tue Nov 29 13:11:00 2016 (r309295) @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -55,8 +56,9 @@ static int dbg_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes, uint32_t *eax, void *arg) { - char ch; int nwritten, nread, printonce; + int on = 1; + char ch; if (bytes == 2 && in) { *eax = BVM_DBG_SIG; @@ -74,8 +76,16 @@ again: printonce = 1; } conn_fd = accept4(listen_fd, NULL, NULL, SOCK_NONBLOCK); - if (conn_fd < 0 && errno != EINTR) + if (conn_fd >= 0) { + /* Avoid EPIPE after the client drops off. */ + (void)setsockopt(conn_fd, SOL_SOCKET, SO_NOSIGPIPE, + &on, sizeof(on)); + /* Improve latency for one byte at a time tranfers. */ + (void)setsockopt(conn_fd, IPPROTO_TCP, TCP_NODELAY, + &on, sizeof(on)); + } else if (errno != EINTR) { perror("accept"); + } } if (in) {