From owner-svn-src-stable-8@FreeBSD.ORG Fri Feb 4 09:15:23 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5CA101065741; Fri, 4 Feb 2011 09:15:23 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4C36C8FC16; Fri, 4 Feb 2011 09:15:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p149FNuJ075858; Fri, 4 Feb 2011 09:15:23 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p149FNhA075856; Fri, 4 Feb 2011 09:15:23 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201102040915.p149FNhA075856@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 4 Feb 2011 09:15:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r218258 - stable/8/sys/kern X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Feb 2011 09:15:23 -0000 Author: kib Date: Fri Feb 4 09:15:23 2011 New Revision: 218258 URL: http://svn.freebsd.org/changeset/base/218258 Log: MFC r218026: If more than one thread allocated sf buffers for sendfile(2), and each of the threads needs more while current pool of the buffers is exhausted, then neither thread can make progress. Switch to nowait allocations after we got first buffer already. Modified: stable/8/sys/kern/uipc_syscalls.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/kern/uipc_syscalls.c ============================================================================== --- stable/8/sys/kern/uipc_syscalls.c Fri Feb 4 09:15:12 2011 (r218257) +++ stable/8/sys/kern/uipc_syscalls.c Fri Feb 4 09:15:23 2011 (r218258) @@ -2128,11 +2128,17 @@ retry_space: } /* - * Get a sendfile buf. We usually wait as long - * as necessary, but this wait can be interrupted. + * Get a sendfile buf. When allocating the + * first buffer for mbuf chain, we usually + * wait as long as necessary, but this wait + * can be interrupted. For consequent + * buffers, do not sleep, since several + * threads might exhaust the buffers and then + * deadlock. */ - if ((sf = sf_buf_alloc(pg, - (mnw ? SFB_NOWAIT : SFB_CATCH))) == NULL) { + sf = sf_buf_alloc(pg, (mnw || m != NULL) ? SFB_NOWAIT : + SFB_CATCH); + if (sf == NULL) { mbstat.sf_allocfail++; vm_page_lock_queues(); vm_page_unwire(pg, 0); @@ -2142,7 +2148,8 @@ retry_space: if (pg->wire_count == 0 && pg->object == NULL) vm_page_free(pg); vm_page_unlock_queues(); - error = (mnw ? EAGAIN : EINTR); + if (m == NULL) + error = (mnw ? EAGAIN : EINTR); break; }