From owner-svn-src-all@FreeBSD.ORG Thu Oct 24 15:54:06 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id D5E609F0; Thu, 24 Oct 2013 15:54:06 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C325C2772; Thu, 24 Oct 2013 15:54:06 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9OFs63A030493; Thu, 24 Oct 2013 15:54:06 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9OFs6jm030492; Thu, 24 Oct 2013 15:54:06 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201310241554.r9OFs6jm030492@svn.freebsd.org> From: Edward Tomasz Napierala Date: Thu, 24 Oct 2013 15:54:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r257061 - head/sys/dev/iscsi 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.14 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: Thu, 24 Oct 2013 15:54:06 -0000 Author: trasz Date: Thu Oct 24 15:54:06 2013 New Revision: 257061 URL: http://svnweb.freebsd.org/changeset/base/257061 Log: Don't spin with mutex hold when there is not enough room in the send socket buffer. While here, make the code flow somewhat nicer. Thanks to mav@ for tracking it down. Tested by: mav MFC after: 3 days Sponsored by: FreeBSD Foundation Modified: head/sys/dev/iscsi/icl.c Modified: head/sys/dev/iscsi/icl.c ============================================================================== --- head/sys/dev/iscsi/icl.c Thu Oct 24 15:44:29 2013 (r257060) +++ head/sys/dev/iscsi/icl.c Thu Oct 24 15:54:06 2013 (r257061) @@ -723,11 +723,7 @@ icl_receive_thread(void *arg) for (;;) { if (ic->ic_disconnecting) { //ICL_DEBUG("terminating"); - ICL_CONN_LOCK(ic); - ic->ic_receive_running = false; - ICL_CONN_UNLOCK(ic); - kthread_exit(); - return; + break; } SOCKBUF_LOCK(&so->so_rcv); @@ -740,6 +736,11 @@ icl_receive_thread(void *arg) icl_conn_receive_pdus(ic, available); } + + ICL_CONN_LOCK(ic); + ic->ic_receive_running = false; + ICL_CONN_UNLOCK(ic); + kthread_exit(); } static int @@ -879,22 +880,19 @@ icl_send_thread(void *arg) ICL_CONN_LOCK(ic); ic->ic_send_running = true; - ICL_CONN_UNLOCK(ic); for (;;) { - ICL_CONN_LOCK(ic); if (ic->ic_disconnecting) { //ICL_DEBUG("terminating"); - ic->ic_send_running = false; - ICL_CONN_UNLOCK(ic); - kthread_exit(); - return; + break; } - if (TAILQ_EMPTY(&ic->ic_to_send)) - cv_wait(&ic->ic_send_cv, &ic->ic_lock); icl_conn_send_pdus(ic); - ICL_CONN_UNLOCK(ic); + cv_wait(&ic->ic_send_cv, &ic->ic_lock); } + + ic->ic_send_running = false; + ICL_CONN_UNLOCK(ic); + kthread_exit(); } static int